2023-09-16 20:26:35 +02:00
|
|
|
function dynaSurf() constructor {
|
2023-09-08 21:09:09 +02:00
|
|
|
surfaces = [];
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static getAbsolutePos = function(_x, _y, _xs = 1, _ys = 1, _rot = 0) {
|
|
|
|
var _w = getWidth() * _xs;
|
|
|
|
var _h = getHeight() * _ys;
|
|
|
|
var _px = point_rotate(0, 0, _w / 2, _h / 2, _rot);
|
|
|
|
|
|
|
|
return [ _x - _px[0], _y - _px[1] ];
|
|
|
|
}
|
|
|
|
|
2024-03-31 05:36:11 +02:00
|
|
|
static getWidth = function() { return is_surface(array_safe_get_fast(surfaces, 0))? surface_get_width(surfaces[0]) : 1; }
|
|
|
|
static getHeight = function() { return is_surface(array_safe_get_fast(surfaces, 0))? surface_get_height(surfaces[0]) : 1; }
|
2024-04-08 07:13:46 +02:00
|
|
|
static getFormat = function() { return is_surface(array_safe_get_fast(surfaces, 0))? surface_get_format(surfaces[0]) : surface_rgba8unorm; }
|
2023-09-08 21:09:09 +02:00
|
|
|
|
|
|
|
static draw = function(_x = 0, _y = 0, _sx = 1, _sy = 1, _ang = 0, _col = c_white, _alp = 1) {}
|
|
|
|
static drawStretch = function(_x = 0, _y = 0, _w = 1, _h = 1, _ang = 0, _col = c_white, _alp = 1) {
|
|
|
|
var _sx = _w / getWidth();
|
|
|
|
var _sy = _h / getHeight();
|
|
|
|
|
|
|
|
draw(_x, _y, _sx, _sy, _ang, _col, _alp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawTile = function(_x = 0, _y = 0, _xs = 1, _ys = 1, _col = c_white, _alp = 1) {}
|
|
|
|
static drawPart = function(_l, _t, _w, _h, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alp = 1) {}
|
|
|
|
|
|
|
|
static onFree = function() {}
|
|
|
|
static free = function() {
|
|
|
|
for( var i = 0, n = array_length(surfaces); i < n; i++ )
|
|
|
|
surface_free_safe(surfaces[i]);
|
|
|
|
onFree();
|
|
|
|
}
|
|
|
|
|
2023-09-26 14:35:25 +02:00
|
|
|
static clone = function() { return noone; }
|
2023-09-11 16:08:58 +02:00
|
|
|
static destroy = function() {}
|
|
|
|
}
|
|
|
|
|
2023-09-16 20:26:35 +02:00
|
|
|
function compute_dynaSurf() : dynaSurf() constructor {
|
2023-09-11 16:08:58 +02:00
|
|
|
drawFn = noone;
|
|
|
|
widthFn = noone;
|
|
|
|
heightFn = noone;
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
useAbsolutePose = false;
|
|
|
|
|
2023-09-11 16:08:58 +02:00
|
|
|
static getWidth = function() { return widthFn? widthFn.eval() : 1; }
|
|
|
|
static getHeight = function() { return heightFn? heightFn.eval() : 1; }
|
|
|
|
|
|
|
|
static draw = function(_x = 0, _y = 0, _sx = 1, _sy = 1, _ang = 0, _col = c_white, _alp = 1) {
|
|
|
|
if(drawFn == noone) return;
|
2023-09-14 16:29:39 +02:00
|
|
|
var pos = useAbsolutePose? getAbsolutePos(_x, _y, _xs, _ys, _rot) : [ _x, _y ];
|
2023-09-13 15:06:39 +02:00
|
|
|
|
|
|
|
var params = {
|
2023-09-14 16:29:39 +02:00
|
|
|
x: pos[0],
|
|
|
|
y: pos[1],
|
2023-09-11 16:08:58 +02:00
|
|
|
sx: _sx,
|
|
|
|
sy: _sy,
|
|
|
|
angle: _ang,
|
|
|
|
color: _col,
|
|
|
|
alpha: _alp
|
2023-09-13 15:06:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
drawFn.eval(params);
|
2023-09-11 16:08:58 +02:00
|
|
|
}
|
2023-09-26 14:35:25 +02:00
|
|
|
|
|
|
|
static clone = function() {
|
|
|
|
var _surf = new compute_dynaSurf();
|
|
|
|
|
|
|
|
_surf.drawFn = drawFn;
|
|
|
|
_surf.widthFn = widthFn;
|
|
|
|
_surf.heightFn = heightFn;
|
|
|
|
|
|
|
|
return _surf;
|
|
|
|
}
|
2023-09-08 21:09:09 +02:00
|
|
|
}
|