xxxxxxxxxx
123
let img;
//flower head
let petalNo=8
let flowerC='red'
let flowerX=200
let flowerY=100
let fSize=145
let petalL=50
let petalS=40
//male body
let muscleX=120
let muscleY=240
let muscleC='red'
let mW=50
let mH=50
//legs
let x1=185
let y1=410
let x2=50
let y2=600
let x3=150
let y3=600
let LegC='orange'
function preload(){
img=loadImage('assets/body.jpg')
angleMode(DEGREES)
}
function setup() {
createCanvas(400, 600);
translate(0,200)
for (let col=0;col<img.width;col++){
for (let row=0;row<img.height;row++){
let c=img.get(col,row);
stroke(color(c));
strokeWeight(10);
point(col,row)
}
}
}
function draw(){
stroke('cyan')
//background
fill(255,95,95)
rect(0,0,400,200)
push();
fill('cyan')
stroke(255,95,95)
rect(0,400,400,200)
pop();
//stem
push();
translate(120,140)
stroke('cyan');
curve(0, 26, 73, 24, 73, 61, 15, 65);
pop();
//flowers
flower(flowerX,flowerY,flowerC,fSize,petalL,petalS)
flower(70,70,'blue',110,40,30)
flower(330,70,'green',70,0,0)
//legs
legs('red',130,400,230,400, 160,600)
legs('green', 120,400,100,600,300,480)
legs(LegC,x1,y1,x2,y2,x3,y3)
legs('green',190,400,150,600,180,600)
legs('yellow',190,420,170,600,210,600)
legs('red',190,400,210,600,250,400)
legs('blue',190,400,210,600,300,480)
//muscles
muscle(muscleX,muscleY,muscleC,mW,mH)
muscle(190,240,'blue',50,50)
muscle(135,300,'cyan',28,28)
muscle(180,300,'cyan',28,28)
muscle(135,330,'cyan',20,20)
muscle(175,330,'cyan',20,20)
muscle(130,360,'cyan',20,25)
muscle(170,360,'cyan',20,25)
}
function flower(flowerX,flowerY,flowerC,fSize,petalL,petalS){
push();
translate(flowerX,flowerY);
fill(flowerC)
circle(0,0,fSize)
fill(flowerC)
circle(0,0,20)
for(let i=0;i<petalNo; i++){
angle=60
rotate(angle)
noStroke()
fill('yellow')
circle(0,40,petalL)
fill(flowerC)
circle(0,40,petalS)
fill('orange')
circle(0,20,20)
}
pop();
}
function muscle(muscleX,muscleY,muscleC,mW,mH){
push();
translate(muscleX,muscleY)
stroke('orange')
fill(muscleC)
rect(0,0,mW,mH)
pop();
}
function legs(LegC,x1,y1,x2,y2,x3,y3){
stroke(255,95,95)
strokeWeight(6.5)
fill(LegC)
triangle(x1,y1,x2,y2,x3,y3)
}