summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-08-17 23:52:32 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-08-17 23:52:32 -0400
commite5f352a7e47741e06bd96120d1bd1f8c1f83589a (patch)
tree66612e1d702ed5d1da10c550261a59c7d4face65 /2d
parent6b217d8c62b75491576682f998acf07af45bcb86 (diff)
Use new color module.
Diffstat (limited to '2d')
-rw-r--r--2d/helpers.scm12
-rw-r--r--2d/sprite.scm14
2 files changed, 7 insertions, 19 deletions
diff --git a/2d/helpers.scm b/2d/helpers.scm
index 70b9a15..e71d7a1 100644
--- a/2d/helpers.scm
+++ b/2d/helpers.scm
@@ -37,15 +37,3 @@ otherwise."
"Returns true if the result of a bitwise AND of the integer
arguments is non-zero and returns false otherwise."
(not (zero? (apply logand args))))
-
-(define (rgba->gl-color color)
- "Converts an integer color code into OpenGL compatible color
-values. Returns a vector of four floating point numbers in range [0,1]."
- (define (component offset)
- (let ((mask (bitwise-arithmetic-shift-left #xff offset)))
- (/ (bitwise-arithmetic-shift-right (logand mask color) offset) 255.0)))
-
- (vector (component 24)
- (component 16)
- (component 8)
- (component 0)))
diff --git a/2d/sprite.scm b/2d/sprite.scm
index 1d4d4fd..bf2a0f6 100644
--- a/2d/sprite.scm
+++ b/2d/sprite.scm
@@ -29,6 +29,7 @@
#:use-module (figl contrib packed-struct)
#:use-module ((sdl sdl) #:prefix SDL:)
#:use-module (2d animation)
+ #:use-module (2d color)
#:use-module (2d helpers)
#:use-module (2d math)
#:use-module (2d texture)
@@ -61,11 +62,10 @@
(define (pack-sprite-vertices vertices offset x y width height origin-x origin-y
scale-x scale-y rotation s1 t1 s2 t2 color)
(define (pack-sprite x1 y1 x2 y2 x3 y3 x4 y4)
- (let* ((color (rgba->gl-color color))
- (r (vector-ref color 0))
- (g (vector-ref color 1))
- (b (vector-ref color 2))
- (a (vector-ref color 3)))
+ (let ((r (color-r color))
+ (g (color-g color))
+ (b (color-b color))
+ (a (color-a color)))
;; Vertices go counter clockwise, starting from the top-left
;; corner.
(pack vertices offset sprite-vertex
@@ -157,7 +157,7 @@
(animation-state sprite-animation-state set-sprite-animation-state!))
(define* (make-sprite drawable #:optional #:key (position #(0 0)) (scale #(1 1))
- (rotation 0) (color #xffffffff) (anchor 'center))
+ (rotation 0) (color white) (anchor 'center))
"Makes a new sprite object."
(let ((vertices (make-packed-array sprite-vertex 4))
(animation-state (if (animation? drawable)
@@ -180,7 +180,7 @@ operation that requires a refresh of the vertex array should use this macro."
(dirty-sprite-setter set-sprite-anchor! %set-sprite-anchor!)
(define* (load-sprite filename #:optional #:key (position #(0 0)) (scale #(1 1))
- (rotation 0) (color #xffffffff) (anchor 'center))
+ (rotation 0) (color white) (anchor 'center))
"Loads a sprite from file."
(make-sprite (load-texture filename) #:position position #:scale scale
#:rotation rotation #:color color #:anchor anchor))