xxxxxxxxxx
245
let rectY = 0;
let ballY;
let ballSpeed = 2;
let X1,X2,Y
let bodymove
function setup() {
createCanvas(400, 600);
ballY = height/2
bodymove = false;
}
function draw() {
background(255,230,225);
console.log('X=',mouseX);
console.log('Y=',mouseY);
background(255,230,225);
noStroke();
fill(209,238,238);
rect(0,485,400,115);
hair(random(4,26));
function hair(x){
//hair layer1
stroke(120,240,255)
strokeWeight(x)
fill(187,255,255)
triangle(95,59,128,150,208,91)
triangle(199,12,135,163,261,131)
triangle(347,70,200,119,288,148)
triangle(232,122,353,162,272,200)
triangle(321,239,244,153,241,235)
triangle(265,283,249,183,175,210)
triangle(166,284,232,198,123,184)
triangle(63,250,186,223,129,149)
triangle(45,145,194,107,200,206)
//hair layer2
noStroke()
triangle(95,59,128,150,208,91)
triangle(199,12,135,163,261,131)
triangle(347,70,200,119,288,148)
triangle(232,122,353,162,272,200)
triangle(321,239,244,153,241,235)
triangle(265,283,249,183,175,210)
triangle(166,284,232,198,123,184)
triangle(63,250,186,223,129,149)
triangle(45,145,194,107,200,206)
}
//hand1
noFill()
stroke(238,180,180)
strokeWeight(42)
bezier(209,177,228,241,323,308,363,283)
stroke(255,193,193)
strokeWeight(34)
bezier(209,177,228,241,323,308,363,283)
noStroke()
fill(255,230,225)
ellipse(361,284,23,23)
fill(238,180,180)
triangle(28,287,45,295,34,302)
triangle(34,301,19,300,29,309)
triangle(29,311,18,315,30,322)
triangle(31,321,27,333,41,331)
//Body
stroke(238,180,180)
strokeWeight(82)
line(200,161,200,307)
line(200,431,200,500)
stroke(255,193,193)
strokeWeight(75)
line(200,161,200,307)
line(200,431,200,500)
//this code doesn't work I don't know why...
if((ballY >= 196 || ballY <= 522)===true){
bodymove = true;
}
else{
bodymove = false;
}
if(bodymove === true){
middlebody1();
}
else{
middlebody2();
}
//middlebody2();
function middlebody2(){
stroke(238,180,180)
strokeWeight(82)
line(200,151,200,445)
stroke(255,193,193)
strokeWeight(75)
line(200,151,200,445)
}
//middlebody1();
function middlebody1() {
noFill()
stroke(238,180,180)
strokeWeight(82)
bezier(200,307,307,344,304,413,200,431)
stroke(255,193,193)
strokeWeight(75)
bezier(200,307,307,344,304,413,200,431)
stroke(255,193,193)
strokeWeight(75)
line(200,170,200,307)
line(200,431,200,500)
}
//hand2
noFill()
stroke(238,180,180)
strokeWeight(42)
bezier(172,185,199,239,111,325,48,314)
stroke(255,193,193)
strokeWeight(34)
bezier(172,185,199,239,111,325,48,314)
noStroke()
fill(255,230,225)
ellipse(50,315,23,23)
fill(238,180,180)
triangle(356,266,363,251,369,265)
triangle(369,264,380,258,378,269)
triangle(380,272,390,273,383,281)
triangle(383,283,391,289,382,293)
//foot
stroke(0,0,0)
strokeWeight(75)
line(200,490,200,500)
fill(255,193,193)
noStroke()
rect(162,449,76,35)
fill(255)
ellipse(200,435,12,12)
ellipse(200,470,12,12)
ellipse(200,505,12,12)
fill(0)
rect(180,530,14,50)
rect(207,530,14,50)
rect(152,570,43,12,20)
rect(206,570,43,12,20)
//face basic
stroke(230,186,200)
strokeWeight(3)
fill(238,238,224)
ellipse(200,162,108,118)
eyes(random(170,176),random(223,229),random(159,165));
function eyes(X1,X2,Y){
//eyes
stroke('black')
strokeWeight(3)
fill(255,255,255)
ellipse(X1,Y,30)
ellipse(X2,Y,30)
//eyeballs
noStroke()
fill(random(255),random(255),random(255))
ellipse(X1,Y,8)
ellipse(X2,Y,8)
}
//nose
stroke('black')
strokeWeight(3)
fill(248,248,255)
bezier(193,171,193,194,206,194,206,171)
//mouth
stroke('black')
strokeWeight(3)
line(188,199,212,199)
//eyebrow
stroke(151,225,225)
strokeWeight(13)
line(168,129,200,144)
line(229,129,200,144)
stroke(187,255,255)
strokeWeight(7)
line(168,129,200,144)
line(229,129,200,144)
scanball();
ballY += ballSpeed;
if(ballY >= height || ballY <= 0){
ballSpeed = -ballSpeed;
}
//scanrect();
rectY = rectY + 1;
if(rectY > height){
rectY = 0;
}
function scanball(){
//scan1
strokeWeight(4)
push()
blendMode(DIFFERENCE)
stroke(255,0,0)
//fill(200,100,20)
fill(255)
ellipse(200,ballY,120)
line(200,ballY-60,200,ballY+60)
line(140,ballY,260,ballY)
pop()
}
function scanrect(){
//scan2
push()
blendMode(DIFFERENCE)
stroke(0)
strokeWeight(10)
fill(0,0,255)
rect(0,rectY,400,40)
pop()
}
}