core :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Pointer :: defaultinit
core :: Object :: defaultinit
sdl2 :: SDLRect :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# A rectangle
extern class SDLRect `{SDL_Rect *`}
# Get a null rectangle (on the C side), should be used only internally
new nil `{ return NULL; `}
# Allocate the memory for a new `SDLRect`, it must then be freed with `free`
new malloc`{ return malloc(sizeof(SDL_Rect)); `}
# Allocate the memory for a new `SDLRect` and fill it with `x`, `y`, `w` and `h`
#
# As with `malloc`, the new instances must then be freed with `free`.
new (x, y, w, h: Int)
do
var rect = new SDLRect.malloc
rect.set(x, y, w, h)
return rect
end
# Set this instance's `x`, `y`, `w` and `h`
fun set(x, y, w, h: Int)
do
self.x = x
self.y = y
self.w = w
self.h = h
end
# X coordinate of the top left corner
fun x: Int `{ return self->x; `}
# Set the X coordinate of the top left corner
fun x=(val: Int) `{ self->x = val; `}
# Y coordinate of the top left corner
fun y: Int `{ return self->y; `}
# Set the Y coordinate of the top left corner
fun y=(val: Int) `{ self->y = val; `}
# Width of this rectangle
fun w: Int `{ return self->w; `}
# Set the width of this rectangle
fun w=(val: Int) `{ self->w = val; `}
# Height of this rectangle
fun h: Int `{ return self->h; `}
# Set the height of this rectangle
fun h=(val: Int) `{ self->h = val; `}
# TODO implement other `SDLRect` related methods:
#
# SDL_EnclosePoints
# SDL_HasIntersection
# SDL_IntersectRect
# SDL_IntersectRectAndLine
# SDL_PointInRect
# SDL_RectEmpty
# SDL_RectEquals
# SDL_UnionRect
end
lib/sdl2/sdl2_base.nit:472,1--533,3