I've drawn a stick figure in p5.js and I'm trying to make it wave. Essentially I have to rotate the line making up its arm around the origin (coord (40,290)) partially.
I want it to bounce between the red line and blue line given in the code below in order to make it look like it's waving. I'm not really sure how to do this though. I've been trying to use the rotate() function but haven't found much success.
Any help would be much appreciated.
function setup() {
createCanvas(400, 400);
background(220);
}
/*
MY SKETCH OVERVIEW:
Person 1 is waving using animation
*/
function draw() {
//person1
stroke('black');
line(20, 395, 40, 355); //left leg
line(40, 355, 60, 395); //right leg
line(40, 355, 40, 250); //body
line(40, 290, 20, 320); //left arm
ellipse(40, 220, 60); //head
//person1 waving (animation)
stroke('red');
line(40, 290, 60, 250); //p1 right arm
stroke('blue');
line(40, 290, 80, 285);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.js"></script>