|
From: | Matt Welland |
Subject: | Re: [Chicken-users] canvas-draw and colors |
Date: | Sat, 16 Jul 2016 13:39:34 -0700 |
On 2016-07-16 21:31, Matt Welland wrote:
> [...]
> (define (vg:rgb->number r g b #!key (a 0)) (u32vector-ref
> (blob->u32vector (u8vector->blob (list->u8vector (list a r g b)))) 0))
> [...]
Hello,
this snippet seems somewhat sub-optimal to say the least. Apart from
being needlessly complicated, it may also be wrong because its result
depends on the endianness of the host platform.
I would suggest to simply use bitwise arithmetic:
(bitwise-ior
(arithmetic-shift a 24)
(arithmetic-shift r 16)
(arithmetic-shift g 8)
b)
Or perhaps just normal arithmetic replacing bitwise-ior by + and
arithmetic-shift by (lambda (x n) (* x (expt 2 n))). This is probably no
less efficient, as the result is going to be a bignum anyway.
Ciao,
Thomas
--
When C++ is your hammer, every problem looks like your thumb.
_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users
[Prev in Thread] | Current Thread | [Next in Thread] |