示例#1
0
文件: pixels.go 项目: DeedleFake/sdl
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
}
示例#2
0
文件: pixels.go 项目: emlai/go-sdl2
// 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
}