@
@
@ntkernel2020-11-27 23:10:26
Algorithms
@ntkernel, 2020-11-27 23:10:26

How to calculate transparency from distance?

Good day, there is the center of the screen (position, conditionally 1920x1080/2), there is also an object (an inscription, a square, and also a winapee window). It is necessary to reduce Alpha (transparency) depending on the distance from the center. I've been thinking about the implementation for 2 days now, I can't come up with
PS Alpha from 0 to 255.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2020-11-27
_

Take the distance from the center to the point you are interested in x and y
R = sqrt( (x-1920/2)^2 + (y-1080/2)^2 )
And then do whatever you want with it, for example:
alpha = 255 * ( 1- R / (1920/2) ) - maximum alpha in the center, minimum - at the edge of the screen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question