Drawing Software Version 2

screen-shot-2016-12-14-at-10-39-37-am

I have redone my Drawing Software code in Processing, You can still use the A, Z, S, X, D, and C keys to change the brush color, use the bracket keys to change the brush’s size, and press the F key to fill-in the background. Now there is a secondary Color that you can change the color with the I, J, O, K, P, and L keys. You can also change the shape of the brush: 1 is the default circle, 2 is a square, and 3 is a triangle.

Code:

color alpha;
color beta;
color paint;
int alphaR=0;
int alphaG=0;
int alphaB=0;
int betaR=255;
int betaG=255;
int betaB=255;
boolean alphaRA=false;
boolean alphaRS=false;
boolean alphaGA=false;
boolean alphaGS=false;
boolean alphaBA=false;
boolean alphaBS=false;
boolean betaRA=false;
boolean betaRS=false;
boolean betaGA=false;
boolean betaGS=false;
boolean betaBA=false;
boolean betaBS=false;
int brushSize=30;
float brushOp=255;
boolean circle=true;
boolean square=false;
boolean triangle=false;
boolean star=false;
void setup(){
size(1000,1200);
background(255);

}
void draw(){
rectMode(CORNER);
fill(160);
rect(0,0,200,1000);
alpha=color(alphaR,alphaG,alphaB);
beta=color(betaR,betaG,betaB);
fill(alpha);
rect(0,0,100,100);
fill(beta);
rect(100,0,100,100);
if(alphaRA==true){
alphaR=alphaR+1;
if(alphaR>255){
alphaR=255;
}
}
if(alphaRS==true){
alphaR=alphaR-1;
if(alphaR<0){
alphaR=0;
}
}
if(alphaGA==true){
alphaG=alphaG+1;
if(alphaG>255){
alphaG=255;
}
}
if(alphaGS==true){
alphaG=alphaG-1;
if(alphaG<0){
alphaG=0;
}
}
if(alphaBA==true){
alphaB=alphaB+1;
if(alphaB>255){
alphaB=255;
}
}
if(alphaBS==true){
alphaB=alphaB-1;
if(alphaB<0){
alphaB=0;
}
}
if(betaRA==true){
betaR=betaR+1;
if(betaR>255){
betaR=255;
}
}
if(betaRS==true){
betaR=betaR-1;
if(betaR<0){
betaR=0;
}
}
if(betaGA==true){
betaG=betaG+1;
if(betaG>255){
betaG=255;
}
}
if(betaGS==true){
betaG=betaG-1;
if(betaG<0){
betaG=0;
}
}
if(betaBA==true){
betaB=betaB+1;
if(betaB>255){
betaB=255;
}
}
if(betaBS==true){
betaB=betaB-1;
if(betaB<0){
betaB=0;
}
}
}
void keyPressed(){
if(key==’a’){
alphaRA=true;
}
if(key==’z’){
alphaRS=true;
}
if(key==’s’){
alphaGA=true;
}
if(key==’x’){
alphaGS=true;
}
if(key==’d’){
alphaBA=true;
}
if(key==’c’){
alphaBS=true;
}
if(key==’i’){
betaRA=true;
}
if(key==’j’){
betaRS=true;
}
if(key==’o’){
betaGA=true;
}
if(key==’k’){
betaGS=true;
}
if(key==’p’){
betaBA=true;
}
if(key==’l’){
betaBS=true;
}
}
void keyReleased(){
if(key==’a’){
alphaRA=false;
}
if(key==’z’){
alphaRS=false;
}
if(key==’s’){
alphaGA=false;
}
if(key==’x’){
alphaGS=false;
}
if(key==’d’){
alphaBA=false;
}
if(key==’c’){
alphaBS=false;
}
if(key==’i’){
betaRA=false;
}
if(key==’j’){
betaRS=false;
}
if(key==’o’){
betaGA=false;
}
if(key==’k’){
betaGS=false;
}
if(key==’p’){
betaBA=false;
}
if(key==’l’){
betaBS=false;
}
}
void mouseDragged(){
if(mouseButton==LEFT){
paint=color(alpha);
}
if(mouseButton==RIGHT){
paint=color(beta);
}
fill(paint,brushOp);
noStroke();
if(circle==true)ellipse(mouseX,mouseY,brushSize,brushSize);
if(square==true){
rectMode(CENTER);
rect(mouseX,mouseY,brushSize,brushSize);
}
if(triangle==true)triangle(mouseX,pmouseY+brushSize/2,pmouseX+brushSize/2,pmouseY-brushSize/2,pmouseX-brushSize/2,pmouseY-brushSize/2);
}

void keyTyped(){
if(key==’f’){
background(alpha);
}
if(key=='[‘){
brushSize=brushSize-1;
if(brushSize<1){
brushSize=1;
}
}
if(key==’]’){
brushSize=brushSize+1;
if(brushSize>1500){
brushSize=1500;
}
}
if(key==’1′){
circle=true;
square=false;
triangle=false;
}
if(key==’2′){
circle=false;
square=true;
triangle=false;
}
if(key==’3′){
circle=false;
square=false;
triangle=true;
}
}

Advertisements

About degrafgo

I am a fun, green loving guy who owns 3 YouTube channels under the name DeGraphics.
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