From 897aefd227d4e45989c02d828a9b968d60a6f6bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 1 Feb 2016 11:45:35 -0500 Subject: [PATCH] lib/gamnit: intro `Sprite::tint` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/gamnit/flat.nit | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/gamnit/flat.nit b/lib/gamnit/flat.nit index ab433bf..6f9dea4 100644 --- a/lib/gamnit/flat.nit +++ b/lib/gamnit/flat.nit @@ -59,7 +59,15 @@ class Sprite var scale = 1.0 is writable # Transparency applied to the texture on draw - var alpha = 1.0 is writable + fun alpha: Float do return tint[3] + + # Transparency applied to the texture on draw + fun alpha=(value: Float) do tint[3] = value + + # Tint applied to the texture on draw + # + # Require: `tint.length == 4` + var tint: Array[Float] = [1.0, 1.0, 1.0, 1.0] is writable private fun draw do @@ -73,7 +81,7 @@ class Sprite simple_2d_program.scale.array_enabled = false simple_2d_program.translation.uniform(center.x, -center.y, center.z, 0.0) - simple_2d_program.color.uniform(1.0, 1.0, 1.0, alpha) + simple_2d_program.color.uniform(tint[0], tint[1], tint[2], tint[3]) simple_2d_program.scale.uniform scale simple_2d_program.use_texture.uniform true -- 1.7.9.5