Processing(一) 简单的猫

float angle = 0;
void setup() {
  size(600, 600);
  background(255);
  //translate coordinates
  pushMatrix();
  float centreX = width/2;
  float centreY = height/2;
  translate(centreX, centreY);
  head(400);
}

void head(float a) {
  //unit a
  float headlength = a;
  float headheight = 0.85*a;
  //ears
  //reference point
  float earpoint_1X = 0.1*a;
  float earpoint_1Y = 0.3*a;
  float eartipX = 0.5*a;
  float eartipY = 0.7*a;
  float earpoint_2X = 0.25*a;
  float earpoint_2Y = 0.3*a;
  //reference point for outer ear
  float earouter_X = 0.4*a;
  float earouter_Y = 0.1*a;
  stroke(0);
  strokeWeight(2);
  fill(180,153,154);
  //ear_triangle
  beginShape();
  vertex(-earpoint_1X, -earpoint_1Y);
  vertex(-eartipX, -eartipY);
  vertex(-earpoint_2X, -earpoint_2Y);
  endShape(CLOSE);
  beginShape();
  vertex(earpoint_1X, -earpoint_1Y);
  vertex(eartipX, -eartipY);
  vertex(earpoint_2X, -earpoint_2Y);
  endShape(CLOSE);
  //ear_outer
  stroke(0);
  strokeWeight(2);
  noFill();
  line(-eartipX, -eartipY, -earouter_X, -earouter_Y);
  line(eartipX, -eartipY, earouter_X, -earouter_Y);
  
  //outer contour
  stroke(0);
  strokeWeight(2);
  fill(180,153,154);
  ellipse(0, 0, headlength, headheight);
  //lower face
  stroke(255);
  strokeWeight(0);
  fill(255);
  arc(0,0,headlength, headheight, 0,PI);
  //Contour of upper face
  strokeWeight(0);
  beginShape();
  vertex(-0.5*headlength, 0);
  bezierVertex(-0.25*headlength, 0, -0.25*headlength, -0.2*headheight, 0, -0.4*headheight);
  bezierVertex(0.25*headlength, -0.2*headheight, 0.25*headlength, 0, 0.5*headlength, 0);
  endShape(CLOSE);
  
  //eyes
  stroke(0);
  strokeWeight(2);
  fill(255);
  ellipse(-0.25*a,-0.05*a,0.35*a,0.35*a); //left eye
  ellipse(0.25*a,-0.05*a,0.35*a,0.35*a); //right eye
  fill(0);
  ellipse(-0.23*a,-0.04*a,0.2*a,0.2*a); //left eyeball
  ellipse(0.23*a,-0.04*a,0.2*a,0.2*a); //right eyeball
  
  //nose
  stroke(0);
  strokeWeight(2);
  fill(0);
  arc(0, 0.11*a, 0.08*a, 0.08*a, radians(225), radians(315));
  
  //mouth
  stroke(0);
  strokeWeight(3);
  noFill();
  beginShape();
  curveVertex(-0.25*a, 0.2*a);
  curveVertex(-0.12*a, 0.28*a);
  curveVertex(0, 0.2*a);
  curveVertex(0.12*a, 0.28*a);
  curveVertex(0.25*a, 0.2*a);
  endShape();
  
  // Whiskers
  stroke(180,153,154);
  strokeWeight(3);
  float x = 0.23*a;
  float y = 0.18*a;
  float whiskerlength = 0.35*a;
  line(-x,y,-x-whiskerlength,y-0.1*a);
  line(x,y,x+whiskerlength,y-0.1*a);
  line(-x,y+0.02*a,-x-whiskerlength,y+0.02*a);
  line(x,y+0.02*a,x+whiskerlength,y+0.02*a);
  line(-x,y+0.04*a,-x-whiskerlength,y+0.14*a);
  line(x,y+0.04*a,x+whiskerlength,y+0.14*a);
}

/*
void draw() {
  background(255); 
  translate(width/2, height/2); 
  rotate(angle); 
  head(400);
  angle += 0.01;
}
*/

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值