Posted By

helloworlder on 08/19/09


Tagged

rectangle lasso dragging selecting


Versions (?)

Draw a lasso rectangle


 / Published in: Pseudocode
 

startloc.x and startloc.y is the position where the dragging first began.

Note that the top, bottom, left , and right represents positions of the 4 lines, with the anchor point at either the top of the line if vertical or left if horizontal.

Also note that the variable top will not always represent the position of the top line and the bottom not always the bottom etc, but only if you imagine dragging a lasso box from the top left to the bottom right. It does not matter however, the lasso will work in any case. The naming just made it easier for me to code it. Just think about it a little and you'll get it.

  1. if(dragging) # yea this is a loop as long as dragging == true
  2. {
  3. graphics.clear();
  4.  
  5. current = getMousePosition() # get latest mouse position
  6.  
  7. length = current.x - start_loc.x # current length so far
  8. height = current.y - start_loc.y # current height so far
  9.  
  10. top = new Point(start_loc.x, start_loc.y)
  11. bottom = new Point(start_loc.x, start_loc.y + height)
  12. left = new Point(start_loc.x, start_loc.y)
  13. right = new Point(current.x, start_loc.y)
  14.  
  15. #drawLine(positionX, positionY, length);
  16. drawLine(top.x, top.y, length) # line anchor point on left
  17. drawLine(bottom.x, bottom.y, length)
  18. drawLine(left.x, left.y, height)
  19. drawLine(right.x, right.y, height)
  20. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Tanaaz on February 6, 2010

Thanks for the interesting information. The codes are well explained, so I think I'll be able to use them conveniently! But I've heard that a Lasso triangle is extremely difficult to finish! Grand National

Posted By: Markdaniel on April 13, 2010

This is an intestind and tutorial post. As a developer I remark it 7/10. Thanks for sharing. Good work. Seo Services

Posted By: Markdaniel on April 15, 2010

Professional SEO and Internet marketing company near Kolkata, India. Contact now at [email protected] or call us straightly at +91.9433365039. We offer best SEO, Social Media and Link building services for all range of business and their sites.

Posted By: Markdaniel on April 15, 2010

Professional SEO and Internet marketing company near Kolkata, India. Contact now at [email protected] or call us straightly at +91.9433365039. We offer best SEO, Social Media and Link building services for all range of business and their sites.

Posted By: Markdaniel on April 15, 2010

Professional SEO and Internet marketing company near Kolkata, India. Contact now at [email protected] or call us straightly at +91.9433365039. We offer best SEO, Social Media and Link building services for all range of business and their sites.

Posted By: jaffa on June 16, 2012

Readjust and correct any issues with the letterhead in Word. Save your changes. Print another copy of the letterhead. Look it over copy again. Repeat this process until you are satisfied with the letterhead. Thanks for sharing information. Regards, website design company

Posted By: jaffa on June 18, 2012

The standard release of Drupal, known as Drupal core, contains basic features common to content management systems. These include user account registration and maintenance, menu management, RSS feeds, page layout customization, and system administration. Thanks. Regards, http://www.wejustlink.com

Posted By: jaffa on June 19, 2012

Refer jobs that require less skill and which are generally lower-paying to a junior designer, and jobs that are out of your comfort zone to your expert in that area. Thanks a lot. Regards, help writing a thesis statement

You need to login to post a comment.