mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-27 05:19:08 +01:00
atlas simp
This commit is contained in:
parent
00e3c1551b
commit
e22b4f4597
1 changed files with 65 additions and 105 deletions
|
@ -1,179 +1,139 @@
|
||||||
function Atlas() constructor {}
|
function Atlas(_surface, _x = 0, _y = 0, _rot = 0, _sx = 1, _sy = 1, _blend = c_white, _alpha = 1) constructor {
|
||||||
|
surface = _surface;
|
||||||
function SurfaceAtlasFast(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend = c_white, alpha = 1) : Atlas() constructor {
|
x = _x;
|
||||||
self.surface = surface;
|
y = _y;
|
||||||
self.x = _x;
|
rotation = _rot;
|
||||||
self.y = _y;
|
sx = _sx;
|
||||||
self.rotation = rot;
|
sy = _sy;
|
||||||
self.sx = sx;
|
blend = _blend;
|
||||||
self.sy = sy;
|
alpha = _alpha;
|
||||||
self.blend = blend;
|
|
||||||
self.alpha = alpha;
|
|
||||||
|
|
||||||
w = 1;
|
w = 1;
|
||||||
h = 1;
|
h = 1;
|
||||||
|
|
||||||
static set = function(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend = c_white, alpha = 1, setDim = true) {
|
static getSurface = function() /*=>*/ {return surface};
|
||||||
|
|
||||||
|
static set = function(_surface, _x = 0, _y = 0, _rot = 0, _sx = 1, _sy = 1, _blend = c_white, _alpha = 1, setDim = true) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
self.surface = surface;
|
surface = _surface;
|
||||||
self.x = _x;
|
x = _x;
|
||||||
self.y = _y;
|
y = _y;
|
||||||
self.rotation = rot;
|
rotation = _rot;
|
||||||
self.sx = sx;
|
sx = _sx;
|
||||||
self.sy = sy;
|
sy = _sy;
|
||||||
self.blend = blend;
|
blend = _blend;
|
||||||
self.alpha = alpha;
|
alpha = _alpha;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSurface = function() {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
return surface;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SurfaceAtlas(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend = c_white, alpha = 1, setDim = true) : Atlas() constructor {
|
function SurfaceAtlasFast(_surface, _x = 0, _y = 0, _rot = 0, _sx = 1, _sy = 1, _blend = c_white, _alpha = 1) : Atlas(_surface, _x, _y, _rot, _sx, _sy, _blend, _alpha) constructor {}
|
||||||
self.surface = new Surface(surface);
|
function SurfaceAtlas( _surface, _x = 0, _y = 0, _rot = 0, _sx = 1, _sy = 1, _blend = c_white, _alpha = 1, setDim = true) : Atlas(_surface, _x, _y, _rot, _sx, _sy, _blend, _alpha) constructor {
|
||||||
self.x = _x;
|
surface = new Surface(_surface);
|
||||||
self.y = _y;
|
w = setDim? surface_get_width_safe(surface.surface) : 1;
|
||||||
self.rotation = rot;
|
h = setDim? surface_get_height_safe(surface.surface) : 1;
|
||||||
self.sx = sx;
|
|
||||||
self.sy = sy;
|
|
||||||
self.blend = blend;
|
|
||||||
self.alpha = alpha;
|
|
||||||
|
|
||||||
w = 1;
|
|
||||||
h = 1;
|
|
||||||
|
|
||||||
if(setDim) {
|
|
||||||
w = surface_get_width_safe(surface);
|
|
||||||
h = surface_get_height_safe(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
oriSurf = noone;
|
oriSurf = noone;
|
||||||
oriSurf_w = w;
|
oriSurf_w = w;
|
||||||
oriSurf_h = h;
|
oriSurf_h = h;
|
||||||
|
|
||||||
static set = function(surface, _x = 0, _y = 0, rot = 0, sx = 1, sy = 1, blend = c_white, alpha = 1, setDim = true) {
|
static getSurface = function() /*=>*/ {return surface.get()};
|
||||||
|
|
||||||
|
__base_set = set;
|
||||||
|
static set = function(_surface, _x = 0, _y = 0, _rot = 0, _sx = 1, _sy = 1, _blend = c_white, _alpha = 1, setDim = true) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
self.surface = new Surface(surface);
|
__base_set(_surface, _x, _y, _rot, _sx, _sy, _blend, _alpha);
|
||||||
self.x = _x;
|
surface = new Surface(_surface);
|
||||||
self.y = _y;
|
|
||||||
self.rotation = rot;
|
|
||||||
self.sx = sx;
|
|
||||||
self.sy = sy;
|
|
||||||
self.blend = blend;
|
|
||||||
self.alpha = alpha;
|
|
||||||
|
|
||||||
w = 1;
|
w = setDim? surface_get_width_safe(surface.surface) : 1;
|
||||||
h = 1;
|
h = setDim? surface_get_height_safe(surface.surface) : 1;
|
||||||
|
|
||||||
if(setDim) {
|
|
||||||
w = surface_get_width_safe(surface);
|
|
||||||
h = surface_get_height_safe(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static setOrginalSurface = function(surf) {
|
static setOrginalSurface = function(_surface) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
oriSurf = surf;
|
oriSurf = _surface;
|
||||||
oriSurf_w = surface_get_width_safe(surf);
|
oriSurf_w = surface_get_width_safe(_surface);
|
||||||
oriSurf_h = surface_get_height_safe(surf);
|
oriSurf_h = surface_get_height_safe(_surface);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getSurface = function() {
|
static setSurface = function(_surface) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
return surface.get();
|
self.surface.set(_surface);
|
||||||
}
|
|
||||||
|
|
||||||
static setSurface = function(surface) {
|
|
||||||
INLINE
|
|
||||||
|
|
||||||
self.surface.set(surface);
|
w = surface_get_width_safe(_surface);
|
||||||
|
h = surface_get_height_safe(_surface);
|
||||||
w = surface_get_width_safe(surface);
|
|
||||||
h = surface_get_height_safe(surface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static draw = function() {
|
static draw = function() {
|
||||||
INLINE
|
|
||||||
|
|
||||||
draw_surface_ext_safe(surface.get(), x, y, sx, sy, rotation, blend, alpha);
|
draw_surface_ext_safe(surface.get(), x, y, sx, sy, rotation, blend, alpha);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static clone = function(_surface = false) {
|
static clone = function(_cloneSurf = false) {
|
||||||
INLINE
|
|
||||||
|
|
||||||
var _surf = getSurface();
|
var _surf = getSurface();
|
||||||
if(_surface) _surf = surface_clone(_surf);
|
if(_cloneSurf) _surf = surface_clone(_surf);
|
||||||
|
|
||||||
return new SurfaceAtlas(_surf, x, y, rotation, sx, sy, blend, alpha);
|
return new SurfaceAtlas(_surf, x, y, rotation, sx, sy, blend, alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Surface(surface) constructor {
|
function Surface(_surf) constructor {
|
||||||
static set = function(surface) {
|
static set = function(_surf) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
self.surface = surface;
|
self.surface = _surf;
|
||||||
w = surface_get_width_safe(surface);
|
w = surface_get_width_safe(_surf);
|
||||||
h = surface_get_height_safe(surface);
|
h = surface_get_height_safe(_surf);
|
||||||
format = surface_get_format(surface);
|
format = surface_get_format(_surf);
|
||||||
}
|
}
|
||||||
set(surface);
|
|
||||||
|
|
||||||
static get = function() { INLINE return surface; }
|
set(_surf);
|
||||||
|
|
||||||
static isValid = function() { INLINE return is_surface(surface); }
|
static get = function() /*=>*/ {return surface};
|
||||||
|
static isValid = function() /*=>*/ {return is_surface(surface)};
|
||||||
|
|
||||||
static resize = function(w, h) {
|
static resize = function(_w, _h) {
|
||||||
INLINE
|
INLINE
|
||||||
|
surface_resize(surface, _w, _h);
|
||||||
surface_resize(surface, w, h);
|
w = _w; h = _h;
|
||||||
self.w = w;
|
|
||||||
self.h = h;
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static draw = function(x, y, xs = 1, ys = 1, rot = 0, col = c_white, alpha = 1) {
|
static draw = function(_x, _y, xs = 1, ys = 1, rot = 0, col = c_white, alpha = 1) {
|
||||||
INLINE
|
INLINE
|
||||||
|
draw_surface_ext_safe(surface, _x, _y, xs, ys, rot, col, alpha);
|
||||||
draw_surface_ext_safe(surface, x, y, xs, ys, rot, col, alpha);
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static drawStretch = function(x, y, w = 1, h = 1, rot = 0, col = c_white, alpha = 1) {
|
static drawStretch = function(_x, _y, _w = 1, _h = 1, rot = 0, col = c_white, alpha = 1) {
|
||||||
INLINE
|
INLINE
|
||||||
|
draw_surface_stretched_ext(surface, _x, _y, _w, _h, col, alpha);
|
||||||
draw_surface_stretched_ext(surface, x, y, w, h, col, alpha);
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static destroy = function() {
|
static destroy = function() {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
if(!isValid()) return;
|
if(!isValid()) return;
|
||||||
surface_free(surface);
|
surface_free(surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Surface_get(surface) {
|
function Surface_get(_surf) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
if(is_real(surface))
|
if(is_real(_surf))
|
||||||
return surface;
|
return _surf;
|
||||||
if(is_struct(surface) && struct_has(surface, "surface"))
|
if(is_struct(_surf) && struct_has(_surf, "surface"))
|
||||||
return surface.surface;
|
return _surf.surface;
|
||||||
|
|
||||||
return noone;
|
return noone;
|
||||||
}
|
}
|
Loading…
Reference in a new issue