Processing 的一些基础知识

驼峰命名camelCasing 

–小写开头

–易读

Ø变量存储的类别。取值的范围。
Øint:: 非负自然数.
–InProcessing, 范围  [ -2147483648 , 2147483647 ]
–操作符operators: +, -, *, DIV, MOD
Ø浮点数float
–InProcessing, 范围[ -3.40282347E+38 , 3.40282347E+38 ]
–操作符: +, -, *, /, square root, ... 
Øboolean:: 两个值:true and false
–操作符: AND, OR, NOT, ...

Ø只读,不能赋值
Ø   mouseX/ mouseY  :: 当前鼠标值
Ø width / height :: 当前窗口的长宽
Ø   frameCount:: 当前帧的数量,从程序开始.

Ø应该把大段代码编程小段的函数,从而易于理解
Ø全局变量尽量少用

custom shapes 自定义形状
Øvertex() 
Ø放在beginShape()  和endShape() 中间

voidsetup() {

  size(400, 400);

  smooth();

  noStroke();

}

voiddraw() {

  background(0);

  // draw a star at the current mouse position

  fill(216, 61, 4);

  drawStar(mouseX, mouseY, 100);

}

void drawStar(intxPos,intyPos,intstarSize){

  beginShape();

  vertex(xPos, yPos-starSize/2);

  vertex(xPos-starSize/3, yPos+starSize/2);

  vertex(xPos+starSize/2, yPos-starSize/8);

  vertex(xPos-starSize/2, yPos-starSize/8);

  vertex(xPos+starSize/3, yPos+starSize/2);

  vertex(xPos, yPos-starSize/2);

  endShape();




Ø常用函数
round()
abs()
ceil()
floor()
random()
sqrt()


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值