Esempio n. 1
0
func (p *Palette) SetColors(c []Color, firstcolor int) error {
	if C.SDL_SetPaletteColors(p.c(), c[0].c(), C.int(firstcolor), C.int(len(c))) != 0 {
		return getError()
	}

	return nil
}
Esempio n. 2
0
// SetColors sets a range of colors in a palette.
// Palette (https://wiki.libsdl.org/SDL_SetPaletteColors)
func (palette *Palette) SetColors(colors []Color) error {
	var ptr *C.SDL_Color
	if len(colors) > 0 {
		ptr = (*C.SDL_Color)(unsafe.Pointer(&colors[0]))
	}

	r := C.SDL_SetPaletteColors((*C.SDL_Palette)(unsafe.Pointer(palette)),
		ptr, 0, C.int(len(colors)))
	if r != 0 {
		return GetError()
	}
	return nil
}