Search code examples
rangescalingnormalizegml

Scale down a larger number from 0 - 1 - 0


I'm not math savvy - but what I want to do seems to be math heavy.

I'm looking to scale down a number which ranges from 0-800 so that it is within a range of 0-1-0 (so 1 being 400). Not sure if this is possible, but my attempts at a solution have not been fruitful. Any indication as to where to look for a solution would be of great benefit!

It's so I can change the alpha of images depending on the screen location - the centre-most images should be 100% visible, whilst as it get's further to the edge of the screen, the images should become more transparent. The range for alpha is 0-1.

Kind regards, and thanks in advance!


Solution

  • Here is the graph of 1-abs(1-2x/a) where a=800:

    1-abs(1-2x/a)

    Here is sin(pi*x/a):

    enter image description here