diff options
| author | Tom Black <[email protected]> | 2019-01-03 16:49:51 -0800 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2019-01-03 16:57:23 -0800 |
| commit | ddc3d31a09557d4d24068078e9d4011df260dc93 (patch) | |
| tree | e043e8080c97cd109cad08076bb0931ec49098c0 /ext | |
| parent | be713c960e2b9f675e04c6d7cdabb3cd61a0d62d (diff) | |
| download | ruby2d-ddc3d31a09557d4d24068078e9d4011df260dc93.tar.gz ruby2d-ddc3d31a09557d4d24068078e9d4011df260dc93.zip | |
Color enhancements, fixes, refactoring
Opacity and color can now be set for sprites. Opacity can now also be set when instantiating a new renderable object. `Color.from(c)` renamed to `Color.set(c)` for clarity. `Renderable` module includes more common functionality.
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/ruby2d/ruby2d.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index de22762..3d300dc 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -444,6 +444,12 @@ static R_VAL ruby2d_sprite_ext_render(R_VAL self) { S2D_RotateSprite(spr, NUM2DBL(r_iv_get(self, "@rotate")), S2D_CENTER); + R_VAL c = r_iv_get(self, "@color"); + spr->color.r = NUM2DBL(r_iv_get(c, "@r")); + spr->color.g = NUM2DBL(r_iv_get(c, "@g")); + spr->color.b = NUM2DBL(r_iv_get(c, "@b")); + spr->color.a = NUM2DBL(r_iv_get(c, "@a")); + S2D_ClipSprite( spr, NUM2INT(r_iv_get(self, "@clip_x")), |
