done renaming
This commit is contained in:
parent
5870c6ba9c
commit
9a3380dee1
@ -0,0 +1,8 @@
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(200);
|
||||
ellipse(frameCount%width, 300, 100, 100);
|
||||
}
|
||||
19
Lektion 1/Arithmetische_Operatoren/Muster/Muster.pde
Normal file
19
Lektion 1/Arithmetische_Operatoren/Muster/Muster.pde
Normal file
@ -0,0 +1,19 @@
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
}
|
||||
int x = 0;
|
||||
float y = 0;
|
||||
|
||||
void draw() {
|
||||
if (x % 3 == 0) {
|
||||
stroke(0);
|
||||
} else if (x % 3 == 1) {
|
||||
stroke(150);
|
||||
} else {
|
||||
stroke(230);
|
||||
}
|
||||
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y+= 0.5;
|
||||
}
|
||||
20
Lektion 1/Arithmetische_Operatoren/Muster_2/Muster_2.pde
Normal file
20
Lektion 1/Arithmetische_Operatoren/Muster_2/Muster_2.pde
Normal file
@ -0,0 +1,20 @@
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
void draw() {
|
||||
if (x % 3 == 0) {
|
||||
stroke(0);
|
||||
} else if (x % 3 == 1) {
|
||||
stroke(150);
|
||||
} else {
|
||||
stroke(230);
|
||||
}
|
||||
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y+= 1;
|
||||
}
|
||||
14
Lektion 1/Arithmetische_Operatoren/Muster_3/Muster_3.pde
Normal file
14
Lektion 1/Arithmetische_Operatoren/Muster_3/Muster_3.pde
Normal file
@ -0,0 +1,14 @@
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
|
||||
y = height;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y-= 1;
|
||||
}
|
||||
13
Lektion 1/Arithmetische_Operatoren/Muster_4/Muster_4.pde
Normal file
13
Lektion 1/Arithmetische_Operatoren/Muster_4/Muster_4.pde
Normal file
@ -0,0 +1,13 @@
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
void draw() {
|
||||
stroke(x / (width / 255));
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y+= 1;
|
||||
}
|
||||
8
Lektion 1/Datentypen/Halbe_Pixel/Halbe_Pixel.pde
Normal file
8
Lektion 1/Datentypen/Halbe_Pixel/Halbe_Pixel.pde
Normal file
@ -0,0 +1,8 @@
|
||||
// Der Kreis wandert alleine nach rechts
|
||||
float x = 0;
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
x+=0.5;
|
||||
ellipse(x, 50, 30, 30);
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
void draw() {
|
||||
frameRate(10);
|
||||
println("x=" + mouseX + " y=" + mouseX);
|
||||
}
|
||||
11
Lektion 1/Datentypen/Zeichenverkettung/Zeichenverkettung.pde
Normal file
11
Lektion 1/Datentypen/Zeichenverkettung/Zeichenverkettung.pde
Normal file
@ -0,0 +1,11 @@
|
||||
String message = "la";
|
||||
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
frameRate(10);
|
||||
println(message);
|
||||
message += " la";
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
background(255);
|
||||
// Viereck in der mitte
|
||||
|
||||
15
Lektion 1/Lokale_Variablen/Mitte/Mitte.pde
Normal file
15
Lektion 1/Lokale_Variablen/Mitte/Mitte.pde
Normal file
@ -0,0 +1,15 @@
|
||||
void setup()
|
||||
{
|
||||
size(800, 600);
|
||||
}
|
||||
void draw()
|
||||
{
|
||||
// Clear Background to prevent shadows
|
||||
background(40, 40, 40, 256);
|
||||
|
||||
|
||||
line(0, 0, mouseX, mouseY);
|
||||
|
||||
circle(mouseX, mouseY, 10);
|
||||
circle(mouseX * .5, mouseY * .5, 10);
|
||||
}
|
||||
24
Lektion 1/Lokale_Variablen/Zwillinge/Zwillinge.pde
Normal file
24
Lektion 1/Lokale_Variablen/Zwillinge/Zwillinge.pde
Normal file
@ -0,0 +1,24 @@
|
||||
void setup()
|
||||
{
|
||||
size(800, 600);
|
||||
}
|
||||
void draw()
|
||||
{
|
||||
// Clear Background to prevent shadows
|
||||
background(40, 40, 40, 256);
|
||||
|
||||
//First circle
|
||||
fill(0, 50, 256);
|
||||
circle(mouseX, mouseY, 100);
|
||||
|
||||
// Second circle
|
||||
// project mouse pos between 0 and 1. Take inverse to get the point symmetric postion
|
||||
PVector fitMouse = new PVector((float) mouseX / (float) width, (float) mouseY / (float) height);
|
||||
PVector twinPos = new PVector((1.0f - fitMouse.x) * width, (1.0f - fitMouse.y) * height);
|
||||
|
||||
fill(256, 50, 0);
|
||||
circle(twinPos.x, twinPos.y, 100);
|
||||
|
||||
|
||||
//println(fitMouseX + ", " + inverseMouseX );
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
final int SPEED = 3;
|
||||
final int RADIUS = 10;
|
||||
|
||||
boolean left1 = true;
|
||||
boolean left2 = true;
|
||||
boolean left3 = true;
|
||||
|
||||
float x1 = random(50, width-50);
|
||||
float x2 = random(50, width-50);
|
||||
float x3 = random(50, width-50);
|
||||
|
||||
void setup () {
|
||||
size(200, 200);
|
||||
}
|
||||
|
||||
// move balls
|
||||
void moveballs() {
|
||||
if (x1+RADIUS>width) {
|
||||
left1=true;
|
||||
}
|
||||
if (x1-RADIUS<0) {
|
||||
left1=false;
|
||||
}
|
||||
if (left1) {
|
||||
x1-=SPEED;
|
||||
} else {
|
||||
x1+=SPEED;
|
||||
}
|
||||
if (x2+RADIUS>width) {
|
||||
left2=true;
|
||||
}
|
||||
if (x2-RADIUS<0) {
|
||||
left2=false;
|
||||
}
|
||||
if (left2) {
|
||||
x2-=SPEED;
|
||||
} else {
|
||||
x2+=SPEED;
|
||||
}
|
||||
if (x3+RADIUS>width) {
|
||||
left3=true;
|
||||
}
|
||||
if (x3-RADIUS<0) {
|
||||
left3=false;
|
||||
}
|
||||
if (left3) {
|
||||
x3-=SPEED;
|
||||
} else {
|
||||
x3+=SPEED;
|
||||
}
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(50);
|
||||
fill(200, 50, 50);
|
||||
|
||||
ellipse(x1, width*0.25, RADIUS*2, RADIUS*2);
|
||||
ellipse(x2, width*0.5, RADIUS*2, RADIUS*2);
|
||||
ellipse(x3, width*0.75, RADIUS*2, RADIUS*2);
|
||||
moveballs();
|
||||
}
|
||||
12
Lektion 1/Systemvariablen/Mitte/Mitte.pde
Normal file
12
Lektion 1/Systemvariablen/Mitte/Mitte.pde
Normal file
@ -0,0 +1,12 @@
|
||||
void setup()
|
||||
{
|
||||
size(111, 77);
|
||||
surface.setResizable(true);
|
||||
}
|
||||
void draw()
|
||||
{
|
||||
// Beim übertragen richtige Fenstergröße (111 x 77) in die main (setup) Methode eintragen und surface.setResizable(true) setzen
|
||||
background(40, 40, 40, 256);
|
||||
circle(width/2, height/2,50);
|
||||
|
||||
}
|
||||
23
Lektion 1/Systemvariablen/Zaehler/Zaehler.pde
Normal file
23
Lektion 1/Systemvariablen/Zaehler/Zaehler.pde
Normal file
@ -0,0 +1,23 @@
|
||||
void setup()
|
||||
{
|
||||
size(800, 600);
|
||||
frameRate(60);
|
||||
}
|
||||
float second;
|
||||
float offset = 0;
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(40, 40, 40, 256);
|
||||
//fill(0,0,0,1);
|
||||
second = constrain(((float) frameCount / (float) frameRate) - offset, 0 , 1000);
|
||||
|
||||
if(mousePressed == true)
|
||||
{
|
||||
offset = second + offset ;
|
||||
}
|
||||
|
||||
println(offset + " " + mousePressed);
|
||||
textSize(50);
|
||||
text(second, width / 2 -50, height/2);
|
||||
}
|
||||
13
Lektion 1/Systemvariablen/Zeichen_Ticker/Zeichen_Ticker.pde
Normal file
13
Lektion 1/Systemvariablen/Zeichen_Ticker/Zeichen_Ticker.pde
Normal file
@ -0,0 +1,13 @@
|
||||
void setup()
|
||||
{
|
||||
size(800, 600);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
// Clear Background to prevent shadows
|
||||
background(40, 40, 40, 256);
|
||||
|
||||
textSize(50);
|
||||
text(key, width / 2, height / 2);
|
||||
}
|
||||
19
Lektion 1/Text-Ausgabe/Ecken/Ecken.pde
Normal file
19
Lektion 1/Text-Ausgabe/Ecken/Ecken.pde
Normal file
@ -0,0 +1,19 @@
|
||||
void setup() {
|
||||
size(500, 500);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
textSize(20);
|
||||
textAlign(LEFT, TOP);
|
||||
fill(0);
|
||||
text("OBEN LINKS", 0, 0);
|
||||
textAlign(RIGHT, TOP);
|
||||
fill(0);
|
||||
text("OBEN RECHTS", width, 0);
|
||||
textAlign(LEFT, BOTTOM);
|
||||
fill(0);
|
||||
text("UNTEN LINKS", 0, width);
|
||||
textAlign(RIGHT, BOTTOM);
|
||||
fill(0);
|
||||
text("UNTEN RECHTS", width, width);
|
||||
}
|
||||
11
Lektion 1/Text-Ausgabe/TextMauszeiger/TextMauszeiger.pde
Normal file
11
Lektion 1/Text-Ausgabe/TextMauszeiger/TextMauszeiger.pde
Normal file
@ -0,0 +1,11 @@
|
||||
void setup() {
|
||||
size(600, 600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(200);
|
||||
textSize(20);
|
||||
textAlign(CENTER);
|
||||
fill(0);
|
||||
text("maus", mouseX, mouseY);
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
size(300, 300);
|
||||
|
||||
textSize(100);
|
||||
textAlign(CENTER);
|
||||
fill(0, 100);
|
||||
text("Julia", 153, 153);
|
||||
fill(255);
|
||||
text("Julia", 150, 150);
|
||||
@ -1,16 +1,24 @@
|
||||
background (233,0,57); // roter Hintergrund
|
||||
noStroke (); // Entfernung der Linien um Überlappung beider Figuren zu verbergen
|
||||
fill (1,50,100); //blaue Färbung
|
||||
|
||||
|
||||
fill (255, 10); // sorgt für Sichtbarkeit aller Linien (Transparenz)
|
||||
|
||||
beginShape (); // Vieleck mit Spitze nach oben
|
||||
vertex (30,80); //linker "Fuß"
|
||||
vertex (50,15); //die obere Spitze
|
||||
vertex (70,80); //rechter "Fuß"
|
||||
vertex (45,60); // Verbindungspunkt
|
||||
endShape ();
|
||||
vertex (50,65); // Verbindungspunkt
|
||||
endShape (CLOSE);
|
||||
|
||||
beginShape (); //Vieleck mit Spitze nach schräg rechts
|
||||
vertex (80, 40); // rechter Arm Spitze
|
||||
vertex (30, 80); // linker Fuß
|
||||
vertex (35, 55); // Verbindungspunkt
|
||||
vertex (37, 55); // Verbindungspunkt
|
||||
vertex (20, 40); // linker Arm Spitze
|
||||
endShape ();
|
||||
endShape (CLOSE);
|
||||
|
||||
beginShape (); // Vieleck mit Spitze nach schräg links
|
||||
vertex (70,80); //rechter Fuß
|
||||
vertex (20,40); //linker Arm
|
||||
vertex (80,40); //rechter Arm
|
||||
vertex (63,55); // Verbindungspunkt
|
||||
endShape (CLOSE);
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
|
||||
|
||||
fill (255, 10); // sorgt für Sichtbarkeit aller Linien (Transparenz)
|
||||
|
||||
beginShape (); // Vieleck mit Spitze nach oben
|
||||
vertex (30,80); //linker "Fuß"
|
||||
vertex (50,15); //die obere Spitze
|
||||
vertex (70,80); //rechter "Fuß"
|
||||
vertex (50,65); // Verbindungspunkt
|
||||
endShape (CLOSE);
|
||||
|
||||
beginShape (); //Vieleck mit Spitze nach schräg rechts
|
||||
vertex (80, 40); // rechter Arm Spitze
|
||||
vertex (30, 80); // linker Fuß
|
||||
vertex (37, 55); // Verbindungspunkt
|
||||
vertex (20, 40); // linker Arm Spitze
|
||||
endShape (CLOSE);
|
||||
|
||||
beginShape (); // Vieleck mit Spitze nach schräg links
|
||||
vertex (70,80); //rechter Fuß
|
||||
vertex (20,40); //linker Arm
|
||||
vertex (80,40); //rechter Arm
|
||||
vertex (63,55); // Verbindungspunkt
|
||||
endShape (CLOSE);
|
||||
72
scratch/ArithmetischeOperatoren.pde
Normal file
72
scratch/ArithmetischeOperatoren.pde
Normal file
@ -0,0 +1,72 @@
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
}
|
||||
|
||||
// Animation mit Modulo
|
||||
/*void draw() {
|
||||
background(200);
|
||||
ellipse(frameCount%width, 300, 100, 100);
|
||||
}*/
|
||||
|
||||
// Muster 4
|
||||
/*int x = 0;
|
||||
int y = 0;
|
||||
|
||||
void draw() {
|
||||
stroke(x / (width / 255));
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y+= 1;
|
||||
}*/
|
||||
|
||||
// Muster 3
|
||||
/*int x = 0;
|
||||
int y = 0;
|
||||
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
|
||||
y = height;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y-= 1;
|
||||
}*/
|
||||
|
||||
// Muster 2
|
||||
/*int x = 0;
|
||||
int y = 0;
|
||||
|
||||
void draw() {
|
||||
if (x % 3 == 0) {
|
||||
stroke(0);
|
||||
} else if (x % 3 == 1) {
|
||||
stroke(150);
|
||||
} else {
|
||||
stroke(230);
|
||||
}
|
||||
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y+= 1;
|
||||
}*/
|
||||
|
||||
// Muster 1
|
||||
/*int x = 0;
|
||||
float y = 0;
|
||||
|
||||
void draw() {
|
||||
if (x % 3 == 0) {
|
||||
stroke(0);
|
||||
} else if (x % 3 == 1) {
|
||||
stroke(150);
|
||||
} else {
|
||||
stroke(230);
|
||||
}
|
||||
|
||||
line(x, 0, x, y);
|
||||
x+= 1;
|
||||
y+= 0.5;
|
||||
}*/
|
||||
32
scratch/Datentypen.pde
Normal file
32
scratch/Datentypen.pde
Normal file
@ -0,0 +1,32 @@
|
||||
/*void setup() {
|
||||
size(800, 600);
|
||||
}*/
|
||||
|
||||
// Zeichenverkettung
|
||||
String message = "la";
|
||||
|
||||
void setup() {
|
||||
size(800, 600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
frameRate(10);
|
||||
println(message);
|
||||
message += " la";
|
||||
}
|
||||
|
||||
// Halbe Pixel?
|
||||
// Der Kreis wandert alleine nach rechts
|
||||
/*float x = 0;
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
x+=0.5;
|
||||
ellipse(x, 50, 30, 30);
|
||||
}*/
|
||||
|
||||
// Mausposition ausgeben
|
||||
/*void draw() {
|
||||
frameRate(10);
|
||||
println("x=" + mouseX + " y=" + mouseX);
|
||||
}*/
|
||||
16
scratch/Stern/Stern.pde
Normal file
16
scratch/Stern/Stern.pde
Normal file
@ -0,0 +1,16 @@
|
||||
background (233,0,57); // roter Hintergrund
|
||||
noStroke (); // Entfernung der Linien um Überlappung beider Figuren zu verbergen
|
||||
fill (1,50,100); //blaue Färbung
|
||||
beginShape (); // Vieleck mit Spitze nach oben
|
||||
vertex (30,80); //linker "Fuß"
|
||||
vertex (50,15); //die obere Spitze
|
||||
vertex (70,80); //rechter "Fuß"
|
||||
vertex (45,60); // Verbindungspunkt
|
||||
endShape ();
|
||||
|
||||
beginShape (); //Vieleck mit Spitze nach schräg rechts
|
||||
vertex (80, 40); // rechter Arm Spitze
|
||||
vertex (30, 80); // linker Fuß
|
||||
vertex (35, 55); // Verbindungspunkt
|
||||
vertex (20, 40); // linker Arm Spitze
|
||||
endShape ();
|
||||
@ -0,0 +1,135 @@
|
||||
/*
|
||||
|
||||
----Lokale Variablen----
|
||||
|
||||
1. Wie lange ist eine Variable gültig, die innerhalb einer Funktion deklariert wurde?
|
||||
|
||||
- bis zum Ende des Programms
|
||||
- bis zum Ende des nächsten Durchlaufs der draw-Funktion
|
||||
X bis zum Ende der Funktion
|
||||
|
||||
2. Wie wird der Bereich bezeichnet, in dem eine Variable gültig ist und verwendet werden kann?
|
||||
|
||||
Scope
|
||||
|
||||
3. Was genau passiert, wenn sich zwei Variablen überschatten? Worauf muss man achten, wenn man Überschattung vermeiden möchte?
|
||||
|
||||
Bei "variable shadowing" wird der Wert einer globalen Variable im Scope der Funktion der lokalen Variable "überschattet".
|
||||
Wenn man vorher also eine globale Variable (x = 5) setzt, diese in der Funktion setX() als lokale Variable neu Deklariert und Initialisiert (x = 3) ,
|
||||
Überschattet der Wert der Lokalen Variable (x = 3) für dessen Scope die globale Variable. Geht die lokale Variable "out of scope", dann
|
||||
gilt wieder der Wert der globalen Variable.
|
||||
|
||||
Um dies zu verhindern sollte man nie den selben Namen für eine Variable verwenden und bei Zuweisungen darauf achten keinen Datentyp dem
|
||||
Namen voranzusetzen.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Aufgabe 1
|
||||
void zwillinge()
|
||||
{
|
||||
// Clear Background to prevent shadows
|
||||
background(40, 40, 40, 256);
|
||||
|
||||
//First circle
|
||||
fill(0, 50, 256);
|
||||
circle(mouseX, mouseY, 100);
|
||||
|
||||
// Second circle
|
||||
// project mouse pos between 0 and 1. Take inverse to get the point symmetric postion
|
||||
PVector fitMouse = new PVector((float) mouseX / (float) width, (float) mouseY / (float) height);
|
||||
PVector twinPos = new PVector((1.0f - fitMouse.x) * width, (1.0f - fitMouse.y) * height);
|
||||
|
||||
fill(256, 50, 0);
|
||||
circle(twinPos.x, twinPos.y, 100);
|
||||
|
||||
|
||||
//println(fitMouseX + ", " + inverseMouseX );
|
||||
}
|
||||
|
||||
void drillinge()
|
||||
{
|
||||
// Clear Background to prevent shadows
|
||||
background(40, 40, 40, 256);
|
||||
|
||||
|
||||
line(0, 0, mouseX, mouseY);
|
||||
|
||||
circle(mouseX, mouseY, 10);
|
||||
circle(mouseX * .5, mouseY * .5, 10);
|
||||
}
|
||||
|
||||
/*
|
||||
----Systemvariablen----
|
||||
|
||||
1. Was sind Systemvariablen?
|
||||
|
||||
Systemvariablen sind variablen die bereitgestellt werden um diese zu verwenden. Beispielsweise die Mausposition oder die Fenstergröße
|
||||
|
||||
2. Was passiert, wenn du eine Variable anlegst, die den selben Namen wie eine Systemvariable hat? Tip: Probiere es mal aus ...
|
||||
|
||||
Die Systemvariable wird von dem selbst gesetzten Wert überschrieben.
|
||||
|
||||
3. Welche 2 Dinge sollte man im Bezug auf Systemvariablen niemals machen? Warum?
|
||||
|
||||
- Den Systemvariablen einen neuen Wert zuweisen
|
||||
- Eigenen Variablen den selben Namen geben
|
||||
*/
|
||||
|
||||
void zeichenTicker()
|
||||
{
|
||||
// Clear Background to prevent shadows
|
||||
background(40, 40, 40, 256);
|
||||
|
||||
textSize(50);
|
||||
text(key, width / 2, height / 2);
|
||||
}
|
||||
|
||||
void mitte()
|
||||
{
|
||||
// Beim übertragen richtige Fenstergröße (111 x 77) in die main (setup) Methode eintragen und surface.setResizable(true) setzen
|
||||
background(40, 40, 40, 256);
|
||||
circle(width/2, height/2,50);
|
||||
|
||||
}
|
||||
|
||||
float second;
|
||||
float offset = 0;
|
||||
|
||||
void zähler()
|
||||
{
|
||||
background(40, 40, 40, 256);
|
||||
//fill(0,0,0,1);
|
||||
second = constrain(((float) frameCount / (float) frameRate) - offset, 0 , 1000);
|
||||
|
||||
if(mousePressed == true)
|
||||
{
|
||||
offset = second + offset ;
|
||||
}
|
||||
|
||||
println(offset + " " + mousePressed);
|
||||
textSize(50);
|
||||
text(second, width / 2 -50, height/2);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(800, 600);
|
||||
frameRate(144);
|
||||
//surface.setResizable(true);
|
||||
}
|
||||
void draw()
|
||||
{
|
||||
|
||||
// ----lokale Variablen----
|
||||
// zwillinge();
|
||||
drillinge();
|
||||
|
||||
// ----Systemvariablen----
|
||||
//zeichenTicker();
|
||||
//mitte();
|
||||
// zähler();
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user