| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jul 2005
Posts: 9
|
i'm trying to write a little command that will move my selection to whole pixels.
i though originally that i would be able to write it so that i can select a bunch of things and have jsfl loop through them and move each one onto whole pixels. this failed miserablly so i'm now attempting to just get the selection moved onto a whole pixel which works with a 0.1% margin of error, which obviously dosen't work. grr it's winding me up. ActionScript Code:
|
|
|
|
|
|
#2 |
|
Registered User
Join Date: Jul 2005
Posts: 9
|
ok so if i switch from using Math.ceil() to using Math.floor() it works , observe:
ActionScript Code:
however this isn't truley moving it to the nearest pixel, it's moving it to the lowest whole pixel. not good. how can i make it behave like Math.round() without the errors?? |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Jul 2005
Posts: 9
|
ok so this is working like 99% :
ActionScript Code:
sometimes however it will land on either xxx.1 or xxx.9 positions, this tends to occur when the original begins xxx.049xxxxxxx obviously where i am adding 1 to counter the Math.floor() when needed i am in fact adding 1.049 am i right in thinking that?? is it just that the Math class can't handle these numbers or what??? |
|
|
|
|
|
#4 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
i think this is a floting point math issue. what you can try is to execute two math.round's on it... a hack but it might work
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|