Example #1
0
//Pushs a viewport to limit the drawing space to the given bounds within the current drawing space.
//Will not accept any negative values.
func (me *Canvas) PushViewport(x, y, width, height int) {
	me.origin.SubtractFrom(me.viewport.translate())
	me.viewport.push(util.Bounds{util.Point{X: int(x), Y: int(y)}, util.Size{Width: int(width), Height: int(height)}})
	r := toSDL_Rect(me.viewport.bounds())
	C.SDL_SetClipRect(me.pane, &r)
	me.origin = me.translation.AddOf(me.viewport.bounds().Point)
	me.origin.AddTo(me.viewport.translate())
}
Example #2
0
//Exits the current viewport, unless there is no viewport.
func (me *Canvas) PopViewport() {
	if me.viewport.pt != 0 {
		me.origin.SubtractFrom(me.viewport.translate())
		me.viewport.pop()
		r := toSDL_Rect(me.viewport.bounds())
		C.SDL_SetClipRect(me.pane, &r)
		me.origin = me.translation.AddOf(me.viewport.bounds().Point)
		me.origin.AddTo(me.viewport.translate())
	}
}
Example #3
0
// Sets the clipping rectangle for a surface.
func (s *Surface) SetClipRect(r *Rect) {
	s.mutex.Lock()
	C.SDL_SetClipRect(s.cSurface, (*C.SDL_Rect)(cast(r)))
	s.mutex.Unlock()
}
Example #4
0
func (surface *Surface) SetClipRect(rect *Rect) bool {
	return C.SDL_SetClipRect(surface.cptr(), rect.cptr()) > 0
}
Example #5
0
// Sets the clipping rectangle for a surface.
func (s *Surface) SetClipRect(r *Rect) {
	C.SDL_SetClipRect((*C.SDL_Surface)(cast(s)), (*C.SDL_Rect)(cast(r)))
	return
}
Example #6
0
func (surface *Surface) SetClipRect(rect *Rect) bool {
	_surface := (*C.SDL_Surface)(unsafe.Pointer(surface))
	_rect := (*C.SDL_Rect)(unsafe.Pointer(rect))
	return C.SDL_SetClipRect(_surface, _rect) > 0
}
Example #7
0
func (s *Surface) SetClipRect(r *Rect) bool {
	return C.SDL_SetClipRect(s.c(), r.c()) == C.SDL_TRUE
}
Example #8
0
func (s *Surface) ClearClipRect() {
	C.SDL_SetClipRect(s.ptr, nil)
}
Example #9
0
func (s *Surface) SetClipRect(rect image.Rectangle) {
	r := convertRect(rect)
	C.SDL_SetClipRect(s.ptr, &r)
}
Example #10
0
// Sets the clipping rectangle for a surface.
func (s *Surface) SetClipRect(r *Rect) {
	C.SDL_SetClipRect(s.cSurface, (*C.SDL_Rect)(cast(r)))
}
Example #11
0
//Loads the settings for this Pane onto the SDL Surface.
func (me *Canvas) load() {
	me.viewport.calcBounds()
	r := toSDL_Rect(me.viewport.bounds())
	C.SDL_SetClipRect(me.pane, &r)
}
Example #12
0
// Sets the clipping rectangle for the destination surface in a blit.
//
// If the clip rectangle is NULL, clipping will be disabled.
// If the clip rectangle doesn't intersect the surface, the function will
// return SDL_FALSE and blits will be completely clipped.  Otherwise the
// function returns SDL_TRUE and blits to the surface will be clipped to
// the intersection of the surface area and the clipping rectangle.
//
// Note that blits are automatically clipped to the edges of the source
// and destination surfaces.
func setClipRect(surface *C.SDL_Surface, rect *C.SDL_Rect) bool {
	return i2b(int(C.SDL_SetClipRect(surface, rect)))
}