okay, this is becoming quite a bit more complicated than I had hoped. I''m not complaining, mind you, I''ve already learned quite a lot. Here is what I want:
The user moves their mouse along the x axis. I''m only concerned with distance along the x axis. All others can be ignored. As the distance from the mouse to the icon becomes shorter, the icon grows to be bigger. The minimum size that an icon can be is the size that it started out as; at the moment 50x50. The maximum size that it can be is twice its origional (100x100). The scaling "curve" if you were to graph the function I want to be roughly logorithmic, or even asuptotic (spellng?) in that it is a steady, fluid curve that never doubles back on itself. The only value going into the function for f(x) is the distance from the mouse to the icon (abs(mouse_x - icon_x)) direction I don''t care about because as I get close from one side it gets bigger, and as I get farther away continuing in the other direction it gets smaller again.
I hope that makes it roughly clear. If you are still confused find someone with a mac or go to comp usa or your local mac store and check out the dock at the bottom of the screen. Some of you may be familiar with a similar effect from nextStep, which is the basis for mac os x.
Peace,
Thokmas
a question about math
interpolation
scale = (maxscale-minscale)*Factor + minscale;
factor will be from 0 to 1, 0 is farthest away form the object, and 1 is on it so do like
scale = (maxscale-minscale)*(actualdistance/maxpossibledistance)+minscale;
maxpossible distance will be depenedent on the resolution iguess the far edge away from the task bar, also if u want there to be a threshold about halfway through the screen u could do
scale = (maxscale-minscale)*(max(0,actualdistance/(maxpossibledistance-thresholddistance)))+ minscale;
you may have to tweek those equations but i htink they are almost right.
hope that helped, or im an idiot...
scale = (maxscale-minscale)*Factor + minscale;
factor will be from 0 to 1, 0 is farthest away form the object, and 1 is on it so do like
scale = (maxscale-minscale)*(actualdistance/maxpossibledistance)+minscale;
maxpossible distance will be depenedent on the resolution iguess the far edge away from the task bar, also if u want there to be a threshold about halfway through the screen u could do
scale = (maxscale-minscale)*(max(0,actualdistance/(maxpossibledistance-thresholddistance)))+ minscale;
you may have to tweek those equations but i htink they are almost right.
hope that helped, or im an idiot...
Why don't you use something like "e^(-x^2) + 1" then. It's a very fluid curve, will look great, and you don't even need to worry about taking the absolute value (the graph is semetrical about the y-axis already). It is also logarithmic in nature as you requested.
My suggestion therefore would be that you use the following formula. If d is your distance:
ScaleFactor = e^(-d^2) + 1
Which will produce a value between 1 and 2, for ANY input x. I'd also recommend that you do a simple check that if abs(d) > some reasonable value, just set the Scale Factor to 1, to avoid the far away icons from jittering.
Secondly if you need to tweak the effect ranges, just substitute (d/c) for d in the above equation. The value of c will control how far away the scalaing starts, etc (although inversly... ie. larger values of c will make it start CLOSER).
Anyways that's the basics. There are plenty of things you can do with that one function, and if you don't like it, there are plenty more options. Good luck with it, and feel free to come back and ask for more help if you need it!
PS: it's spelled "asymptotic"
[Edit] The above linear interpolation method is fine, but it won't give you the "smooth" curve that you are looking for. Graphically, it will be a line which at zero hits a sharp corner. The logarithmic function will be much "smoother". Just graph them both and see what I mean.
[edited by - AndyTX on May 6, 2003 9:57:54 AM]
My suggestion therefore would be that you use the following formula. If d is your distance:
ScaleFactor = e^(-d^2) + 1
Which will produce a value between 1 and 2, for ANY input x. I'd also recommend that you do a simple check that if abs(d) > some reasonable value, just set the Scale Factor to 1, to avoid the far away icons from jittering.
Secondly if you need to tweak the effect ranges, just substitute (d/c) for d in the above equation. The value of c will control how far away the scalaing starts, etc (although inversly... ie. larger values of c will make it start CLOSER).
Anyways that's the basics. There are plenty of things you can do with that one function, and if you don't like it, there are plenty more options. Good luck with it, and feel free to come back and ask for more help if you need it!
PS: it's spelled "asymptotic"
[Edit] The above linear interpolation method is fine, but it won't give you the "smooth" curve that you are looking for. Graphically, it will be a line which at zero hits a sharp corner. The logarithmic function will be much "smoother". Just graph them both and see what I mean.
[edited by - AndyTX on May 6, 2003 9:57:54 AM]
uhm, that looks like what you want...
f(x) = 1/((x*n)^m+0.5)
you can chose whatever number you like for n and m
[edited by - novum on May 6, 2003 10:11:12 AM]
f(x) = 1/((x*n)^m+0.5)
you can chose whatever number you like for n and m
[edited by - novum on May 6, 2003 10:11:12 AM]
okay, I can see the flames already because of obvious issues of screen res, etc. but I just divided the distance by 200 (all screen coords in the api I''m using are floats, so decimals are okay) and my function is (2 - sqrt(distance)). It makes it nice and smooth, and I just have a check that if at any time the size of the icon drops below its base size, then set it to its base size. The extra check slows things down a bit, but only by about 4 operations per cycle, which no human being will ever notice. And if they do, they can kiss it.
Again, everyone, thanx for all your help! I hope that this thread is also useful to other people. I will try some of the functions that you all have given me and see if I like any of them better than what I already have. Thank you so much!
Over and out,
Me.
Again, everyone, thanx for all your help! I hope that this thread is also useful to other people. I will try some of the functions that you all have given me and see if I like any of them better than what I already have. Thank you so much!
Over and out,
Me.
Not a problem, and don''t worry about the "extra check"... it''s gonna be necessary no matter what. Plus, even with 100 icons, 100 if conditions is still negligable compared ot even drawing a single icon anyways
It will never go over y=2 for x>=0 for odd m and will never go over y=2 for even m :D
[edited by - novum on May 8, 2003 10:48:08 AM]
[edited by - novum on May 8, 2003 10:48:08 AM]
No no no... an UPPER BOUND check on the DOMAIN, not the range. The point is that after the cursor gets 2 or 3 icons away, you want to cap the icon size at 1x... not just NEAR 1x or anything... the if condition is necessary because what we want is a function like:
f(d) = { g(d) if |d|<100, 1 if |d| >= 100 }
Where d is the distance and 100 is an arbitrary pixel range maximum to begin scaling at.
[edited by - AndyTX on May 8, 2003 10:02:39 PM]
f(d) = { g(d) if |d|<100, 1 if |d| >= 100 }
Where d is the distance and 100 is an arbitrary pixel range maximum to begin scaling at.
[edited by - AndyTX on May 8, 2003 10:02:39 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement