mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-10-12 01:45:18 +02:00
Viele weitere Beispielprojekt für verschiedene Anwendungen
This commit is contained in:
51
examples/zm_follow/Eye.java
Normal file
51
examples/zm_follow/Eye.java
Normal file
@@ -0,0 +1,51 @@
|
||||
import schule.ngb.zm.Color;
|
||||
import schule.ngb.zm.DrawingLayer;
|
||||
import schule.ngb.zm.Vector;
|
||||
import schule.ngb.zm.Zeichenobjekt;
|
||||
|
||||
public class Eye extends Zeichenobjekt {
|
||||
|
||||
private Vector position;
|
||||
|
||||
private double size;
|
||||
|
||||
private Color color;
|
||||
|
||||
public Eye() {
|
||||
position = Vector.random(0, width, 0, height);
|
||||
size = random(10.0, 25.0);
|
||||
color = null;
|
||||
}
|
||||
|
||||
public Eye( float x, float y ) {
|
||||
position = new Vector(x, y);
|
||||
size = random(10.0, 25.0);
|
||||
color = null;
|
||||
}
|
||||
|
||||
public Eye( float x, float y, Color color ) {
|
||||
position = new Vector(x, y);
|
||||
size = random(10.0, 25.0);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw( DrawingLayer drawing ) {
|
||||
Vector dir = Vector.sub(new Vector(mouseX, mouseY), position);
|
||||
double len = dir.length();
|
||||
|
||||
drawing.setStrokeColor(0);
|
||||
if( color == null ) {
|
||||
drawing.setFillColor(colorHsb(354, 100.0 - limit(len, 0.0, 100.0), 100));
|
||||
} else {
|
||||
drawing.setFillColor(color);
|
||||
}
|
||||
drawing.circle(position.x, position.y, size);
|
||||
|
||||
|
||||
Vector pupil = Vector.add(position, dir.limit(size*.4));
|
||||
|
||||
drawing.setFillColor(0);
|
||||
drawing.circle(pupil.x, pupil.y, size*.4);
|
||||
}
|
||||
}
|
||||
38
examples/zm_follow/Eyes.java
Normal file
38
examples/zm_follow/Eyes.java
Normal file
@@ -0,0 +1,38 @@
|
||||
import schule.ngb.zm.Zeichenmaschine;
|
||||
|
||||
public class Eyes extends Zeichenmaschine {
|
||||
|
||||
public static final int N_EYES = 30;
|
||||
|
||||
public static void main( String[] args ) {
|
||||
new Eyes();
|
||||
}
|
||||
|
||||
Eye[] eyes;
|
||||
|
||||
public Eyes() {
|
||||
super(600, 600, "Eyes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
eyes = new Eye[N_EYES];
|
||||
for( int i = 0; i < eyes.length; i++ ) {
|
||||
eyes[i] = new Eye();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( double delta ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
drawing.clear(200);
|
||||
|
||||
for( int i = 0; i < eyes.length; i++ ) {
|
||||
eyes[i].draw(drawing);
|
||||
}
|
||||
}
|
||||
}
|
||||
55
examples/zm_follow/package.bluej
Normal file
55
examples/zm_follow/package.bluej
Normal file
@@ -0,0 +1,55 @@
|
||||
#BlueJ package file
|
||||
dependency1.from=Attractor
|
||||
dependency1.to=Gravity
|
||||
dependency1.type=UsesDependency
|
||||
dependency2.from=Gravity
|
||||
dependency2.to=Mover
|
||||
dependency2.type=UsesDependency
|
||||
dependency3.from=Gravity
|
||||
dependency3.to=Attractor
|
||||
dependency3.type=UsesDependency
|
||||
editor.fx.0.height=728
|
||||
editor.fx.0.width=1037
|
||||
editor.fx.0.x=95
|
||||
editor.fx.0.y=53
|
||||
objectbench.height=94
|
||||
objectbench.width=776
|
||||
package.divider.horizontal=0.6
|
||||
package.divider.vertical=0.8305369127516778
|
||||
package.editor.height=488
|
||||
package.editor.width=661
|
||||
package.editor.x=374
|
||||
package.editor.y=158
|
||||
package.frame.height=660
|
||||
package.frame.width=800
|
||||
package.numDependencies=3
|
||||
package.numTargets=3
|
||||
package.showExtends=true
|
||||
package.showUses=true
|
||||
project.charset=UTF-8
|
||||
readme.height=60
|
||||
readme.name=@README
|
||||
readme.width=48
|
||||
readme.x=10
|
||||
readme.y=10
|
||||
target1.height=70
|
||||
target1.name=Mover
|
||||
target1.showInterface=false
|
||||
target1.type=ClassTarget
|
||||
target1.width=120
|
||||
target1.x=380
|
||||
target1.y=220
|
||||
target2.height=70
|
||||
target2.name=Attractor
|
||||
target2.showInterface=false
|
||||
target2.type=ClassTarget
|
||||
target2.width=120
|
||||
target2.x=380
|
||||
target2.y=350
|
||||
target3.height=70
|
||||
target3.name=Gravity
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.width=120
|
||||
target3.x=120
|
||||
target3.y=120
|
||||
Reference in New Issue
Block a user