Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
mrblack2012
mrblack2012'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
honeycomb pattern
[3 Replies]
08-Jul-2012 10:54 AM
Forum:
Programming Questions
Hey I´ve written some code that should create a honeycomb pattern. It works, except the upper right corner where the pattern gets shifte a little bit. Can anybody tell me why it doesn´t work properly?
This is the code:
int sidelength = 40;
void draw_comb (int x,int y,int l)
{
beginShape();
vertex(x-0.5*l,y+cos(radians(30))*l);
vertex(x+0.5*l,y+cos(radians(30))*l);
vertex(x+l,y);
vertex(x+0.5*l,y-cos(radians(30))*l);
vertex(x-0.5*l,y-cos(radians(30))*l);
vertex(x-l,y);
vertex(x-0.5*l,y+cos(radians(30))*l);
endShape();
}
void honeycomb_background()
{
for(int y_start=height ; y_start >= -height; y_start -= 2*sidelength*sin(radians(60)))
{
for(int x=0,y=y_start;x<=width+sidelength; x+=3/2*sidelength+sidelength*sin(radians(30)), y+= sidelength/tan(radians(30))/2)
{
draw_comb(x,y,sidelength);
}
}
}
void setup()
{
size(800,800);
}
void draw()
{
noFill();
stroke(100);
honeycomb_background();
//draw_comb(200,200,20);
//ellipse(200,200,10,10);
}
«Prev
Next »
Moderate user : mrblack2012
Forum