Hello, some question from a beginner (drip effect)

Hi,
I want to do spray paint effect,but how to cancel the point of the drip effect? (just want only "line "drip)
sorry,I just the beginner.

thanks!!

my code:

final int maxIterations = 20;  //
float x=0;
float y=0;

void setup () {
  size (500, 700);
  background(255);
  stroke(0); // red
}
void draw () {

  if (mousePressed ) {
    brush () ;
    brushX();
  }
}
void brush () {
  int width1=40; //
  //
  float radx;   // Radius
  float rady;
  float angle1; // angle
  float x;      // result
  float y;
  //
  for (int i=0; i < maxIterations; i++) {
    radx=random(width1);
    rady=random(width1);
    angle1= random(600);
    //
    x=(radx*cos(radians(angle1)))+mouseX;
    y=(rady*sin(radians(angle1)))+mouseY;
    strokeWeight(3);
    point(x, y);
  }
}
void brushX () {
  int x=0;
  int y=0;
  for (int i=0; i < 2; i++) {
    x=mouseX;
    y=mouseY;
    strokeWeight(2);
  line(mouseX,mouseY,mouseX,mouseY++);
  }
}
1 Like

just like this!

spray-paint-vector-elements-isolated-260nw-1655127337

Ummm, could you try to rephrase your problem? I don’t understand what you’re trying to achieve… are you trying to create a spray paint effect from scratch? or are you using some library?

maybe you could find some help here on how to make your question more understandable.

please remember

  • to use ctrl-t in pocessing to get auto-format before posting
  • after you pasted your code: in the forum select your code with the mouse and hit ctrl-e (or in the small command bar the sign </>)
  • to use more empty lines, between functions for example

Hey, and welcome to the forum!

Warm regards,

Chrisir

Hello Chrisir,
thanks so much!

Hello KaliBrain,

thanks for your reply!
I want to make a spray paint effect,and partly completed.
It will dripping if I press the mouse for more than 3-5 seconds,but how to cancel the splashing effect for the dripping?

Thanks!!

my code:

final int maxIterations = 20;
float x=0;
float y=0;

void setup () {
  size (500, 700);
  background(255);
  stroke(0);
}
void draw () {

  if (mousePressed ) {
    brush () ;
    brushX();
  }
}
void brush () {
  int width1=40;

  float radx;
  float rady;
  float angle1;
  float x;
  float y;

  for (int i=0; i < maxIterations; i++) {
    radx=random(width1);
    rady=random(width1);
    angle1= random(600);

    x=(radx*cos(radians(angle1)))+mouseX;
    y=(rady*sin(radians(angle1)))+mouseY;
    strokeWeight(3);
    point(x, y);
  }
}
void brushX () {
  int x=0;
  int y=0;
  for (int i=0; i < 2; i++) {
    x=mouseX;
    y=mouseY;
    strokeWeight(2);
    line(mouseX, mouseY, mouseX, mouseY++);
  }
}

Hello,

This is useful for timing:

There are many examples of timers in this forum.

I created a “rough” dripping effect with circle() and random() using mouseReleased():

void mouseReleased()
  {
  x = mouseX;
  y = mouseY;
  // Add code for effect here
  } 

image

Have fun!

:)

1 Like

Hi glv,

Big thanks for share!!!

2 Likes

I was thinking maybe you could use some sort of statement including the dist(mouseX,mouseY,pmouseX,pmouseY) function.
Another good option is using a statement including time elapsed like @glv suggested.

About the fact that the dripping effect had a spray effect too, maybe it’s because of too little variables and the fact that the same variable controls the spray effect and the line effect. I didn’t read into your code fully as it was kind of long, but I hope you find a solution and send the fixed code here as I would be interested in seeing it.
GL!

1 Like

Thakns @KaliBrain
I will keep trying!!!

1 Like

You change mouseY

That’s not a good thing

Instead copy mouseY to a new variable when dripping starts and then work with the new variable

@paulgoux Thx for sharing!!!

1 Like

@Chrisir Thanks!! :wink:

1 Like