|
Author |
Topic: making a stroke (Read 775 times) |
|
icioula
|
making a stroke
« on: Oct 29th, 2003, 1:51am » |
|
Hi all! Could anyone give me a clue on how to generate a smooth continuous stroke with a mouse or tablet device. I looked at Amit s pressure sensitive WinTab device and got very excited. I have been then trying to create continuous stroke but did not manage. Could anyone put me on a track? I have tried making one with a series of ellipses but when the movement was too fast it would make gaps between the iterations. Apparently using: beginShape(QUADS); could do the job of a continuous line and various thickness but I can not work out what parameters use. I have as well tried something like: strokeWeight(t.pressure/100); line(pmouseX,pmouseY,mouseX,mouseY); But the result is pretty awful. So, if anyone got any type of answer I would be very grateful. Thanks.
|
|
|
|
mflux
|
Re: making a stroke
« Reply #1 on: Oct 29th, 2003, 9:59am » |
|
Hi. Without getting too complicated.. there is a method that records the mouse and draws a curve in-between them. It's very much like vector graphics, it uses processing's curves to achieve this. Currently it just draws a continuous line... int[] mx; //records mouseX locations int[] my; //records mouseY locations int history=100; //how many states the mouse is recorded int drawCounter=0; //counts delays for the... int drawDelay=4; //delay that must pass before the mouse is recorded again //the higher the number the smoother the curves but less responsive it is void setup() { size(500,500); mx=new int[history]; my=new int[history]; stroke(0); } void loop() { background(255); if(mx[history-1]!=0) { beginShape(LINE_STRIP); for(int i=0;i<history;i++) { if(mx[i]!=0) //makes it not draw the first coordinate curveVertex(mx[i],my[i]); } endShape(); } } void mouseDragged() { if(drawCounter<drawDelay) drawCounter++; else //if enough delay has passed { for(int i=1;i<history;i++) //shift the entire list back { mx[i-1]=mx[i]; my[i-1]=my[i]; } mx[history-1]=mouseX; //and get new coordinates my[history-1]=mouseY; drawCounter=0; } } That is one solution. Another solution would use something I have done with the autonomouse networks drawing project but less extreme. It involves having an object that's constantly attracted by the mouse, but the mouse's force repels it. Depending on how you use the settings, you can draw really fine curves with such a drawing tool. See the code and the drawing tool in action: http://classes.design.ucla.edu/Fall03/157A/cursos/00/index_visor.php?id= 8&ejercicio_id=6&persona_id=20 Good luck!
|
|
|
|
mflux
|
Re: making a stroke
« Reply #3 on: Oct 29th, 2003, 11:59am » |
|
Ah.. that's a nice example
|
|
|
|
icioula
|
Re: making a stroke
« Reply #4 on: Oct 29th, 2003, 3:33pm » |
|
Thanks so much to you both! Mikkel, this was indeed what I was looking for Thanks for your spot on example. Micheal, thanks for your help. Your "network" drawing tool is lovely. What about adding colors to the path and nodes? It could create wonderful visual worlds! Oli
|
|
|
|
|