Processing- Painting Program and Landscape

screen-shot-2016-09-29-at-2-26-12-pmscreen-shot-2016-09-29-at-2-01-59-pmscreen-shot-2016-09-29-at-2-16-01-pm

float valueR;
float valueG;
float valueB;
float valueW;
float linny=5;
float valueW2= 50;
float memR;
float memG;
float memB;
float memW;
int counter=0;
color paintbrush;
int backbackR=255;
int backbackG=255;
int backbackB=255;
void setup() {
size (1000, 1000, FX2D);
smooth();
background(backbackR, backbackG, backbackB);
frameRate(60);
}

void draw() {
counter++;
//image();
if (mousePressed == true) {
//fill(paintbrush);
//noStroke();
//ellipse(mouseX, mouseY, 30, 30);
stroke(paintbrush);
if ( key==’w’) {
strokeWeight(100);
} else {
strokeWeight(linny);
}
line(pmouseX, pmouseY, mouseX, mouseY);
}
//constraints
if (valueR > 255) {
valueR = 255;
}
if (valueR < 0) {
valueR = 0;
}
if (valueG > 255) {
valueG = 255;
}
if (valueG < 0) {
valueG = 0;
}
if (valueB > 255) {
valueB = 255;
}
if (valueB < 0) {
valueB = 0;
}
if (linny > 300) {
linny=1000;
}
if (linny < 1) {
linny= 1;
}
if (keyPressed) {
if (valueR >= 0 && valueR <= 255) {
if (key == ‘R’) {
valueR += 2;
} else if (key == ‘r’) {
valueR -= 2;
}
}
if (valueG >= 0 && valueG <= 255) {
if (key == ‘G’) {
valueG += 2;
} else if (key == ‘g’) {
valueG -= 2;
}
}
if (valueB >= 0 && valueB <= 255) {
if (key == ‘B’) {
valueB += 2;
} else if (key == ‘b’) {
valueB -= 2;
}
if (key == ‘w’) {
valueR=255;
valueG=255;
valueB=255;
}
if (key == ‘C’) {
valueR=0;
valueG=0;
valueB=0;
}
if (key == ‘X’) {
linny=5;
}
if (key==’D’) {
background (255);
}
if (key==’a’) {
linny+=1;
}
if (key== ‘s’) {
linny-=1;
}
if (key== ‘f’) {
valueR= random(255);
valueG=random(255);
valueB=random(255);
}
if (counter>=100) {
counter=0;
}
}
if (key==’1′) {
backbackR= 0;
backbackG=0;
backbackB=0;
background(backbackR, backbackG, backbackB);
}
if (key==’2′) {
backbackR= 255;
backbackG=255;
backbackB=255;
background(backbackR, backbackG, backbackB);
}
if (key==’3′) {
backbackR= 255;
backbackG=0;
backbackB=0;
background(backbackR, backbackG, backbackB);
}
if (key==’4′) {
backbackR= 0;
backbackG=255;
backbackB=0;
background(backbackR, backbackG, backbackB);
}
if (key==’5′) {
backbackR= 0;
backbackG=0;
backbackB=255;
background(backbackR, backbackG, backbackB);
}
if (key==’5′) {
backbackR= 0;
backbackG=0;
backbackB=255;
background(backbackR, backbackG, backbackB);
}
if (key==’6′) {
backbackR= 255;
backbackG=255;
backbackB=0;
background(backbackR, backbackG, backbackB);
}
if (key==’7′) {
backbackR= 255;
backbackG=0;
backbackB=255;
background(backbackR, backbackG, backbackB);
}
if (key==’8′) {
backbackR= 0;
backbackG=255;
backbackB=255;
background(backbackR, backbackG, backbackB);
}
if (key==’9′) {
backbackR= 128;
backbackG=128;
backbackB=128;
background(backbackR, backbackG, backbackB);
}
if (key== ‘Q’) {
linny=300;
}
if (key== ‘q’) {
linny=1;
}
if (key== ‘h’) {
filter(ERODE);
}
if (key== ‘j’) {
filter(BLUR);
}
if (key== ‘k’){
filter(DILATE);
}
}
paintbrush=color(valueR, valueG, valueB);
smooth();

ellipseMode(CORNER);
rectMode(CORNER);
noStroke();
fill (paintbrush);
ellipse(0, 0, 80, 80);//head

fill(128);
rect(0, 0, 46, 46, 0, 23, 23, 23);//pupil

cursor(CROSS);
}
void keyPressed() {
if (key == ‘w’) {
memR=valueR;
memG=valueG;
memB=valueB;
memW=valueW;
}
if (key==’`’) {
saveFrame(“painting.png”);
}
if (key==’~’) {
loadImage(“painting.png”);
}
}
void keyReleased() {
if (key == ‘w’) {
valueR=memR;
valueG=memG;
valueB=memB;
valueW=memW;
}
}

Advertisements
This entry was posted in Non-Time Based and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s