We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a brush and I want it to move softly. The problem is that if I use delay function, the brush strokes is too dotty, and if I use "easing", all my strokes are connecting, so I get one big line instead of separated strokes. Is there another way to make soft brush movement?
Answers
here is an example where the longer you hold the mouse in one spot, the more pixels will appear
did you mean that?
can you post your code so that we know what you mean ?
if (mousePressed == true) { float targetX = mouseX; float dx = targetX - x; x += dx * easing;
float targetY = mouseY; float dy = targetY - y; y += dy * easing;
ellipse(x, y, brushsize, brushsize); } // My code is something like this. I use "easing" from standart example, this works fine for moving objects, but when I tried to use it with drawing brush, it draws me trajectories everywhere, connecting my strokes to one line.
and another question - how to post a code like you did it? in separate window with line numbers?
oh, I found an english word to describe what I want to do - the word is "lag". the brush have to draw with a little lag, that gives a posiibility to draw a smooth lines. hope that makes sense.
how to format code
you can highlight your code (select it) and hit ctrl-o
empty line before and after it
here is another code, where the dots are connected with a line
maybe you do not understand me correctly, I want to draw smooth-curved lines without connection of my brush strokes, but the problem is that standart easing connects my strokes, and I'm asking is there another way to draw smooth-curved lines without using easing.
here is an example - the lines are smooth-curved (this is good), but all the strokes are connected (this is not good, I want every stroke be separate).
do you mean general or the places where the color changes?
I can't help you with that...
different colors is the different strokes. I draw them in different places of canvas, but there is always an unwanted connection from one stroke to the next.
I see
post your code
I'll fix it
float x; // easing float y; float easing = 0.1; int r1; int g1; int b1;
void setup()
{ size(800,800); background(0); frameRate (100); }
void draw()
{ if (mousePressed == true)
{ float targetX = mouseX; // easing float dx = targetX - x; x += dx * easing;
}
void mouseReleased() { r1 = int(random(100, 255)); g1 = int(random(100, 255)); b1 = int(random(100, 255)); }
still dont understand how to post code correctly, the code below is one piece of code, dont know why site separates it : (
wow! working! thank you : ) but the difference is just in "void mousePressed" ?
https://forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
thanks, GoToLoop
yes, just in the function mousePressed() - it now sets x and y to the mouse position so that x,y don't interfere with our easing formula anymore
cool, thanks again!
this works because the function
mousePressed()
gets only called once in the moment you press the mouse button initially, whereas the variablemousePressed
(indraw()
line 17) is true throughoutso with the function
mousePressed()
we set the next line up (preparing it) whereas in draw we draw the line through the entire timeunderstood