Growing circles on mouse move
in
Programming Questions
•
2 years ago
So, you'll have to forgive me, I'm very new to processing, but I'm trying to create a drawing tool that somewhat mimics what a person experiences when using a sharpie pen (or any other sort of pen or marker in which the ink kind of flows on its own). I've got a fairly decent work in progress, but I haven't been able to figure out how to make the circles grow only when the mouse moves over a created circle while the mouse button is clicked (i.e. the ink should only expand when the tip is held to the paper; if the pen is moving, the ink shouldn't expand but should simply draw lines).
Here's the code I'm working with:
int num = 80;
int count = 0;
float mx[] = new float[num];
float my[] = new float[num];
float ms[] = new float[num];
void setup() {
size(800, 800);
noStroke();
fill(0, 255);
background(255);
}
void draw() {
if (mousePressed)
{
stroke(0);
strokeWeight(20);
smooth();
line(pmouseX, pmouseY, mouseX, mouseY);
if (mousePressed)
{
mx[count%num] = mouseX;
my[count%num] = mouseY;
ms[count%num] = 0;
for (int i = 0; i < min(count, num); i++) {
ellipse(mx[i], my[i], ms[i], ms[i]);
ms[i]++;
}
count++;
}
}
}
void mouseReleased() {
count=0;
}
I've tried using the mouseMoved function but it doesn't work like mousePressed and the example in resources doesn't show how to limit its effects for only if the mouse is over the object.
Here's the code I'm working with:
int num = 80;
int count = 0;
float mx[] = new float[num];
float my[] = new float[num];
float ms[] = new float[num];
void setup() {
size(800, 800);
noStroke();
fill(0, 255);
background(255);
}
void draw() {
if (mousePressed)
{
stroke(0);
strokeWeight(20);
smooth();
line(pmouseX, pmouseY, mouseX, mouseY);
if (mousePressed)
{
mx[count%num] = mouseX;
my[count%num] = mouseY;
ms[count%num] = 0;
for (int i = 0; i < min(count, num); i++) {
ellipse(mx[i], my[i], ms[i], ms[i]);
ms[i]++;
}
count++;
}
}
}
void mouseReleased() {
count=0;
}
I've tried using the mouseMoved function but it doesn't work like mousePressed and the example in resources doesn't show how to limit its effects for only if the mouse is over the object.
1