mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
- [Path] Previewing node now set proper preview area.
This commit is contained in:
parent
44a03c57df
commit
e6d39113c2
3 changed files with 34 additions and 7 deletions
|
@ -102,6 +102,20 @@ function __BBOX() constructor {
|
|||
return self;
|
||||
}
|
||||
|
||||
static fromBoundingBox = function(box) {
|
||||
self.x0 = box.minx;
|
||||
self.x1 = box.maxx;
|
||||
self.y0 = box.miny;
|
||||
self.y1 = box.maxy;
|
||||
|
||||
self.xc = (x0 + x1) / 2;
|
||||
self.yc = (y0 + y1) / 2;
|
||||
self.w = x1 - x0;
|
||||
self.h = y1 - y0;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static toSquare = function() {
|
||||
var _span = min(w, h) / 2;
|
||||
|
||||
|
|
|
@ -856,8 +856,9 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
lengthAccs[i] = lengthTotal;
|
||||
}
|
||||
|
||||
var minx = boundary.minx - 8, miny = boundary.miny - 8;
|
||||
var maxx = boundary.maxx + 8, maxy = boundary.maxy + 8;
|
||||
var pad = min(8, abs(boundary.maxx - boundary.minx) * 0.1, abs(boundary.maxy - boundary.miny) * 0.1);
|
||||
var minx = boundary.minx - pad, miny = boundary.miny - pad;
|
||||
var maxx = boundary.maxx + pad, maxy = boundary.maxy + pad;
|
||||
var rngx = maxx - minx, rngy = maxy - miny;
|
||||
var prev_s = 128;
|
||||
var _surf = surface_create(prev_s, prev_s);
|
||||
|
@ -1050,4 +1051,6 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
gpu_set_tex_filter(false);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static getPreviewBoundingBox = function() { return BBOX().fromBoundingBox(boundary); }
|
||||
}
|
|
@ -633,20 +633,30 @@ function Panel_Preview() : PanelContent() constructor {
|
|||
canvas_hover = point_in_rectangle(mx, my, 0, toolbar_height, w, h - toolbar_height);
|
||||
} #endregion
|
||||
|
||||
function fullView() { #region
|
||||
function fullView() {
|
||||
var bbox = noone;
|
||||
|
||||
var node = getNodePreview();
|
||||
if(node != noone) bbox = node.getPreviewBoundingBox();
|
||||
if(bbox == noone) bbox = BBOX().fromWH(0, 0, PROJECT.attributes.surface_dimension[0], PROJECT.attributes.surface_dimension[1]);
|
||||
|
||||
var _x = bbox.x0, _y = bbox.y0;
|
||||
var _w = bbox.w, _h = bbox.h;
|
||||
|
||||
if(_w == 0 || _h == 0) {
|
||||
_x = 0;
|
||||
_y = 0;
|
||||
_w = DEF_SURF_W;
|
||||
_h = DEF_SURF_H;
|
||||
}
|
||||
|
||||
var tl = tool_side_draw_l * 40;
|
||||
var tr = tool_side_draw_r * 40;
|
||||
var ss = min((w - 32 - tl - tr) / bbox.w, (h - 32 - toolbar_height * 2) / bbox.h);
|
||||
var ss = min((w - 32 - tl - tr) / _w, (h - 32 - toolbar_height * 2) / _h);
|
||||
canvas_s = ss;
|
||||
canvas_x = w / 2 - bbox.w * canvas_s / 2 - bbox.x0 * canvas_s + (tl - tr) / 2;
|
||||
canvas_y = h / 2 - bbox.h * canvas_s / 2 - bbox.y0 * canvas_s;
|
||||
} #endregion
|
||||
canvas_x = w / 2 - _w * canvas_s / 2 - _x * canvas_s + (tl - tr) / 2;
|
||||
canvas_y = h / 2 - _h * canvas_s / 2 - _y * canvas_s;
|
||||
}
|
||||
|
||||
function drawNodeChannel(_x, _y) { #region
|
||||
var _node = getNodePreview();
|
||||
|
|
Loading…
Reference in a new issue