# 期末報告 --- ## 期中自畫像 https://openprocessing.org/sketch/1363638 ```javascript= function setup() { createCanvas(windowWidth, windowHeight); background(255); } var mode=1 function mousePressed(){ mode++ if(mode>3){ mode =1 } } var v=425 var t=425 var v_x=3 var v_y=3 var count=0 var x= 10 var y = 10 function draw() { background(190,250,130);//背景顏色 textSize(50)//字體大小 text("胡亞琁",150,150)//名字 fill(240,220,181) //膚色 circle(400, 425, 200)//頭 fill(255) line(400, 300, 250, 550) line(400, 295, 250, 550) line(400, 305, 250, 550) line(400, 310, 250, 550) line(400, 290, 250, 550) line(400, 315, 250, 550) line(400, 285, 250, 550) line(400, 320, 250, 550) line(400, 325, 250, 550) line(400, 330, 250, 550) line(400, 280, 250, 550) line(400, 275, 250, 550) line(400, 270, 250, 550) line(400, 265, 250, 550) line(400, 335, 250, 550) line(400, 260, 250, 550) line(400, 255, 250, 550) line(400, 250, 250, 550) line(400, 245, 250, 550) line(400, 240, 250, 550)//頭髮 strokeWeight(5)//五官 ellipse(400,380,50+mouseY/10);//眼睛跟著滑鼠改變大小 ellipse(470,380,20) strokeWeight(1) beginShape() vertex(370,450) vertex(460,480) vertex(500,460) endShape() fill(200,263,241) fill(200,263,241) if(mode==2){ background(255); fill(0) strokeWeight(6) stroke(0) ellipse(v,t,50,50); v =v+v_x t =t+v_y v_y =v_y+0.5 if(t>height){ v_y=-v_y*0.8 t=height//自由落體 } } } ``` --- ## 期末報告 https://openprocessing.org/sketch/1427745 ```javascript= let video; let poseNet; let pose; let skeleton; var rightEar,rightWrist function preload(){ rightEarImg= loadImage("wee.png") rightWristImg= loadImage("bh.png") } function setup() { createCanvas(640, 480); //createCanvas(windowWidth, windowHeight); video = createCapture(VIDEO); video.hide(); poseNet = ml5.poseNet(video, modelLoaded); //呼叫在ml5.js上的net函數,用此函數來判斷各位置,呼叫成功即執行function modelLoaded poseNet.on('pose', gotPoses); } function gotPoses(poses) { if (poses.length > 0) { pose = poses[0].pose; //把抓到的幾個點,都放置pose變數內 skeleton = poses[0].skeleton; //把相關於骨架的點都放到skeleton變數內 } } function modelLoaded() { //顯示pose model已經準備就緒 console.log('poseNet ready'); } function draw() { background(0); translate(video.width,0) //因為攝影機顯示的是反像的畫面,需要透過這兩條指令來做反轉 scale(-1,1) //因為攝影機顯示的是反像的畫面,需要透過這兩條指令來做反轉 image(video, 0, 0); //顯示你的畫面在螢幕上 if (pose) { let eyeR = pose.rightEye; //抓到右眼資訊,放到eyeR let eyeL = pose.leftEye; //抓到左眼資訊,放到eyeL let d = dist(eyeR.x, eyeR.y, eyeL.x, eyeL.y); //算出左右眼的距離,當作鼻子顯示圓的直徑 fill(255, 0, 0); push() translate(pose.nose.x, pose.nose.y-150,d) imageMode(CENTER); scale(0.5) //image(noseImg,0,0) fill(240,220,181) //膚色 circle(400, 425, 200)//頭 fill(255) line(400, 300, 250, 550) line(400, 295, 250, 550) line(400, 305, 250, 550) line(400, 310, 250, 550) line(400, 290, 250, 550) line(400, 315, 250, 550) line(400, 285, 250, 550) line(400, 320, 250, 550) line(400, 325, 250, 550) line(400, 330, 250, 550) line(400, 280, 250, 550) line(400, 275, 250, 550) line(400, 270, 250, 550) line(400, 265, 250, 550) line(400, 335, 250, 550) line(400, 260, 250, 550) line(400, 255, 250, 550) line(400, 250, 250, 550) line(400, 245, 250, 550) line(400, 240, 250, 550)//頭髮 strokeWeight(5)//五官 ellipse(400,380,50+mouseY/10);//眼睛跟著滑鼠改變大小 ellipse(470,380,20) strokeWeight(1) beginShape() vertex(370,450) vertex(460,480) vertex(500,460) endShape() fill(200,263,241) fill(200,263,241) pop() push() translate(pose.rightEar.x, pose.rightEar.y-110) imageMode(CENTER); scale(-1,1) scale(1) image(rightEarImg,0,0) pop() push() translate(pose.leftEar.x, pose.leftEar.y-110) imageMode(CENTER); scale(1) image(rightEarImg,0,0) pop() push() translate(pose.rightWrist.x, pose.rightWrist.y-50) imageMode(CENTER); scale(-1,1) scale(1) image(rightWristImg,0,0) pop() push() translate(pose.leftWrist.x, pose.leftWrist.y-50) imageMode(CENTER); scale(1) image(rightWristImg,0,0) pop() fill(255); } } ```