Class: SFML::Cursor
- Inherits:
-
Object
- Object
- SFML::Cursor
- Defined in:
- ext/window/cursor.c,
ext/window/cursor.c
Overview
A native mouse cursor, either built from raw pixel data or one of the platform's built-in system cursors. Assign to Window#cursor= to apply.
Class Method Summary collapse
-
.from_pixels(pixels, size, hotspot) ⇒ Cursor
Creates a cursor from RGBA32 pixel data (+width * height * 4+ bytes, row-major, top-to-bottom).
-
.from_system(type) ⇒ Cursor
Creates a cursor from a native system cursor type (a Symbol, e.g.
:arrow,:hand,:crosshair; see the cursor type symbols this binding accepts).
Class Method Details
.from_pixels(pixels, size, hotspot) ⇒ Cursor
Creates a cursor from RGBA32 pixel data (+width * height * 4+ bytes, row-major, top-to-bottom).
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'ext/window/cursor.c', line 39
static VALUE Cursor_from_pixels(VALUE klass, VALUE rb_pixels, VALUE rb_size, VALUE rb_hotspot) {
sfVector2u size = vec2u_from_rb(rb_size);
size_t expected = (size_t)size.x * size.y * 4;
StringValue(rb_pixels);
if ((size_t)RSTRING_LEN(rb_pixels) < expected) {
rb_raise(rb_eArgError, "pixel data too short: expected %zu bytes", expected);
}
return Cursor_wrap(sfCursor_createFromPixels((const uint8_t*)RSTRING_PTR(rb_pixels), size,
vec2u_from_rb(rb_hotspot)));
}
|
.from_system(type) ⇒ Cursor
Creates a cursor from a native system cursor type (a Symbol, e.g.
:arrow, :hand, :crosshair; see the cursor type symbols this binding
accepts).
63 64 65 |
# File 'ext/window/cursor.c', line 63
static VALUE Cursor_from_system(VALUE klass, VALUE rb_type) {
return Cursor_wrap(sfCursor_createFromSystem(cursor_type_from_rb(rb_type)));
}
|