Example #1
0
//Draws the image at the given coordinates.
func DrawImage(img *Image, destX, destY, srcX, srcY, srcW, srcH int) {
	var src, dest C.SDL_Rect
	dest.x = C.int(destX)
	dest.y = C.int(destY)
	dest.w = C.int(img.Width)
	dest.h = C.int(img.Height)

	src.x = C.int(srcX)
	src.y = C.int(srcY)
	src.w = C.int(srcW)
	src.h = C.int(srcH)
	C.SDL_SetTextureAlphaMod(img.surface, 255)
	C.SDL_RenderCopy(renderer, img.surface, &src, &dest)
}
Example #2
0
//Draws the image at the given coordinates.
func (me *Canvas) DrawImage(img *Image, x, y int) {
	C.SDL_SetAlpha(img.img, C.SDL_SRCALPHA, 255)
	var dest C.SDL_Rect
	dest.x = C.Sint16(x + me.origin.X)
	dest.y = C.Sint16(y + me.origin.Y)
	C.SDL_BlitSurface(img.img, nil, me.pane, &dest)
}
Example #3
0
func sdl_Rect(x, y, width, height int) C.SDL_Rect {
	var r C.SDL_Rect
	r.x = C.int(x)
	r.y = C.int(y)
	r.w = C.int(width)
	r.h = C.int(height)
	return r
}
Example #4
0
func toSDL_Rect(b util.Bounds) C.SDL_Rect {
	var r C.SDL_Rect
	r.x = C.Sint16(b.X)
	r.y = C.Sint16(b.Y)
	r.w = C.Uint16(b.Width)
	r.h = C.Uint16(b.Height)
	return r
}
Example #5
0
func FillRect(x, y, w, h int, c Color) {
	var rect C.SDL_Rect
	rect.x = C.int(x)
	rect.y = C.int(y)
	rect.w = C.int(w)
	rect.h = C.int(h)
	C.SDL_SetRenderDrawColor(renderer, C.Uint8(c.Red), C.Uint8(c.Green), C.Uint8(c.Blue), C.Uint8(c.Alpha))
	C.SDL_RenderFillRect(renderer, &rect)
}
Example #6
0
// Blit performs a fast blit from the source surface to the destination surface.
//
// srcRect represents the rectangle to be copied or image.ZR to copy the entire
// surface.
//
// dstPoint represents the destination position.
func (src *Surface) Blit(srcRect image.Rectangle, dst *Surface, dstPoint image.Point) (err error) {
	cSrcRect := cRect(srcRect)
	cDstRect := new(C.SDL_Rect)
	cDstRect.x = C.int(dstPoint.X)
	cDstRect.y = C.int(dstPoint.Y)
	if C.SDL_BlitSurface(src.cSurface, cSrcRect, dst.cSurface, cDstRect) != 0 {
		return getError()
	}
	return nil
}
Example #7
0
//Draws the text at the given coordinates.
func (me *Canvas) DrawText(text *Text, x, y int) {
	var dest C.SDL_Rect
	dest.x = C.Sint16(x + me.origin.X)
	dest.y = C.Sint16(y + me.origin.Y)
	C.SDL_BlitSurface(text.text, nil, me.pane, &dest)
}