var x = []
var y = []
var num = 10;
var f = [drawReat,drawPoint,drawLine,drawEllipse, drawBigOmega, drawLittleAlpha,
drawBigPi, drawLittlePi, drawBigSigma, drawLittleSigma];
var speedX = []
var speedY = []
function setup() {
createCanvas(500, 600);
for(var i=0;i<num;i++){
x[i] = random(0,width)
y[i] = random(0,height)
speedX[i] = random(0, 1)
speedY[i] = random(0, 1)
}
}
function draw() {
background(220);
for(var i=0;i<num;i++){
x[i] = x[i] + speedX[i];
y[i] = y[i] + speedY[i];
if(x[i] > width){
x[i] = x[i] - width
}
if(x[i] < 0){
x[i] = x[i] + width
}
if(y[i] > height){
y[i] = y[i] - height
}
if(y[i] < 0){
y[i] = y[i] + height
}
var drawWidth = random(30,71)
var drawHeight = random(45,71)
f[i](x[i], y[i], drawWidth, drawHeight);
}
}
function drawReat(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
rect(x, y, drawWidth, drawHeight);
}
function drawPoint(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
point(x, y);
}
function drawLine(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
line(x,y,x+drawWidth,y+drawHeight);
}
function drawEllipse(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
ellipse(x+drawWidth/2, y+drawHeight/2, drawWidth-2, drawHeight-2);
}
function drawBigOmega(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
arc(x+drawWidth/2,y+drawHeight/2,drawWidth,drawHeight,-(QUARTER_PI+PI),QUARTER_PI)
line(x,y+drawHeight,x+drawWidth*1/6,y+drawHeight*4/5)
line(x+drawWidth*5/6,y+drawHeight*4/5,x+drawWidth,y+drawHeight)
}
function drawLittleAlpha(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
ellipse(x+drawWidth/2, y+drawHeight/2, drawWidth-2-3, drawHeight-2);
line(x+drawWidth,y,x+drawWidth-6,y+drawHeight)
}
function drawBigPi(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
line(x,y,x+drawWidth,y);
line(x+drawWidth*1/5,y,x+drawWidth*1/5,y+drawHeight);
line(x+drawWidth*4/5,y,x+drawWidth*4/5,y+drawHeight);
}
function drawLittlePi(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
line(x,y,x+drawWidth,y);
line(x+drawWidth*2/5,y,x+drawWidth*2/5-5,y+drawHeight);
line(x+drawWidth*3/5,y,x+drawWidth*3/5-5,y+drawHeight);
line(x+drawWidth*3/5-5,y+drawHeight,x+drawWidth*4/5,y+drawHeight*3/5);
}
function drawBigSigma(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
line(x,y,x+drawWidth,y);
line(x,y,x+drawWidth*1/2,y+drawHeight/2);
line(x+drawWidth*1/2,y+drawHeight/2,x,y+drawHeight)
line(x,y+drawHeight,x+drawWidth,y+drawHeight);
}
function drawLittleSigma(x, y, drawWidth, drawHeight)
{
strokeWeight(3);
ellipse(x+drawWidth/2,y+drawHeight/2,drawWidth,drawHeight);
line(x+drawWidth/2,y,x+drawWidth,y);
}
homework3
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- website: http://iems5703.albertauyeung.com/assignment-3 A...
- 本次学习内容:U3L3 灰色练习册: Workbook - P38, Activity A. Look and c...
- Book 5, Unit 3, Lesson 3 In this unit, the students will ...
- 本次学习内容:U3L3 灰色练习册: Workbook - P38, Activity A. Look and w...