1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

examples: add support for transparency / opacity / alpha in particle example (#6488)

This commit is contained in:
Larpon
2020-09-28 06:14:15 +02:00
committed by GitHub
parent 06cade6c31
commit 0e2f267805
3 changed files with 15 additions and 7 deletions

View File

@@ -27,7 +27,7 @@ fn remap(v, min, max, new_min, new_max f64) f64 {
return (((v - min) * (new_max - new_min)) / (max - min)) + new_min
}
// * Particle
// Particle
pub struct Particle {
mut:
location vec2.Vec2
@@ -49,7 +49,7 @@ pub fn (mut p Particle) update(dt f64) {
p.color.r = p.color.r - 1 // byte(remap(p.life_time,0.0,p.life_time_init,0,p.color.r))
p.color.g = p.color.g - 1 // byte(remap(p.life_time,0.0,p.life_time_init,0,p.color.g))
p.color.b = p.color.b - 1 // byte(remap(p.life_time,0.0,p.life_time_init,0,p.color.b))
// p.color.a = byte(remap(p.life_time,0.0,p.life_time_init,0,255))
p.color.a = byte(int(remap(p.life_time, 0.0, p.life_time_init, 0, 255))) - 10
} else {
p.life_time = 0
}