Szkicownik – kolejna wersja

Kolejna wersja naszego szkicownika w Processingu:

GRUPA 17:10:

//—————————————————————————————

int brushSize, gumSize;
color brushColor = color(0, 255, 0);
color canvasColor = color(255, 255, 255);

void setup(){
size(600, 600);
background(canvasColor);
brushSize = 10;
gumSize = 50;
}

void draw(){
if(mousePressed == true && mouseButton == LEFT){
noStroke();
fill(brushColor);
ellipse(mouseX, mouseY, brushSize, brushSize);
}
if(mousePressed == true && mouseButton == RIGHT){
noStroke();
fill(canvasColor);
ellipse(mouseX, mouseY, gumSize, gumSize);
}
if(keyPressed == true && key == 's'){
saveFrame("rysunek-######.png");
}
if(keyPressed == true && key == 'c'){
background(canvasColor);
}

}

GRUPA 18:20:

//—————————————————————————————

color brushColor = color(255, 255, 0);
color canvasColor = color(0, 100, 0);
color c1 = color(255, 0, 0);
color c2 = color(0, 255, 0);
color c3 = color(0, 0, 255);
int p1x, p1y, dx, dy;

void setup() {
size(600, 600);
background(canvasColor);
p1x = 10;
p1y = 10;
dx = 20;
dy = 20;
}

void draw() {
noStroke();
fill(c1);
rect(p1x,p1y,dx,dy);

if(mousePressed == true
&& mouseX > p1x
&& mouseX < p1x+dx
&& mouseY > p1y
&& mouseY < p1y+dy)
{
brushColor = c1;
}

if (mousePressed == true && mouseButton == LEFT) {
noStroke();
fill(brushColor);
ellipse(mouseX, mouseY, 20, 20);
}
if (mousePressed == true && mouseButton == RIGHT){
noStroke();
fill(canvasColor);
ellipse(mouseX, mouseY, 50, 50);
}

if(keyPressed == true && key == 'c'){
background(canvasColor);
}

if(keyPressed == true && key == 's'){
saveFrame("rysunek.png");
}
}
Udostępnij znajomym

Zostaw komentarz