Processing学习笔记---基本结构

Basics of programming

1. Coordinates



2. Provide a command (which we will refer to as a “ function ” ) for the machine to follow entitled “ line. ” In addition, we specify some arguments for how that line should be drawn, from point A (0,1) to point B (4,5). 



3. Color and transparency




4. Zoog


Coding in Processing


1. Basic syntax rules. Th ere are three kinds of statements we can write: 

•     Function calls 函数调用


quad(38, 31, 86, 20, 69, 63, 30, 76);


noFill();
stroke(255, 102, 0);
curve(5, 26, 5, 26, 73, 24, 73, 61);
stroke(0); 
curve(5, 26, 73, 24, 73, 61, 15, 65); 
stroke(255, 102, 0);
curve(73, 24, 73, 61, 15, 65, 15, 65);


•    Assignment operations 赋值操作

Varaible declaration and initialization: Variables can hold primitive values or references to objects and arrays . Variables are declared by first stating the type, followed by the name. A type is the kind of data stored in that variable



•    Control structure 控制结构


The flow of a processing program (two “ blocks of code ”   setup( ) and  draw( ) -----A block of code is any code enclosed within curly brackets.)

Blocks1: setup(): Initialize conditions; Just as a game begins with a set of initial conditions: you name your character, you start with a score of zero, and you start on level one.

 After these conditions are initialized, you begin to play the game. 

Blocks2draw() and mouse events: At every instant, the computer checks what you are doing with the mouse, calculates all the appropriate behaviors for the game characters, and updates the screen to render all the game graphics. Th is cycle of calculating and drawing happens over and over again, ideally 30 or more times per second for a smooth animation. 

Note: If nothing in the draw() function varies each, the program will still run over time redrawing the window, but it looks static to us !!!


     

The speed at which the mouse is moving is : 
• abs(  mouseX - pmouseX ) 


  Blocks3:  Mouse Events : mousePressed, keyPressed

frameRate( ) , which requires an integer between 1 and 60, enforces the speed at which Processing will cycle through  draw( ).frameRate (30) , 
for example, means 30 frames per second, a traditional speed for computer animation.


This concept is crucial to our ability to move beyond static designs with Processing . 
Step 1. Set starting conditions for the program one time. 
Step 2. Do something over and over and over and over (and over … ) again until the program quits. 


Consider how you might go about running a race. 
Step 1. Put on your sneakers and stretch. Just do this once, OK? 
Step 2. Put your right foot forward, then your left foot. Repeat this over and over as fast as you can. 
Step 3.After 26 miles, quit.  



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值