Copy link to clipboard
Copied
In super short, I want to do this ↓
And I've tried these:
I want to give user a float slider (to move something in X and Y) but the result should be a multiple of 1/32 (let's say).
The approaches I tried are not giving me the 'Stepped' result but smooth continous values.
Happy holidays to the US folks!
Thanks!
Hey Ayush,
Great task, I'll give you an outline of how this would work.
Lets say you want a float to be a multiple of 1/32
1. Multiply the float with 32, so you have a floating point value between 0 and 32
2. Use the floor function on the result or round the result to the nearest integer value (depending on what you want to achieve)
3. Divide the rounded value by 32 to get a stepped value between 0 and 1 with a distance of 1/32
If you have any arbitrary value which is not expressable by a frac
...Copy link to clipboard
Copied
Hey Ayush,
Great task, I'll give you an outline of how this would work.
Lets say you want a float to be a multiple of 1/32
1. Multiply the float with 32, so you have a floating point value between 0 and 32
2. Use the floor function on the result or round the result to the nearest integer value (depending on what you want to achieve)
3. Divide the rounded value by 32 to get a stepped value between 0 and 1 with a distance of 1/32
If you have any arbitrary value which is not expressable by a fraction, let's say you want values to be a multiple of 0.0317 then just divide the input float by this value this gives you a range between 0 and 1/0.0317 floor or round the result and multiply it by 0.0317 and you have a stepped value with multiples of 0.0317.
I hope this helps, stay healthy and creative Marco
Copy link to clipboard
Copied