Bots
June 4, 2023, 4:48pm
1
In the following code , I am trying to increase and decrease the size of the ellipses as my mouse moves from left to right on the canvas, I would appreciate any help
int logoSize = 250;
void setup(){
size(500,500);
}
void draw(){
background(255);
strokeWeight(20);
ellipse(mouseX,mouseY,logoSize+50+mouseX,logoSize-50+mouseX);
ellipse(mouseX,mouseY-60,logoSize-50+mouseX,logoSize-175+mouseX);
noFill();
ellipse(mouseX,mouseY,logoSize-175+mouseX,logoSize-50+mouseX);
if(mousePressed){
noLoop();
}
}
Bots
June 4, 2023, 6:18pm
2
@Chrisir could you help with this
jafal
June 4, 2023, 8:10pm
3
Hi
Welcome
float z= 60;
void setup() {
size(600, 600);
}
void draw() {
background(255, 0, 255);
fill(0, 255, 255);
ellipse(width/2, height/2, z, z);
ellipse(width/4, height/4, z, z);
}
void mousePressed() {
z= dist(mouseX, mouseY, width/2, height/2);
}
void mouseDragged() {
z= dist(mouseX, mouseY, width/2, height/2);
}
1 Like
you can also look at the map command, for example
// increase
radius1 = map (mouseX,
0,width,
30,129);
// decrease
radius2 = map (mouseX,
0,width,
129,30);
1 Like
Bots
June 4, 2023, 8:30pm
5
Thank you but i would also need the logo to follow the mouse as it gets bigger or smaller
1 Like
Bots
June 4, 2023, 8:30pm
6
Where would this be used exactly
the lines belong before the 2 lines with the ellipse command
the ellipse command need to use radius1 or radius2
before setup() you need float radius1, radius2;
you can use loadimage and then image(logo, mouseX, mouseY);
you can also use resize on image to change the size (or scale() command)
Bots
June 4, 2023, 8:43pm
9
Ok and what would the code look like after all of this
1 Like
read the reference and then show your approach please.
see resize() / Reference / Processing.org for example
Bots
June 4, 2023, 8:53pm
11
I genuinely don’t know the process behind it
Use loadImage to load your logo
Use the lines with map to calc the radius
Use radius with resize
Use image() to display the logo
There are examples to all commands in the reference
Bots
June 4, 2023, 9:20pm
13
so thing is the logo isn’t a picture, its three ellipses together so i don’t know how loadimage works with it
Loadimage does only apply when you want to load an image lile jpg
I misunderstood you
For the 3 circles just use the radius for each of then
And use translate (mouseX, mouseY); for example
Sorry that this is so hard.
Bots
June 4, 2023, 10:14pm
16
yes I only want to change the size
Bots
June 4, 2023, 10:26pm
17
still don’t really know how to do this
Chrisir:
the lines with map(mouseX… belong before the 2 lines with the ellipse command
the ellipse command need to use radius1 or radius2
before setup() you need float radius1, radius2;
That’s the idea
Can you please show your attempt
example with scale
The difficult thing is to have the logo stay in the same place during using scale().
[code removed]
1 Like
Bots
June 5, 2023, 6:16pm
20
This is my attempt so far
int logoSize = 250;
float radius1, radius2;
void setup(){
size(500,500);
}
void draw(){
background(255);
strokeWeight(20);
// increase
radius1 = map (mouseX,
0,width,
30,129);
// decrease
radius2 = map (mouseX,
0,width,
129,30);
ellipse(mouseX,mouseY,logoSize+50+mouseX,logoSize-50+mouseX);
ellipse(mouseX,mouseY-60,logoSize-50+mouseX,logoSize-175+mouseX);
noFill();
ellipse(mouseX,mouseY,logoSize-175+mouseX,logoSize-50+mouseX);
if(mousePressed){
noLoop();
}
}
Bots
June 5, 2023, 6:17pm
21
what am I missing if anything