xxxxxxxxxx
760
let headWidth = 120;
function setup() {
createCanvas(400, 600);
}
function draw() {
background(133, 87, 111);
angleMode(DEGREES);
// drawing the pattern background
lines()
// green b/g lines
bgCircles()
// drawing all diamonds on the background
diamond(50,height/4,height*3/4)
diamond(100,0,height)
diamond(150,height/4,height*3/4)
diamond(200,0,height)
diamond(250,height/4,height*3/4)
diamond(300,0,height)
diamond(350,height/4,height*3/4)
diamond(50,height*3/4,height/4)
diamond(100,height,0)
diamond(150,height*3/4,height/4)
diamond(200,height,0)
diamond(250,height*3/4,height/4)
diamond(300,height,0)
diamond(350,height*3/4,height/4)
diamond(100,height/2-10,height/2+10)
diamond(200,height/2-10,height/2+10)
diamond(300,height/2-10,height/2+10)
// drawing lotus motifs on b/g
pattern(100,150);
pattern(300,460);
// making the hair at the back move from side to side
push();
if (second() % 2 == 0) {
push();
translate(3, 0);
// hair base
push();
fill(0);
noStroke();
circle(width / 2, height / 4 - 20, 150);
rect(width / 2, height / 4 + 60, 100, 200, 10);
pop();
} else {
push();
translate(-3, 0);
// hair base
push();
fill(0);
noStroke();
circle(width / 2, height / 4 - 20, 150);
rect(width / 2, height / 4 + 60, 100, 200, 10);
pop();
}
pop();
// palm and fingers
hand(
width / 2,
height / 2 + 60,
250,
250,
300,
-10,
width / 2 + 124,
height / 2 + 50,
20,
20,
2
);
hand(
width / 2,
height / 2 + 60,
250,
250,
190,
270,
width / 2 - 124,
height / 2 + 50,
20,
20,
2
);
//calling fingers
push();
fill(213, 166, 124);
fingers(width / 2 - 110, height / 2 + 45, 15, 7, 1);
fingers(width / 2 - 131, height / 2 + 62, 5, 10, 1);
fingers(width / 2 - 124, height / 2 + 63, 5, 12, 1);
fingers(width / 2 - 117, height / 2 + 63, 5, 12, 1);
fingers(width / 2 + 110, height / 2 + 45, 15, 7, 1);
fingers(width / 2 + 131, height / 2 + 62, 5, 10, 1);
fingers(width / 2 + 124, height / 2 + 63, 5, 12, 1);
fingers(width / 2 + 117, height / 2 + 63, 5, 12, 1);
pop();
// bangles
push();
noFill();
stroke(240, 193, 7);
strokeWeight(3);
line(width / 2 - 115, height / 2 + 33, width / 2 - 130, height / 2 + 30);
line(width / 2 + 115, height / 2 + 33, width / 2 + 130, height / 2 + 30);
stroke(168, 17, 42);
line(width / 2 - 115, height / 2 + 37, width / 2 - 130, height / 2 + 35);
line(width / 2 + 115, height / 2 + 37, width / 2 + 130, height / 2 + 35);
line(width / 2 - 113, height / 2 + 30, width / 2 - 128, height / 2 + 27);
line(width / 2 + 113, height / 2 + 30, width / 2 + 128, height / 2 + 27);
pop();
// calling respective body part functions - bottom, body, neck
bottom();
body();
// body();
neck();
// calling all sleeve ellipses
push();
sleeve(-60, 80, 20, 55, 60);
sleeve(60, -80, 20, 55, 60);
sleeve(90, -30, 50, 45, 45);
sleeve(-90, 30, 50, 45, 45);
sleeve(-70, 100, 45, 35, 35);
sleeve(70, -100, 45, 35, 35);
// drawing collar on either side of body by calling the function
collar(13, 30, 0, 40, 25, -20, 15, -25, 27, -30, 35, 15);
collar(-13, 30, 0, 40, -25, -20, -15, -25, -27, -30, -35, 15);
// curve of tail
push();
noFill();
stroke(171, 119, 156);
strokeWeight(20);
arc(width * 0.39, (height * 3) / 4 + 20, 90, 160, 0, 170);
// stroke(0)
arc(width * 0.39 + 10, (height * 3) / 4 + 25, 95, 160, 0, 100);
arc(width * 0.45, (height * 3) / 4 + 20, 70, 160, 0, 95);
arc(width * 0.4, (height * 3) / 4 + 20, 50, 160, 0, 90);
pop();
tail(-100, 160, 50, 50, 100, 0, 100, 100, -10);
tail(-80, 200, 50, 50, 0, 100, 100, 100, 10);
// gold chains
push();
stroke(240, 193, 7);
strokeWeight(2);
noFill();
arc(width / 2, height / 3 + 30, 25, 15, 0, 180, OPEN);
arc(width / 2, height / 3 + 30, 25, 35, 0, 180, OPEN);
arc(width / 2, height / 3 + 30, 25, 55, 0, 180, OPEN);
// gold tail lines
line(width / 2 - 37, height / 2 + 75, width / 2 + 37, height / 2 + 75);
line(width / 2 - 34, height / 2 + 105, width / 2 + 34, height / 2 + 106);
line(width / 2 - 31, height / 2 + 135, width / 2 + 31, height / 2 + 135);
line(width / 2 - 28, height / 2 + 163, width / 2 + 28, height / 2 + 170);
line(width / 2 - 26, height / 2 + 190, width / 2 + 24, height / 2 + 207);
line(width / 2 - 31, height / 2 + 212, width / 2 + 10, height / 2 + 240);
line(width / 2 - 38, height / 2 + 236, width / 2 - 19, height / 2 + 263);
line(width / 2 - 52, height / 2 + 237, width / 2 - 58, height / 2 + 258);
line(width / 2 - 64, height / 2 + 225, width / 2 - 80, height / 2 + 240);
line(width / 2 - 71, height / 2 + 212, width / 2 - 92, height / 2 + 217);
pop();
// pearl pendants on gold chain
push();
fill(255);
circle(width / 2, height / 3 + 38, 5);
circle(width / 2, height / 3 + 48, 5);
circle(width / 2, height / 3 + 58, 5);
pop();
pop();
// making the face and all features in front move from side to side
push();
if (second() % 2 == 0) {
push();
translate(5, 0);
push();
fill(0);
noStroke();
circle(width / 2, height / 4 - 20, 150);
pop();
features();
chin();
pop();
} else {
push();
translate(-5, 0);
push();
fill(0);
noStroke();
circle(width / 2, height / 4 - 20, 150);
pop();
features();
chin();
pop();
}
pop();
// fill(0);
// text("x:" + mouseX + " y:" + mouseY, mouseX, mouseY);
}
function head() {
// face base
push();
rectMode(CENTER);
fill(213, 166, 124);
stroke(213, 166, 124);
//rect(width / 2, height / 4, 100, 100,10);
push();
// head quad base
translate(0, -15);
quad(
width / 2 + headWidth / 2 - headWidth / 10,
height / 4 - headWidth / 3 - 10,
width / 2 - headWidth / 2 + headWidth / 10,
height / 4 - headWidth / 3 - 10,
width / 2 - headWidth / 2,
height / 4 + headWidth / 5,
width / 2 + headWidth / 2,
height / 4 + headWidth / 5
);
pop();
// bottom of face
ellipse(width / 2, height / 4, headWidth, headWidth - 10);
// hair up
push();
fill(0);
noStroke();
arc(width / 2 - 35, height / 4 - 70, 70, 50, -55, 155, CHORD);
arc(width / 2 + 35, height / 4 - 70, 70, 50, 25, 235, CHORD);
pop();
// ear left
push();
// translate(width/2,height/2)
// rotate(10)
ellipse(
width / 2 - headWidth / 2,
height / 4 - headWidth / 10,
headWidth / 6,
headWidth / 4
);
pop();
// ear right
push();
ellipse(
width / 2 + headWidth / 2,
height / 4 - headWidth / 10,
headWidth / 6,
headWidth / 4
);
pop();
}
// eye
function eye(x, y, a, b, r, start, end) {
// x=width/2
// y=height / 4
// a=headWidth / 4
// b=headWidth / 10
// trying a triangular eye
// push();
// fill(255);
// noStroke();
// //triangle(193,140,180,135,185,153)
// pop();
// white base of eye
push();
translate(x - a, y - b);
rotate(r);
fill(255);
noStroke();
rectMode(CENTER);
rect(0, 8, headWidth / 3.5, headWidth / 5, 10);
pop();
push();
// pupil movement
if (second() % 2 == 0) {
translate(6, 0);
push();
fill(0);
noStroke();
arc(x - a, y - b, headWidth / 5, headWidth / 4, start, end, CHORD);
pop()
} else{
push();
translate(-6, 0);
push();
fill(0);
noStroke();
arc(x - a, y - b, headWidth / 5, headWidth / 4, start, end, CHORD);
pop()
}
pop();
push()
if (second() % 2 == 0) {
translate(12, 0);
push()
fill(255)
noStroke()
circle(x-a,y-7,5)
pop()
} else {
translate(-12, 0);
push()
fill(255)
noStroke()
circle(x-a,y-7,5)
pop()
}
pop()
pop();
// eyelash
push();
translate(x - a, y - b);
rotate(r);
fill(0);
stroke(0);
strokeWeight(2);
arc(0, 0, 40, 15, 180, 360, CHORD);
pop();
push();
translate(x - a, y - b);
rotate(r);
fill(0);
stroke(0);
arc(-a / 1.25, -2, 10, 5, 0, 180, OPEN);
pop();
// eyebrows
push();
stroke(0);
strokeWeight(2);
noFill();
arc(width / 2 - 25, height / 4 - 20, 40, 35, 230, 0);
arc(width / 2 + 25, height / 4 - 20, 40, 35, 180, -60);
pop();
// lips
fill(168, 17, 42);
ellipse(width / 2, height / 4 + 35, 20, 15);
push(0);
stroke(0);
noFill();
arc(width / 2, height / 4 + 32, 25, 10, 0, 180);
pop();
// nose
push();
stroke(0);
noFill();
line(width / 2 - 5, height / 4 - 20, width / 2 - 5, height / 4 + 10);
//line(width/2+5,height/4-20,width/2+5,height/4+5)
arc(width / 2 - 5, height / 4 + 15, 10, 7, 90, 280, OPEN);
// arc(width/2+5,height/4+15,10,10,270,90,OPEN)
pop();
push();
stroke(240, 193, 7);
noFill();
// nose ring
stroke(240, 193, 7);
strokeWeight(2);
arc(width / 2 + 10, height / 3 - 25, 20, 20, 180, 170, OPEN);
push();
fill(255);
noStroke();
circle(width / 2 + 20, height / 3 - 15, 5);
pop();
// bindi
noStroke();
fill(168, 17, 42);
triangle(
width / 2 - 4,
height / 4 - 30,
width / 2 + 4,
height / 4 - 30,
width / 2,
height / 4 - 45
);
circle(width / 2, height / 4 - 30, 8);
circle(width / 2, height / 4 - 22, 4);
}
// creating a function for the earrings
function earring(leftEarX, rightEarX, earY) {
push();
noFill();
stroke(240, 193, 7);
strokeWeight(2);
line(leftEarX, earY, leftEarX, earY + 10);
line(rightEarX, earY, rightEarX, earY + 10);
pop();
push();
fill(240, 193, 7);
arc(leftEarX, earY + 25, 30, 30, 180, 360, CHORD);
arc(rightEarX, earY + 25, 30, 30, 180, 360, CHORD);
fill(255);
circle(leftEarX, earY + 30, 5);
circle(leftEarX - 10, earY + 30, 5);
circle(leftEarX + 10, earY + 30, 5);
circle(rightEarX, earY + 30, 5);
circle(rightEarX - 10, earY + 30, 5);
circle(rightEarX + 10, earY + 30, 5);
pop();
// forehead
push();
stroke(240, 193, 7);
strokeWeight(2);
line(width / 2, height / 4 - 75, width / 2, height / 4 - 95);
fill(240, 193, 7);
noStroke();
circle(width / 2, height / 4 - 75, 20);
fill(255);
circle(width / 2, height / 4 - 55, 5);
pop();
}
// function for neck
function neck() {
fill(181, 132, 89);
noStroke();
quad(
width / 2 - 10,
height / 3,
width / 2 + 10,
height / 3,
width / 2 + 13,
height / 3 + 30,
width / 2 - 13,
height / 3 + 30
);
}
// collar function will all vertices
function collar(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6) {
fill(146, 201, 201);
beginShape();
vertex(width / 2 + x1, height / 3 + y1);
vertex(width / 2 + x2, height / 2 + y2);
vertex(width / 2 + x3, height / 2 + y3);
vertex(width / 2 + x4, height / 2 + y4);
vertex(width / 2 + x5, height / 2 + y5);
vertex(width / 2 + x6, height / 3 + y6);
endShape();
push();
stroke(240, 193, 7);
strokeWeight(2);
beginShape(LINES);
vertex(width / 2 + x3, height / 2 + y3);
vertex(width / 2 + x4, height / 2 + y4);
vertex(width / 2 + x5, height / 2 + y5);
vertex(width / 2 + x6, height / 3 + y6);
endShape();
pop();
}
// body function
function body() {
push();
fill(190, 169, 199);
noStroke();
quad(
width / 2 - 32,
height / 3 + 30,
width / 2 + 32,
height / 3 + 30,
width / 2 + 40,
height / 2 + 40,
width / 2 - 40,
height / 2 + 40
);
pop();
// gold belt
push();
fill(240, 193, 7);
noStroke();
quad(
width / 2 + 45,
height / 2 + 40,
width / 2 - 45,
height / 2 + 40,
width / 2 - 45,
height / 2 + 47,
width / 2 + 45,
height / 2 + 47
);
pop();
// pearls for gold belt
push();
fill(255);
circle(width / 2, height / 2 + 53, 5);
circle(width / 2 + 10, height / 2 + 53, 5);
circle(width / 2 + 20, height / 2 + 53, 5);
circle(width / 2 + 30, height / 2 + 53, 5);
circle(width / 2 + 40, height / 2 + 53, 5);
circle(width / 2 - 10, height / 2 + 53, 5);
circle(width / 2 - 20, height / 2 + 53, 5);
circle(width / 2 - 30, height / 2 + 53, 5);
circle(width / 2 - 40, height / 2 + 53, 5);
pop();
fill(181, 132, 89);
ellipse(width / 2, height / 3 + 30, 25, 15);
}
function sleeve(angle, x, y, w, h) {
push();
fill(162, 161, 195);
noStroke();
translate(width / 2, height / 2);
rotate(angle);
ellipse(x, y, w, h);
pop();
}
function hand(x, y, w, h, start, stop, x1, y1, w1, h1, r1) {
push();
stroke(213, 166, 124);
strokeWeight(15);
noFill();
arc(x, y, w, h, start, stop);
rectMode(CENTER);
pop();
push();
fill(213, 166, 124);
rect(x1, y1, w1, h1, r1);
pop();
}
function fingers(x, y, w, h, r) {
rect(x, y, w, h, r);
}
function bottom() {
push();
fill(171, 119, 156);
noStroke();
quad(
width / 2 + 40,
height / 2 + 40,
width / 2 - 40,
height / 2 + 40,
width / 2 - 25,
height / 2 + 180,
width / 2 + 25,
height / 2 + 180
);
pop();
}
function tail(x, y, w, h, r1, r2, r3, r4, angle) {
push();
// rectMode(CENTER)
translate(width / 2, height / 2);
rotate(angle);
fill(247, 141, 145);
// stroke(255)
rect(x - 2, y - 3, w + 3, h + 3, r1, r2, r3, r4);
fill(190, 169, 199);
noStroke()
rect(x, y, w, h, r1, r2, r3, r4);
pop();
}
function features() {
head();
eye(width / 2, height / 4, headWidth / 4, headWidth / 10, 10, 0, 205);
eye(width / 2, height / 4, -headWidth / 4, headWidth / 10, -10, -30, 180);
earring(width / 2 - 63, width / 2 + 63, height / 4);
}
function chin() {
fill(213, 166, 124);
ellipse(width / 2, height / 4 + 53, 20, 15);
}
function lines(){
push()
stroke(171, 119, 156)
strokeWeight(1.5)
line(50,0,50,height)
line(100,0,100,height)
line(150,0,150,height)
line(200,0,200,height)
line(250,0,250,height)
line(300,0,300,height)
line(350,0,350,height)
pop()
}
// background lotus
function pattern(x,y){
push()
rectMode(CENTER)
translate(x,y)
stroke(247, 141, 145)
strokeWeight(2)
fill(133, 87, 111)
rect(-15,0,70,60,0,50,50,50)
rect(15,0,70,60,50,0,50,50)
push()
rotate(70)
rect(5,-10,60,60,0,50,50,50)
pop()
push()
rotate(10)
rect(-10,0,60,60,0,50,50,50)
pop()
push()
rotate(45)
rect(0,0,60,60,0,50,30,50)
pop()
push()
stroke(247, 141, 145)
line(0,30,0,-30)
line(0,30,10,-20)
line(0,30,-10,-20)
line(0,30,20,-10)
line(0,30,-20,-10)
line(0,30,-22,5)
line(0,30,22,5)
pop()
// green stalk
push()
stroke(175, 209, 2)
strokeWeight(1.5)
line(0,30,0,height)
pop()
pop()
}
function diamond(x,h1,h2,b){
let y= map(mouseX,0,width,h1,h2)
push()
translate(x,y)
rotate(45)
fill(162, 161, 195)
noStroke()
square(0,0,34)
stroke(171, 119, 156)
strokeWeight(2)
fill(133, 87, 111)
square(0,0,30)
pop()
}
function circles(x,y){
push()
stroke(175, 209, 2)
noFill()
circle(x,y,5)
pop()
}
function bgCircles(){
circles(50,height/2)
circles(50,height/4+50)
circles(50,height/4-50)
circles(50,height*3/4+50)
circles(50,height*3/4-50)
circles(150,height/2)
circles(150,height/4+50)
circles(150,height/4-50)
circles(150,height*3/4+50)
circles(150,height*3/4-50)
circles(250,height/2)
circles(250,height/4+50)
circles(250,height/4-50)
circles(250,height*3/4+50)
circles(250,height*3/4-50)
circles(350,height/2)
circles(350,height/4+50)
circles(350,height/4-50)
circles(350,height*3/4+50)
circles(350,height*3/4-50)
circles(100,height/2+50)
circles(100,height/2-50)
circles(100,50)
circles(100,height-50)
circles(200,height/2+50)
circles(200,height/2-50)
circles(200,50)
circles(200,height-50)
circles(300,height/2+50)
circles(300,height/2-50)
circles(300,50)
circles(300,height-50)
}