Пример #1
0
// Color returns the current drawing color.
func (c Canvas) color() color.Color {
	var r, g, b, a C.Uint8
	if C.SDL_GetRenderDrawColor(c.win.rend, &r, &g, &b, &a) < 0 {
		panic(sdlError())
	}
	return color.NRGBA{uint8(r), uint8(g), uint8(b), uint8(a)}
}
Пример #2
0
func (renderer *Renderer) GetDrawColor(r, g, b, a *uint8) int {
	_renderer := (*C.SDL_Renderer)(unsafe.Pointer(renderer))
	_r := (*C.Uint8)(unsafe.Pointer(r))
	_g := (*C.Uint8)(unsafe.Pointer(g))
	_b := (*C.Uint8)(unsafe.Pointer(b))
	_a := (*C.Uint8)(unsafe.Pointer(a))
	return (int)(C.SDL_GetRenderDrawColor(_renderer, _r, _g, _b, _a))
}
Пример #3
0
func (renderer *Renderer) GetDrawColor() (r, g, b, a uint8, status int) {
	_r := (*C.Uint8)(unsafe.Pointer(&r))
	_g := (*C.Uint8)(unsafe.Pointer(&g))
	_b := (*C.Uint8)(unsafe.Pointer(&b))
	_a := (*C.Uint8)(unsafe.Pointer(&a))
	status = int(C.SDL_GetRenderDrawColor(renderer.cptr(), _r, _g, _b, _a))
	return
}
Пример #4
0
func (r *Renderer) GetDrawColor() (red, g, b, a uint8, err error) {
	var cr, cg, cb, ca C.Uint8
	if C.SDL_GetRenderDrawColor(r.c, &cr, &cg, &cb, &ca) != 0 {
		return 0, 0, 0, 0, getError()
	}

	return uint8(cr), uint8(cg), uint8(cb), uint8(ca), nil
}
Пример #5
0
func (r *Renderer) GetDrawColor() Color {
	cr := C.Uint8(0)
	cg := C.Uint8(0)
	cb := C.Uint8(0)
	ca := C.Uint8(0)
	ret := C.SDL_GetRenderDrawColor(r.cRenderer, &cr, &cg, &cb, &ca)
	if int(ret) == 0 {
		return Color{uint8(cr), uint8(cg), uint8(cb), uint8(ca)}
	}
	return Color{0, 0, 0, 0}
}
Пример #6
0
// Renderer (https://wiki.libsdl.org/SDL_GetRenderDrawColor)
func (renderer *Renderer) GetDrawColor() (r, g, b, a uint8, err error) {
	_r := (*C.Uint8)(unsafe.Pointer(&r))
	_g := (*C.Uint8)(unsafe.Pointer(&g))
	_b := (*C.Uint8)(unsafe.Pointer(&b))
	_a := (*C.Uint8)(unsafe.Pointer(&a))
	_ret := C.SDL_GetRenderDrawColor(renderer.cptr(), _r, _g, _b, _a)
	if _ret < 0 {
		err = GetError()
		return r, g, b, a, err
	}
	return r, g, b, a, nil
}