By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

how to move multiple objects - mouse press

P: 2
Hi there

Request - simplest on mouse press/ drag , multiple ellipse (or ellipse in square). Attempted to modify code for ellipse(), multiple objects, mouse press - incl. pvectors, pop matrix, translate (all translate to continuous tail from single ellipse). All my code is very messy. A maths or syntax query

simple modification of processing.js code :
When I attempt to modify for mulitple objects( incl all versions eg. simple ellipse (0 - int NUM = 20... for (int i = 0; i < 20; i++) etc ). Advice / links ref multiple ellipses on mouse press - locating ellipse. (using int x, y, sz = 100).


Expand|Select|Wrap|Line Numbers
  1. void setup() {
  2.   size(400, 300);
  3.   colorMode(HSB);
  4.   noStroke();
  5.   smooth();
  6.  
  7.   fill(random(255), 100, 200);
  8.   bgcolor = color(random(255), 150, 255);
  9.   background(bgcolor);
  10. }
  11. void draw() {
  12.   background(bgcolor);
  13.  
  14.   if(dist(x,y, mouseX, mouseY) < sz / 2) {
  15.     cursor(HAND);
  16.     if(mousePressed) {
  17.       x = mouseX;
  18.       y = mouseY;
  19.       strokeWeight(5);
  20.     } else {
  21.       strokeWeight(2);
  22.     }
  23.     stroke(255);
  24.   } else {
  25.     cursor(ARROW);
  26.     noStroke();
  27.   }
  28.  
  29.   ellipse(x, y, sz, sz);
  30. }
  31.  
attempt version- PLEASE - the code is a version of 100s (amongst which some the syntax errors = = ';'! code included to emphasis that the request is the context of transforming syntax for multiple mouse press/ drag/ spring particularly locating ellipse.

Expand|Select|Wrap|Line Numbers
  1. int [i] = new int [20];
  2.  
  3. PVector position;
  4.  
  5. void sestup() {
  6.   size (200, 200);
  7.   smooth();
  8.  
  9.   position = new PVector();
  10.  
  11. }
  12.  
  13. void draw()
  14. {
  15.   ellipseMode(CENTER);
  16.  
  17.   for(int [i] = 0; i < 20; i++);
  18.  
  19.   if  (mousePressed);
  20.   x = mouseX
  21.   y = mouseY
  22.  
  23.   pushMatrix();
  24.  
  25. ellipse(mouseX, mouseY, 100, 100);
  26.  
  27. popMatrix();
  28.  
  29. }
Thank you for your assistance!
Oct 18 '12 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,430
I have absolutely no idea what you just said.
Oct 18 '12 #2

gits
Expert Mod 5K+
P: 5,390
the posted code is no javascript at all - and the question isn't clear either
Oct 19 '12 #3

P: 2
the processing.js is OOP javascript based. Request - simplest on mouse press/ drag , multiple ellipse.The processing forum replies are the same examples I modified. requesting assistance for : multiple ellipse (on mouse press move). error on locating x,y mouse press for ellipse center transform for multiple objects

Expand|Select|Wrap|Line Numbers
  1. using int string for ( int i = 0; i < 20; i++) 
  2. object ellipse (co,or for multiple ellipses) 
  3. on mouse press versions.... mouseX, mouseY.... tempmouseX .... tempmouseY
  4. locating ellipse on mouse press ... [20]  conversion code =error  
Thank you for your assistance!
Oct 19 '12 #4

zmbd
Expert Mod 5K+
P: 5,397
abde - please read the following and confirm or correct:

From both OP posts:
It appears that OP is asking about the boundary box that shows when user left-click-hold (L-C-H) in empty area and then drags across multiple objects... for example, MS access form designer, three textboxs and labels... L-C-H on the background of the form and then drag mouse across the form, a box-frame shows up that indicates the selection boundary so that one could select one, two, or all six objects by enclosing them in the boundary box.
Oct 19 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.