mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
1.14.7.1 patch
This commit is contained in:
parent
dd9cb05c96
commit
cfbcdd393a
8 changed files with 127 additions and 54 deletions
|
@ -57,12 +57,17 @@ function array_safe_get(arr, index, def = 0, overflow = ARRAY_OVERFLOW._default)
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_push_create(arr, val) {
|
function array_push_create(arr, val) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_array(arr)) return [ val ];
|
if(!is_array(arr)) return [ val ];
|
||||||
array_push(arr, val);
|
array_push(arr, val);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_get_decimal(arr, index, color = false) {
|
function array_get_decimal(arr, index, color = false) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(!is_array(arr)) return 0;
|
||||||
if(frac(index) == 0) return array_safe_get(arr, index);
|
if(frac(index) == 0) return array_safe_get(arr, index);
|
||||||
|
|
||||||
var v0 = array_safe_get(arr, floor(index));
|
var v0 = array_safe_get(arr, floor(index));
|
||||||
|
@ -77,6 +82,7 @@ function array_exists(arr, val) {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
self.__temp_val = val;
|
self.__temp_val = val;
|
||||||
|
|
||||||
|
if(!is_array(arr)) return false;
|
||||||
return array_any(arr, function(_val, _ind) {
|
return array_any(arr, function(_val, _ind) {
|
||||||
return isEqual(_val, self.__temp_val);
|
return isEqual(_val, self.__temp_val);
|
||||||
});
|
});
|
||||||
|
@ -84,53 +90,70 @@ function array_exists(arr, val) {
|
||||||
|
|
||||||
function array_empty(arr) {
|
function array_empty(arr) {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
return array_length(arr) == 0;
|
return is_array(arr) && array_length(arr) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_find(arr, val) {
|
function array_find(arr, val) {
|
||||||
gml_pragma("forceinline");
|
gml_pragma("forceinline");
|
||||||
self.__temp_val = val;
|
self.__temp_val = val;
|
||||||
|
|
||||||
|
if(!is_array(arr)) return -1;
|
||||||
return array_find_index(arr, function(_val, _ind) {
|
return array_find_index(arr, function(_val, _ind) {
|
||||||
return isEqual(_val, self.__temp_val);
|
return isEqual(_val, self.__temp_val);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_remove(arr, val) {
|
function array_remove(arr, val) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(!is_array(arr)) return;
|
||||||
if(!array_exists(arr, val)) return;
|
if(!array_exists(arr, val)) return;
|
||||||
var ind = array_find(arr, val);
|
var ind = array_find(arr, val);
|
||||||
array_delete(arr, ind, 1);
|
array_delete(arr, ind, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_push_unique(arr, val) {
|
function array_push_unique(arr, val) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(!is_array(arr)) return;
|
||||||
if(array_exists(arr, val)) return;
|
if(array_exists(arr, val)) return;
|
||||||
array_push(arr, val);
|
array_push(arr, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function array_insert_unique(arr, ind, val) {
|
function array_insert_unique(arr, ind, val) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(!is_array(arr)) return;
|
||||||
if(array_exists(arr, val)) return;
|
if(array_exists(arr, val)) return;
|
||||||
array_insert(arr, ind, val);
|
array_insert(arr, ind, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_append(arr, arr0) {
|
function array_append(arr, arr0) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(!is_array(arr)) return arr;
|
||||||
|
if(!is_array(arr0)) return arr;
|
||||||
|
|
||||||
for( var i = 0, n = array_length(arr0); i < n; i++ )
|
for( var i = 0, n = array_length(arr0); i < n; i++ )
|
||||||
array_push(arr, arr0[i]);
|
array_push(arr, arr0[i]);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_merge() {
|
function array_merge() {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
var arr = [];
|
var arr = [];
|
||||||
for( var i = 0; i < argument_count; i++ ) {
|
for( var i = 0; i < argument_count; i++ )
|
||||||
array_append(arr, argument[i]);
|
array_append(arr, argument[i]);
|
||||||
}
|
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_clone(arr) {
|
function array_clone(arr) {
|
||||||
if(!is_array(arr))
|
gml_pragma("forceinline");
|
||||||
return arr;
|
|
||||||
|
if(!is_array(arr)) return arr;
|
||||||
|
|
||||||
var _res = [];
|
var _res = [];
|
||||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||||
|
@ -139,24 +162,30 @@ function array_clone(arr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_min(arr) {
|
function array_min(arr) {
|
||||||
if(array_length(arr) == 0) return 0;
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(!is_array(arr) || array_length(arr) == 0) return 0;
|
||||||
|
|
||||||
var mn = arr[0];
|
var mn = arr[0];
|
||||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||||
mn = min(mn, arr[i]);
|
mn = min(mn, arr[i]);
|
||||||
return mn;
|
return mn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_max(arr) {
|
function array_max(arr) {
|
||||||
if(array_length(arr) == 0) return 0;
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
if(!is_array(arr) || array_length(arr) == 0) return 0;
|
||||||
|
|
||||||
var mx = arr[0];
|
var mx = arr[0];
|
||||||
for( var i = 0, n = array_length(arr); i < n; i++ )
|
for( var i = 0, n = array_length(arr); i < n; i++ )
|
||||||
mx = max(mx, arr[i]);
|
mx = max(mx, arr[i]);
|
||||||
return mx;
|
return mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
function array_get_dimension(arr) {
|
function array_get_dimension(arr) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
return is_array(arr)? array_length(arr) : 1;
|
return is_array(arr)? array_length(arr) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ function buffer_get_color(buffer, _x, _y, w, h) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buffer_get_string(buffer, text = true) {
|
function buffer_get_string(buffer, text = true, limit = 400) {
|
||||||
buffer_seek(buffer, buffer_seek_start, 0);
|
buffer_seek(buffer, buffer_seek_start, 0);
|
||||||
var len = buffer_get_size(buffer);
|
var len = min(limit, buffer_get_size(buffer));
|
||||||
var ss = "";
|
var ss = "";
|
||||||
|
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
var _r = buffer_read(buffer, buffer_u8);
|
var _r = buffer_read(buffer, buffer_u8);
|
||||||
|
|
|
@ -163,7 +163,7 @@ function draw_tooltip_atlas(atlas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw_tooltip_buffer(buff) {
|
function draw_tooltip_buffer(buff) {
|
||||||
var txt = buffer_get_string(buff, false);
|
var txt = buffer_get_string(buff, false, 400);
|
||||||
var len = string_length(txt);
|
var len = string_length(txt);
|
||||||
|
|
||||||
if(len > 400) txt = string_copy(txt, 1, 400);
|
if(len > 400) txt = string_copy(txt, 1, 400);
|
||||||
|
|
|
@ -92,10 +92,10 @@
|
||||||
|
|
||||||
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER;
|
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER;
|
||||||
|
|
||||||
VERSION = 11470;
|
VERSION = 11471;
|
||||||
SAVE_VERSION = 11470;
|
SAVE_VERSION = 11470;
|
||||||
VERSION_STRING = "1.14.7";
|
VERSION_STRING = "1.14.7.1";
|
||||||
BUILD_NUMBER = 11470;
|
BUILD_NUMBER = 11471;
|
||||||
|
|
||||||
globalvar APPEND_MAP;
|
globalvar APPEND_MAP;
|
||||||
APPEND_MAP = ds_map_create();
|
APPEND_MAP = ds_map_create();
|
||||||
|
@ -233,6 +233,4 @@
|
||||||
|
|
||||||
#region debug
|
#region debug
|
||||||
global.FLAG = {};
|
global.FLAG = {};
|
||||||
|
|
||||||
global.FLAG.expression_debug = false;
|
|
||||||
#endregion
|
#endregion
|
|
@ -112,11 +112,11 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
var _dim = inputs[| 0].getValue();
|
var _dim = inputs[| 0].getValue();
|
||||||
var cDep = attrDepth();
|
var cDep = attrDepth();
|
||||||
|
|
||||||
if(!is_surface(canvas_surface))
|
if(!is_surface(canvas_surface)) {
|
||||||
canvas_surface = surface_create_from_buffer(_dim[0], _dim[1], canvas_buffer);
|
canvas_surface = surface_create_from_buffer(_dim[0], _dim[1], canvas_buffer);
|
||||||
else if(surface_get_width(canvas_surface) != _dim[0] || surface_get_height(canvas_surface) != _dim[1]) {
|
} else if(surface_get_width(canvas_surface) != _dim[0] || surface_get_height(canvas_surface) != _dim[1]) {
|
||||||
buffer_delete(canvas_buffer);
|
buffer_delete(canvas_buffer);
|
||||||
canvas_buffer = buffer_create(_dim[0] * _dim[1] * 4, buffer_fixed, 4);
|
canvas_buffer = buffer_create(_dim[0] * _dim[1] * 4, buffer_fixed, 4);
|
||||||
canvas_surface = surface_size_to(canvas_surface, _dim[0], _dim[1]);
|
canvas_surface = surface_size_to(canvas_surface, _dim[0], _dim[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1053,7 +1053,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
cache_value[0] = false;
|
cache_value[0] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getValue = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0, useCache = true) {
|
static getValue = function(_time = PROJECT.animator.current_frame, applyUnit = true, arrIndex = 0, useCache = false) {
|
||||||
if(type == VALUE_TYPE.trigger)
|
if(type == VALUE_TYPE.trigger)
|
||||||
useCache = false;
|
useCache = false;
|
||||||
|
|
||||||
|
@ -1064,6 +1064,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
cache_hit &= cache_value[2] != undefined;
|
cache_hit &= cache_value[2] != undefined;
|
||||||
cache_hit &= connect_type == JUNCTION_CONNECT.input;
|
cache_hit &= connect_type == JUNCTION_CONNECT.input;
|
||||||
cache_hit &= unit.reference == noone || unit.mode == VALUE_UNIT.constant;
|
cache_hit &= unit.reference == noone || unit.mode == VALUE_UNIT.constant;
|
||||||
|
cache_hit &= !expUse;
|
||||||
|
|
||||||
if(cache_hit) {
|
if(cache_hit) {
|
||||||
global.cache_hit++;
|
global.cache_hit++;
|
||||||
|
@ -1161,10 +1162,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||||
//print($"========== EXPRESSION CALLED ==========");
|
//print($"========== EXPRESSION CALLED ==========");
|
||||||
//print(debug_get_callstack(8));
|
//print(debug_get_callstack(8));
|
||||||
|
|
||||||
//printIf(global.FLAG.expression_debug, "==================== EVAL BEGIN ====================");
|
|
||||||
if(global.EVALUATE_HEAD != noone && global.EVALUATE_HEAD == self) {
|
if(global.EVALUATE_HEAD != noone && global.EVALUATE_HEAD == self) {
|
||||||
//noti_warning($"Expression evaluation error : recursive call detected.");
|
//noti_warning($"Expression evaluation error : recursive call detected.");
|
||||||
} else {
|
} else {
|
||||||
|
printIf(global.LOG_EXPRESSION, "==================== EVAL BEGIN {expTree} ====================");
|
||||||
|
|
||||||
global.EVALUATE_HEAD = self;
|
global.EVALUATE_HEAD = self;
|
||||||
var params = {
|
var params = {
|
||||||
name: name,
|
name: name,
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#region data
|
#region data
|
||||||
|
global.LOG_EXPRESSION = false;
|
||||||
|
|
||||||
global.EVALUATE_HEAD = noone;
|
global.EVALUATE_HEAD = noone;
|
||||||
|
|
||||||
global.EQUATION_PRES = ds_map_create();
|
global.EQUATION_PRES = ds_map_create();
|
||||||
|
@ -162,7 +164,7 @@ function functionStringClean(fx) {
|
||||||
if(condition == noone) return 0;
|
if(condition == noone) return 0;
|
||||||
|
|
||||||
var res = condition.eval(params);
|
var res = condition.eval(params);
|
||||||
printIf(global.FLAG.expression_debug, $"<<<<<< IF {res} >>>>>>");
|
printIf(global.LOG_EXPRESSION, $"<<<<<< IF {res} >>>>>>");
|
||||||
|
|
||||||
if(res) return if_true == noone? 0 : if_true.eval(params);
|
if(res) return if_true == noone? 0 : if_true.eval(params);
|
||||||
else return if_false == noone? 0 : if_false.eval(params);
|
else return if_false == noone? 0 : if_false.eval(params);
|
||||||
|
@ -210,16 +212,16 @@ function functionStringClean(fx) {
|
||||||
static eval = function(params = {}) {
|
static eval = function(params = {}) {
|
||||||
if(itr_array) {
|
if(itr_array) {
|
||||||
var _arr = cond_arr.eval(params);
|
var _arr = cond_arr.eval(params);
|
||||||
printIf(global.FLAG.expression_debug, $"<<<<<< FOR EACH {_arr} >>>>>>");
|
printIf(global.LOG_EXPRESSION, $"<<<<<< FOR EACH {_arr} >>>>>>");
|
||||||
for( var i = 0, n = array_length(_arr); i < n; i++ ) {
|
for( var i = 0, n = array_length(_arr); i < n; i++ ) {
|
||||||
var val = _arr[i];
|
var val = _arr[i];
|
||||||
params[$ cond_iter] = val;
|
params[$ cond_iter] = val;
|
||||||
|
|
||||||
printIf(global.FLAG.expression_debug, $"<< ITER {i}: {cond_iter} = {val} >>");
|
printIf(global.LOG_EXPRESSION, $"<< ITER {i}: {cond_iter} = {val} >>");
|
||||||
action.eval(params);
|
action.eval(params);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printIf(global.FLAG.expression_debug, "<< FOR >>");
|
printIf(global.LOG_EXPRESSION, "<< FOR >>");
|
||||||
cond_init.eval(params);
|
cond_init.eval(params);
|
||||||
|
|
||||||
while(cond_term.eval(params)) {
|
while(cond_term.eval(params)) {
|
||||||
|
@ -252,7 +254,7 @@ function functionStringClean(fx) {
|
||||||
|
|
||||||
if(is_string(val)) val = string_trim(val);
|
if(is_string(val)) val = string_trim(val);
|
||||||
|
|
||||||
//printIf(global.FLAG.expression_debug, $" [ get struct {params}[{val}] ]");
|
//printIf(global.LOG_EXPRESSION, $" [ get struct {params}[{val}] ]");
|
||||||
|
|
||||||
if(struct_has(params, val))
|
if(struct_has(params, val))
|
||||||
return struct_try_get(params, val);
|
return struct_try_get(params, val);
|
||||||
|
@ -337,8 +339,8 @@ function functionStringClean(fx) {
|
||||||
_l[i] = getVal(l[i], params);
|
_l[i] = getVal(l[i], params);
|
||||||
|
|
||||||
var res = _ev(_l);
|
var res = _ev(_l);
|
||||||
printIf(global.FLAG.expression_debug, $"Function {symbol}{_l} = {res}");
|
printIf(global.LOG_EXPRESSION, $"Function {symbol}{_l} = {res}");
|
||||||
printIf(global.FLAG.expression_debug, "====================");
|
printIf(global.LOG_EXPRESSION, "====================");
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -382,11 +384,11 @@ function functionStringClean(fx) {
|
||||||
} else
|
} else
|
||||||
res = eval_real(v1, v2);
|
res = eval_real(v1, v2);
|
||||||
|
|
||||||
printIf(global.FLAG.expression_debug, $"|{v1}|{symbol}|{v2}| = {res}");
|
printIf(global.LOG_EXPRESSION, $"|{v1}|{symbol}|{v2}| = {res}");
|
||||||
printIf(global.FLAG.expression_debug, $"symbol : {symbol}");
|
printIf(global.LOG_EXPRESSION, $"symbol : {symbol}");
|
||||||
printIf(global.FLAG.expression_debug, $"l : | {typeof(l)} |{l}|");
|
printIf(global.LOG_EXPRESSION, $"l : | {typeof(l)} |{l}|");
|
||||||
printIf(global.FLAG.expression_debug, $"r : | {typeof(r)} |{r}|");
|
printIf(global.LOG_EXPRESSION, $"r : | {typeof(r)} |{r}|");
|
||||||
printIf(global.FLAG.expression_debug, "====================");
|
printIf(global.LOG_EXPRESSION, "====================");
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -535,7 +537,7 @@ function functionStringClean(fx) {
|
||||||
var _ch = "";
|
var _ch = "";
|
||||||
var in_str = false;
|
var in_str = false;
|
||||||
|
|
||||||
printIf(global.FLAG.expression_debug, $"===== Evaluating function: {fx} =====");
|
printIf(global.LOG_EXPRESSION, $"===== Evaluating function: {fx} =====");
|
||||||
|
|
||||||
while(l <= len) {
|
while(l <= len) {
|
||||||
ch = string_char_at(fx, l);
|
ch = string_char_at(fx, l);
|
||||||
|
@ -668,8 +670,8 @@ function functionStringClean(fx) {
|
||||||
if(!is_struct(tree))
|
if(!is_struct(tree))
|
||||||
tree = new __funcTree("", tree);
|
tree = new __funcTree("", tree);
|
||||||
|
|
||||||
//print(tree);
|
printIf(global.LOG_EXPRESSION, tree);
|
||||||
//print("");
|
printIf(global.LOG_EXPRESSION, "");
|
||||||
|
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//draw
|
//draw
|
||||||
function draw_surface_safe(surface, _x = 0, _y = 0) {
|
function draw_surface_safe(surface, _x = 0, _y = 0) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
|
|
||||||
__channel_pre(surface);
|
__channel_pre(surface);
|
||||||
|
@ -7,6 +9,8 @@ function draw_surface_safe(surface, _x = 0, _y = 0) {
|
||||||
__channel_pos(surface);
|
__channel_pos(surface);
|
||||||
}
|
}
|
||||||
function draw_surface_stretched_safe(surface, _x, _y, _w, _h) {
|
function draw_surface_stretched_safe(surface, _x, _y, _w, _h) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
|
|
||||||
__channel_pre(surface);
|
__channel_pre(surface);
|
||||||
|
@ -14,6 +18,8 @@ function draw_surface_stretched_safe(surface, _x, _y, _w, _h) {
|
||||||
__channel_pos(surface);
|
__channel_pos(surface);
|
||||||
}
|
}
|
||||||
function draw_surface_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) {
|
function draw_surface_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
|
|
||||||
__channel_pre(surface);
|
__channel_pre(surface);
|
||||||
|
@ -21,6 +27,8 @@ function draw_surface_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col
|
||||||
__channel_pos(surface);
|
__channel_pos(surface);
|
||||||
}
|
}
|
||||||
function draw_surface_tiled_safe(surface, _x, _y) {
|
function draw_surface_tiled_safe(surface, _x, _y) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
|
|
||||||
__channel_pre(surface);
|
__channel_pre(surface);
|
||||||
|
@ -28,6 +36,8 @@ function draw_surface_tiled_safe(surface, _x, _y) {
|
||||||
__channel_pos(surface);
|
__channel_pos(surface);
|
||||||
}
|
}
|
||||||
function draw_surface_tiled_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _col = c_white, _alpha = 1) {
|
function draw_surface_tiled_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _col = c_white, _alpha = 1) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
|
|
||||||
__channel_pre(surface);
|
__channel_pre(surface);
|
||||||
|
@ -35,6 +45,8 @@ function draw_surface_tiled_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _col = c
|
||||||
__channel_pos(surface);
|
__channel_pos(surface);
|
||||||
}
|
}
|
||||||
function draw_surface_part_ext_safe(surface, _l, _t, _w, _h, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) {
|
function draw_surface_part_ext_safe(surface, _l, _t, _w, _h, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
|
|
||||||
__channel_pre(surface);
|
__channel_pre(surface);
|
||||||
|
@ -46,6 +58,8 @@ function draw_surface_part_ext_safe(surface, _l, _t, _w, _h, _x, _y, _xs = 1, _y
|
||||||
#macro __surface_free surface_free
|
#macro __surface_free surface_free
|
||||||
|
|
||||||
function surface_free_safe(surface) {
|
function surface_free_safe(surface) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
__surface_free(surface);
|
__surface_free(surface);
|
||||||
}
|
}
|
||||||
|
@ -123,6 +137,8 @@ function surface_verify(surf, w, h, format = surface_rgba8unorm) {
|
||||||
|
|
||||||
//get
|
//get
|
||||||
function surface_get_pixel(surface, _x, _y) {
|
function surface_get_pixel(surface, _x, _y) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
var f = surface_get_format(surface);
|
var f = surface_get_format(surface);
|
||||||
var px = surface_getpixel(surface, _x, _y);
|
var px = surface_getpixel(surface, _x, _y);
|
||||||
|
@ -132,6 +148,8 @@ function surface_get_pixel(surface, _x, _y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_get_pixel_ext(surface, _x, _y) {
|
function surface_get_pixel_ext(surface, _x, _y) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
var f = surface_get_format(surface);
|
var f = surface_get_format(surface);
|
||||||
var px = surface_getpixel_ext(surface, _x, _y);
|
var px = surface_getpixel_ext(surface, _x, _y);
|
||||||
|
@ -141,29 +159,29 @@ function surface_get_pixel_ext(surface, _x, _y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//create
|
//create
|
||||||
function surface_create_empty(w, h) {
|
function surface_create_empty(w, h, format = surface_rgba8unorm) {
|
||||||
var s = surface_create(w, h);
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
|
var s = surface_create(w, h, format);
|
||||||
surface_clear(s);
|
surface_clear(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_create_size(surface, format = surface_rgba8unorm) {
|
function surface_create_size(surface, format = surface_rgba8unorm) {
|
||||||
var s = surface_create_valid(surface_get_width(surface), surface_get_height(surface), format);
|
gml_pragma("forceinline");
|
||||||
surface_set_target(s);
|
|
||||||
DRAW_CLEAR
|
return surface_create_valid(surface_get_width(surface), surface_get_height(surface), format);
|
||||||
surface_reset_target();
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_create_valid(w, h, format = surface_rgba8unorm) {
|
function surface_create_valid(w, h, format = surface_rgba8unorm) {
|
||||||
var s = surface_create(surface_valid_size(w), surface_valid_size(h), format);
|
gml_pragma("forceinline");
|
||||||
surface_set_target(s);
|
|
||||||
DRAW_CLEAR
|
return surface_create_empty(surface_valid_size(w), surface_valid_size(h), format);
|
||||||
surface_reset_target();
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_create_from_buffer(w, h, buff, format = surface_rgba8unorm) {
|
function surface_create_from_buffer(w, h, buff, format = surface_rgba8unorm) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(buff < 0) return;
|
if(buff < 0) return;
|
||||||
var s = surface_create_valid(surface_valid_size(w), surface_valid_size(h), format);
|
var s = surface_create_valid(surface_valid_size(w), surface_valid_size(h), format);
|
||||||
buffer_set_surface(buff, s, 0);
|
buffer_set_surface(buff, s, 0);
|
||||||
|
@ -252,10 +270,14 @@ function surface_size_to(surface, width, height, format = noone) {
|
||||||
if(ww == width && hh == height) return surface;
|
if(ww == width && hh == height) return surface;
|
||||||
|
|
||||||
surface_resize(surface, width, height);
|
surface_resize(surface, width, height);
|
||||||
|
surface_clear(surface);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_clear(surface) {
|
function surface_clear(surface) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return;
|
if(!is_surface(surface)) return;
|
||||||
surface_set_target(surface);
|
surface_set_target(surface);
|
||||||
DRAW_CLEAR
|
DRAW_CLEAR
|
||||||
|
@ -263,6 +285,8 @@ function surface_clear(surface) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_copy_from(dst, src, format = noone) {
|
function surface_copy_from(dst, src, format = noone) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
surface_set_target(dst);
|
surface_set_target(dst);
|
||||||
DRAW_CLEAR
|
DRAW_CLEAR
|
||||||
BLEND_OVERRIDE;
|
BLEND_OVERRIDE;
|
||||||
|
@ -272,6 +296,8 @@ function surface_copy_from(dst, src, format = noone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_clone(surface, source = noone, format = noone) {
|
function surface_clone(surface, source = noone, format = noone) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surface)) return noone;
|
if(!is_surface(surface)) return noone;
|
||||||
|
|
||||||
source = surface_verify(source, surface_get_width(surface), surface_get_height(surface), format == noone? surface_get_format(surface) : format);
|
source = surface_verify(source, surface_get_width(surface), surface_get_height(surface), format == noone? surface_get_format(surface) : format);
|
||||||
|
@ -288,6 +314,8 @@ function surface_clone(surface, source = noone, format = noone) {
|
||||||
|
|
||||||
//in-place modification
|
//in-place modification
|
||||||
function surface_stretch(surf, _w, _h) {
|
function surface_stretch(surf, _w, _h) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surf)) return noone;
|
if(!is_surface(surf)) return noone;
|
||||||
|
|
||||||
_w = surface_valid_size(_w);
|
_w = surface_valid_size(_w);
|
||||||
|
@ -304,6 +332,8 @@ function surface_stretch(surf, _w, _h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_mirror(surf, _h, _v) {
|
function surface_mirror(surf, _h, _v) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(surf)) return noone;
|
if(!is_surface(surf)) return noone;
|
||||||
var _surf = surface_create_size(surf);
|
var _surf = surface_create_size(surf);
|
||||||
|
|
||||||
|
@ -322,6 +352,8 @@ function surface_mirror(surf, _h, _v) {
|
||||||
|
|
||||||
//others
|
//others
|
||||||
function surface_copy_size(dest, source, format = noone) {
|
function surface_copy_size(dest, source, format = noone) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_surface(dest)) return;
|
if(!is_surface(dest)) return;
|
||||||
if(!is_surface(source)) return;
|
if(!is_surface(source)) return;
|
||||||
|
|
||||||
|
@ -334,6 +366,8 @@ function surface_copy_size(dest, source, format = noone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_valid_size(s) {
|
function surface_valid_size(s) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(is_infinity(s)) return 1;
|
if(is_infinity(s)) return 1;
|
||||||
s = toNumber(s);
|
s = toNumber(s);
|
||||||
if(!is_real(s)) return 1;
|
if(!is_real(s)) return 1;
|
||||||
|
@ -341,6 +375,8 @@ function surface_valid_size(s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_array_free(arr) {
|
function surface_array_free(arr) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
if(!is_array(arr)) {
|
if(!is_array(arr)) {
|
||||||
if(is_surface(arr)) surface_free(arr);
|
if(is_surface(arr)) surface_free(arr);
|
||||||
return;
|
return;
|
||||||
|
@ -367,6 +403,8 @@ function surface_array_clone(arr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_array_serialize(arr) {
|
function surface_array_serialize(arr) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
var _arr = __surface_array_serialize(arr);
|
var _arr = __surface_array_serialize(arr);
|
||||||
return json_stringify(_arr);
|
return json_stringify(_arr);
|
||||||
}
|
}
|
||||||
|
@ -393,6 +431,8 @@ function __surface_array_serialize(arr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_array_deserialize(arr, index = -1) {
|
function surface_array_deserialize(arr, index = -1) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
var _arr = json_try_parse(arr);
|
var _arr = json_try_parse(arr);
|
||||||
return index == -1? __surface_array_deserialize(_arr) : __surface_array_deserialize(_arr[index]);
|
return index == -1? __surface_array_deserialize(_arr) : __surface_array_deserialize(_arr[index]);
|
||||||
}
|
}
|
||||||
|
@ -448,6 +488,8 @@ function surface_format_get_bytes(format) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_get_size(surface) {
|
function surface_get_size(surface) {
|
||||||
|
gml_pragma("forceinline");
|
||||||
|
|
||||||
var sw = surface_get_width(surface);
|
var sw = surface_get_width(surface);
|
||||||
var sh = surface_get_height(surface);
|
var sh = surface_get_height(surface);
|
||||||
var sz = sw * sh * surface_format_get_bytes(surface_get_format(surface));
|
var sz = sw * sh * surface_format_get_bytes(surface_get_format(surface));
|
||||||
|
|
Loading…
Reference in a new issue