Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
htschopp46405
htschopp46405's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Help With Recursion
[3 Replies]
20-Mar-2012 06:32 PM
Forum:
Programming Questions
Hi,
I am trying to recreate a star shape using recursion. I do not know what I am doing wrong. Can anyone please help?
This is what I have so far, and the program keeps coming up Unreachable Code.
float x;
float y;
int sz;
float angle;
void setup()
{
size(400,400);
smooth();
x=width/4;
y=width/4;
sz=width/8;
}
void draw()
{
background(255);
Star();
}
void Star()
{
fill(255,255,0);
noStroke();
beginShape();
vertex(x,y-sz/2);
vertex(x+sz/6,y-sz/6);
vertex(x+sz/2,y-sz/11);
vertex(x +sz/4,y+sz/8);
vertex(x+sz/3,y+sz/2);
vertex(x,y+sz/3);
vertex(x-sz/3,y+sz/2);
vertex(x-sz/4,y+sz/6);
vertex(x-sz/2,y-sz/9);
vertex(x-sz/6,y-sz/6);
endShape(CLOSE);
}
void star(float x, float y, float sz)
{
if(sz<6);
{
return;
}
star(x+sz, y+sz, sz*1/3);
star(x+sz,y,sz*1*3);
star(x+sz,y-sz,sz*1/3);
star(x,y-sz,sz*1/3);
star(x-sz,y-sz,sz*1/3);
star(x-sz,y,sz*1/3);
star(x-sz,y-sz,sz*1/3);
star(x-sz,y+sz,sz*1/3);
star(x,y+sz,sz*1/3);
}
«Prev
Next »
Moderate user : htschopp46405
Forum