We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Mapping dist() to scale()
Page Index Toggle Pages: 1
Mapping dist() to scale() (Read 537 times)
Mapping dist() to scale()
Jun 28th, 2009, 6:20am
 
I have two points, whose distance apart I'm tracking with a dist() float. What I'd like to do is map that to another float linked to a scale() function elsewhere.

Essentially, I'd like the resulting scale() float, which starts at 1.0, to add 0.1 if the line is growing, and subtract 0.1 if the line is shrinking. Roughly like getting the difference between mouseX and pmouseX, except I'm not sure how to do this with a line whose length is constantly changing.

Any thoughts?
Re: Mapping dist() to scale()
Reply #1 - Jun 28th, 2009, 11:23am
 
Unless I've misunderstood your aim I think you may be over-analysing the problem.  You have a starting state for the distance between two points - store this in a variable.  In draw() subtract the current distance from the starting state and adjust scale accordingly...
Page Index Toggle Pages: 1