Tut­o­r­i­a­l week 8

by Brittany Klaassens

two circles changes in size and position with the mouse

  • Show Code
/** @peep sketch */
 
color black = color(0, 0, 0);
color darkBlue = color(0, 102, 153);
color pink = color(255, 0, 127);
 
void setup() {
  size(200, 200);
  noStroke();
}
 
void draw() {
  background(255);
  float radius1 = 100 + (height-mouseX )/ 2;
  float radius2 = 10 + (width - mouseX) / 2;
  fill(pink, 128);
  ellipse(mouseX, mouseY, radius1, radius1);
  fill(black, 128);
  ellipse(mouseX, height/5, radius2, radius2);
}

paint using mouse:

  • Show Code
/** @peep sketch */
 
color lightpink = color(255, 204, 229);
color darkpink = color(255, 0, 127);
color eraser = color(0);
 
void setup() {
  size(200, 200);
  background(0);
}
 
void draw() {
  if (mousePressed) {
    if (mouseButton == LEFT) {
      stroke(darkpink);
    } else if (mouseButton == RIGHT) {
      stroke(eraser);
      strokeWeight(10);
    }
    line(pmouseX, pmouseY, mouseX, mouseY);
  }
 
}

Comments

Nobody has said anything yet.