We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › how to draw a dotted line
Page Index Toggle Pages: 1
how to draw a dotted line? (Read 2265 times)
how to draw a dotted line?
Aug 20th, 2008, 8:02pm
 
hi, i'm pretty new in processing. want to draw a dotted line. is there something like linestyle?
thanks
s.
Re: how to draw a dotted line?
Reply #1 - Aug 20th, 2008, 8:24pm
 
guess you have to draw it like that :

for(int i = 10; i<width; i+=10){
ellipse (i,height/2,2,2);  
}

Re: how to draw a dotted line?
Reply #2 - Aug 20th, 2008, 8:33pm
 
but i guess depends on what you want to draw...

this is another example, but maybe someone know some other helpfull tipps...


void setup(){
 size(400,400);
 smooth();
 noStroke();
 }
 
 void draw(){
   background(255);
   float rad = 100;
   for(int a = 0; a<360; a+=5){
   float xoff = cos(radians(a))*rad;
       float yoff = sin(radians(a))*rad;
       fill(0);
       ellipse(width/2+xoff,height/2+yoff, 2, 2);
   }    
 }
Re: how to draw a dotted line?
Reply #3 - Aug 20th, 2008, 10:05pm
 
Re: how to draw a dotted line?
Reply #4 - Aug 20th, 2008, 10:18pm
 
true, thats another great way and makes it alot easier... another example in the reference : http://processing.org/reference/lerp_.html

but i guess its not possible to use it to follow bezier() curves right? or is there an easy way? just asking myself
Re: how to draw a dotted line?
Reply #5 - Aug 21st, 2008, 2:41am
 
if you use alot of dotted lines maybe something like this is usefull for you... just call dottedLine() like you would call line()


void setup(){
 size(400,400);
 smooth();
}

void draw(){
 fill(255);
 dottedLine(0,0,300,300,40);
 dottedLine(50,30,340,200,60);
 fill(255,0,0);
 dottedLine(100,250,300,200,20);

}



void dottedLine(float x1, float y1, float x2, float y2, float steps){
 for(int i=0; i<=steps; i++) {
   float x = lerp(x1, x2, i/steps);
   float y = lerp(y1, y2, i/steps);
   noStroke();
   ellipse(x, y,2,2);
 }
}
Re: how to draw a dotted line?
Reply #6 - Sep 1st, 2008, 3:48pm
 
thank you very much! ...so many good information.
...sorry for my late reply, had 10 days off.
Page Index Toggle Pages: 1