Sander Schobers
115f9877c1
- Added sub-bitmaps. - Color implements color.Color interface. - Added methods to retrieve font dimensions and its rendered text. - Added DrawPolyline method.
32 lines
645 B
Go
32 lines
645 B
Go
package allegro5
|
|
|
|
// #include <allegro5/allegro.h>
|
|
import "C"
|
|
import "image/color"
|
|
|
|
var _ color.Color = &Color{}
|
|
|
|
type Color struct {
|
|
color C.ALLEGRO_COLOR
|
|
}
|
|
|
|
func NewColor(r, g, b byte) Color {
|
|
return Color{C.al_map_rgb(C.uchar(r), C.uchar(g), C.uchar(b))}
|
|
}
|
|
|
|
func NewColorAlpha(r, g, b, a byte) Color {
|
|
return Color{C.al_map_rgba(C.uchar(r), C.uchar(g), C.uchar(b), C.uchar(a))}
|
|
}
|
|
|
|
// RGBA implements the color.Color interface.
|
|
func (c Color) RGBA() (r, g, b, a uint32) {
|
|
var cr, cg, cb, ca C.uchar
|
|
C.al_unmap_rgba(c.color, &cr, &cg, &cb, &ca)
|
|
a = uint32(ca)
|
|
r = uint32(cr) * a
|
|
g = uint32(cg) * a
|
|
b = uint32(cb) * a
|
|
a *= a
|
|
return
|
|
}
|