xxxxxxxxxx
189
// let angle = 0;
// let r = 0;
let x = 0,
y = 0;
let a, b;
function setup() {
createCanvas(600, 600);
angleMode(DEGREES);
// c = random(-0.5, 0.5);
}
function draw() {
background(130, 30, 7, 75);
strokeCap(ROUND)
if (mouseX < width / 2) {
a = map(mouseX, 0, width / 2, 0.2, 1, true);
} else {
a = map(mouseX, width / 2, width, 1, 0.2, true);
}
for (let i = 0; i < 360; i += 30) {
push();
if (mouseY < height / 2) {
b = map(mouseY, 0, height / 2, 0, 90);
rotation()
} else {
b = map(mouseY, height / 2, height, 90, 180);
rotation()
}
translate(width / 2, height / 2);
rotate(i);
scale(a);
warli(0, 200);
pop();
}
for (let i = 0; i < 360; i += 20) {
push();
if (mouseY < height / 2) {
b = map(mouseY, 0, height / 2, 0, -90);
rotation()
} else {
b = map(mouseY, height / 2, height, -90, -180);
rotation()
}
translate(width / 2, height / 2);
rotate(i);
scale(a);
warli(0, 500);
pop();
}
for (let i = 0; i < 360; i += 10) {
push();
if (mouseY < height / 2) {
b = map(mouseY, 0, height / 2, 0, 90);
rotation()
} else {
b = map(mouseY, height / 2, height, 90, 180);
rotation()
}
translate(width / 2, height / 2);
rotate(i);
scale(a);
warli(0, 800);
pop();
}
for (let i = 0; i < 360; i += 8) {
push();
if (mouseY < height / 2) {
b = map(mouseY, 0, height / 2, 0, -90);
rotation()
} else {
b = map(mouseY, height / 2, height, -90, -180);
rotation()
}
translate(width / 2, height / 2);
rotate(i);
scale(a);
warli(0, 1100);
pop();
}
for (let i = 0; i < 360; i += 5) {
push();
if (mouseY < height / 2) {
b = map(mouseY, 0, height / 2, 0, 90);
rotation()
} else {
b = map(mouseY, height / 2, height, 90, 180);
rotation()
}
translate(width / 2, height / 2);
rotate(i);
scale(a);
warli(0, 1400);
pop();
}
push()
translate(width/2, height/2)
scale(a)
tree()
pop()
// warli(100,100)
}
function warli(p, q) {
//body
push();
noStroke();
ellipse(p, q, 50, 50);
triangle(p, q + 100, p - 50, q + 30, p + 50, q + 30);
triangle(p, q + 90, p - 50, q + 170, p + 50, q + 170);
pop();
stroke(255);
strokeWeight(2);
//hands
line(p - 50, q + 30, p - 75, q + 80);
line(p - 75, q + 80, p - 120, q + 100);
line(p + 50, q + 30, p + 75, q + 80);
line(p + 75, q + 80, p + 120, q + 100);
// legs
line(p - 30, q + 170, p - 10, q + 200);
line(p - 10, q + 200, p - 30, q + 230);
line(p + 30, q + 170, p + 50, q + 200);
line(p + 50, q + 200, p + 30, q + 230);
// hair
push()
noFill()
beginShape()
vertex(p+10, q-15)
bezierVertex(p+25, q-40, p+25, q, p+35, q-5)
endShape()
beginShape()
vertex(p+10, q-15)
bezierVertex(p+30, q-50, p+35, q+5, p+45, q-5)
endShape()
pop()
// stick
push()
strokeWeight(6)
line(p-80, q+40, p-100, q+200)
pop()
}
function rotation(){
translate(width / 2, height / 2);
rotate(b);
translate(-width / 2, -height / 2);
}
function tree(){
push()
translate(0,10)
push()
stroke(255)
strokeWeight(6)
line(0,-100, 0, 100)
line(0, -30, 75, -80)
line(0, 40, 75, -10)
line(0, -20, -75, -70)
line(0, 50, -75, 0)
pop()
push()
fill(255,75)
stroke(255)
ellipse(0,-100,50,50)
pop()
push()
fill(255,75)
stroke(255)
rotate(35)
ellipse(-30, 40, 120, 35)
ellipse(-70, -15, 120, 35)
pop()
push()
fill(255,75)
stroke(255)
rotate(-35)
ellipse(30, 35, 120, 35)
ellipse(70, -20, 120, 35)
pop()
pop()
}