mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 03:48:06 +01:00
[Draw Line] Add triangular end caps.
This commit is contained in:
parent
388fa8fc69
commit
7a79b9c021
11 changed files with 168 additions and 41 deletions
|
@ -2347,6 +2347,7 @@
|
|||
{"name":"s_node_kuwahara","order":32,"path":"sprites/s_node_kuwahara/s_node_kuwahara.yy",},
|
||||
{"name":"s_node_level_selector","order":34,"path":"sprites/s_node_level_selector/s_node_level_selector.yy",},
|
||||
{"name":"s_node_level","order":33,"path":"sprites/s_node_level/s_node_level.yy",},
|
||||
{"name":"s_node_line_cap","order":34,"path":"sprites/s_node_line_cap/s_node_line_cap.yy",},
|
||||
{"name":"s_node_line","order":7,"path":"sprites/s_node_line/s_node_line.yy",},
|
||||
{"name":"s_node_liquefy_type","order":29,"path":"sprites/s_node_liquefy_type/s_node_liquefy_type.yy",},
|
||||
{"name":"s_node_liquefy","order":71,"path":"sprites/s_node_liquefy/s_node_liquefy.yy",},
|
||||
|
|
|
@ -3038,6 +3038,7 @@
|
|||
{"id":{"name":"s_node_kuwahara","path":"sprites/s_node_kuwahara/s_node_kuwahara.yy",},},
|
||||
{"id":{"name":"s_node_level_selector","path":"sprites/s_node_level_selector/s_node_level_selector.yy",},},
|
||||
{"id":{"name":"s_node_level","path":"sprites/s_node_level/s_node_level.yy",},},
|
||||
{"id":{"name":"s_node_line_cap","path":"sprites/s_node_line_cap/s_node_line_cap.yy",},},
|
||||
{"id":{"name":"s_node_line","path":"sprites/s_node_line/s_node_line.yy",},},
|
||||
{"id":{"name":"s_node_liquefy_type","path":"sprites/s_node_liquefy_type/s_node_liquefy_type.yy",},},
|
||||
{"id":{"name":"s_node_liquefy","path":"sprites/s_node_liquefy/s_node_liquefy.yy",},},
|
||||
|
|
|
@ -97,29 +97,30 @@ function buttonGroup(_data, _onClick) : widget() constructor {
|
|||
|
||||
for(var i = 0; i < amo; i++) {
|
||||
var _d = data[i];
|
||||
|
||||
buttons[i].setFocusHover(active, hover);
|
||||
buttons[i].tooltip = array_safe_get(tooltips, i, "");
|
||||
|
||||
if(is(_d, scrollItem))
|
||||
_d = _d.spr;
|
||||
|
||||
var bww = !is_string(_d) && sprite_exists(_d) && _mx? _sw : ww;
|
||||
var spr = i == 0 ? buttonSpr[0] : (i == amo - 1? buttonSpr[2] : buttonSpr[1]);
|
||||
|
||||
if(_selecting == i) {
|
||||
draw_sprite_stretched_ext(spr, 2, floor(bx), _y, ceil(bww), _h, boxColor);
|
||||
draw_sel = [spr, bx];
|
||||
|
||||
} else {
|
||||
buttons[i].draw(floor(bx), _y, ceil(bww), _h, _m, spr);
|
||||
if(buttons[i].clicked) onClick(i);
|
||||
}
|
||||
|
||||
if(is_string(data[i])) {
|
||||
if(is_string(_d)) {
|
||||
draw_set_text(font, fa_center, fa_center, fColor);
|
||||
draw_text_add(bx + bww / 2, _y + _h / 2, data[i]);
|
||||
draw_text_add(bx + bww / 2, _y + _h / 2, _d);
|
||||
|
||||
} else if(sprite_exists(data[i])) {
|
||||
draw_sprite_ui_uniform(data[i], i, bx + bww / 2, _y + _h / 2, 1);
|
||||
|
||||
}
|
||||
} else if(sprite_exists(_d))
|
||||
draw_sprite_ui_uniform(_d, i, bx + bww / 2, _y + _h / 2, 1);
|
||||
|
||||
bx += bww;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,9 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
newInput(12, nodeValue_Bool("Span width over path", self, false, "Apply the full 'width over length' to the trimmed path."));
|
||||
|
||||
newInput(13, nodeValue_Bool("Round cap", self, false));
|
||||
newInput(13, nodeValue_Enum_Button("End cap", self, 0, [ new scrollItem("None", s_node_line_cap, 0),
|
||||
new scrollItem("Round", s_node_line_cap, 1),
|
||||
new scrollItem("Tri", s_node_line_cap, 2), ]));
|
||||
|
||||
newInput(14, nodeValue_Int("Round segment", self, 8))
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [2, 32, 0.1] });
|
||||
|
@ -139,7 +141,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
static getTool = function() {
|
||||
var _path = getInputData(7);
|
||||
return is_instanceof(_path, Node)? _path : self;
|
||||
return is(_path, Node)? _path : self;
|
||||
}
|
||||
|
||||
static step = function() {
|
||||
|
@ -226,17 +228,13 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
var _pnt0 = _data[32];
|
||||
var _pnt1 = _data[33];
|
||||
var _aa = power(2, _data[34]);
|
||||
#endregion
|
||||
|
||||
/////// Check data
|
||||
|
||||
if(_dtype == 1 && _pat == noone)
|
||||
_dtype = 0;
|
||||
|
||||
if(_dtype == 2 && (array_invalid(_segs) || array_invalid(_segs[0])))
|
||||
_dtype = 0;
|
||||
|
||||
/////// Data
|
||||
if(_dtype == 1 && _pat == noone)
|
||||
_dtype = 0;
|
||||
|
||||
if(_dtype == 2 && (array_invalid(_segs) || array_invalid(_segs[0])))
|
||||
_dtype = 0;
|
||||
#endregion
|
||||
|
||||
if(IS_FIRST_FRAME || inputs[11].is_anim)
|
||||
ds_map_clear(widthMap);
|
||||
|
@ -534,7 +532,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
}
|
||||
|
||||
/////// Draw
|
||||
////- Draw
|
||||
|
||||
var _colorPass = surface_verify(_outData[0], _surfDim[0], _surfDim[1], attrDepth());
|
||||
var _widthPass = surface_verify(_outData[1], _surfDim[0], _surfDim[1], attrDepth());
|
||||
|
@ -562,23 +560,21 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
for( var i = 0, n = array_length(lines); i < n; i++ ) {
|
||||
var points = lines[i];
|
||||
if(array_length(points) < 2) continue;
|
||||
random_set_seed(_sed + i);
|
||||
|
||||
if(_useTex && _scaleTex) shader_set_2("scale", [ _texSca[0] * _len, _texSca[1] ]);
|
||||
if(_useTex) draw_primitive_begin_texture(pr_trianglestrip, tex);
|
||||
else draw_primitive_begin(pr_trianglestrip);
|
||||
|
||||
var _ldata = line_data[i];
|
||||
var _len = _ldata.length;
|
||||
var _caps = [];
|
||||
|
||||
if(_useTex && _scaleTex) shader_set_2("scale", [ _texSca[0] * _len, _texSca[1] ]);
|
||||
|
||||
if(_useTex) draw_primitive_begin_texture(pr_trianglestrip, tex);
|
||||
else draw_primitive_begin(pr_trianglestrip);
|
||||
|
||||
random_set_seed(_sed + i);
|
||||
var pxs = [];
|
||||
var dat = array_safe_get_fast(_pathData, i, noone);
|
||||
var pxs = [];
|
||||
var dat = array_safe_get_fast(_pathData, i, noone);
|
||||
|
||||
var _col_base = dat == noone? _colb.eval(random(1)) : dat.color;
|
||||
|
||||
for( var j = 0; j < array_length(points); j++ ) {
|
||||
for( var j = 0, m = array_length(points); j < m; j++ ) {
|
||||
var p0 = points[j];
|
||||
var _nx = p0.x - 0.5 * _1px + _padx;
|
||||
var _ny = p0.y - 0.5 * _1px + _pady;
|
||||
|
@ -597,24 +593,24 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
_nc = colorMultiply(_col_base, _color.eval(_colP? prog : prgc));
|
||||
|
||||
if(_cap) {
|
||||
if(_cap) {
|
||||
if(j == 1) {
|
||||
_d = _dir + 180;
|
||||
_caps[0] = [ _oc, _ox, _oy, _ow / 2, _d - 90, _d ];
|
||||
_caps[1] = [ _oc, _ox, _oy, _ow / 2, _d, _d + 90 ];
|
||||
}
|
||||
|
||||
if(j == array_length(points) - 1) {
|
||||
if(j == m - 1) {
|
||||
_d = _dir;
|
||||
_caps[2] = [ _nc, _nx, _ny, _nw / 2, _d - 90, _d ];
|
||||
_caps[3] = [ _nc, _nx, _ny, _nw / 2, _d, _d + 90 ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(_1px) {
|
||||
if(j) {
|
||||
var dst = point_distance(_ox, _oy, _nx, _ny);
|
||||
if(dst <= 1 && i < array_length(points) - 1) continue;
|
||||
if(dst <= 1 && i < m - 1) continue;
|
||||
draw_line_color(_ox * _aa, _oy * _aa, _nx * _aa, _ny * _aa, _oc, _nc);
|
||||
}
|
||||
|
||||
|
@ -627,7 +623,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
var _nd0 = _dir;
|
||||
var _nd1 = _nd0;
|
||||
|
||||
if(j < array_length(points) - 1) {
|
||||
if(j < m - 1) {
|
||||
var p2 = points[j + 1];
|
||||
var _nnx = p2.x + _padx;
|
||||
var _nny = p2.y + _pady;
|
||||
|
@ -638,7 +634,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
_nd = _nd0;
|
||||
|
||||
if(_useTex) {
|
||||
var _len = array_length(points) - 1;
|
||||
var _len = m - 1;
|
||||
|
||||
var ox0 = _ox + lengthdir_x(_ow / 2, _od + 90);
|
||||
var oy0 = _oy + lengthdir_y(_ow / 2, _od + 90);
|
||||
|
@ -682,8 +678,23 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
for( var j = 0, m = array_length(_caps); j < m; j++ ) {
|
||||
var _cps = _caps[j];
|
||||
var _cpx = _cps[1] * _aa;
|
||||
var _cpy = _cps[2] * _aa;
|
||||
var _cpr = _cps[3] * _aa;
|
||||
|
||||
draw_set_color(_cps[0]);
|
||||
draw_circle_angle(_cps[1] * _aa, _cps[2] * _aa, _cps[3] * _aa, _cps[4], _cps[5], _capP);
|
||||
|
||||
switch(_cap) {
|
||||
case 1 : draw_circle_angle(_cpx, _cpy, _cpr, _cps[4], _cps[5], _capP); break;
|
||||
case 2 :
|
||||
var _x0 = _cpx + lengthdir_x(_cpr, _cps[4]);
|
||||
var _y0 = _cpy + lengthdir_y(_cpr, _cps[4]);
|
||||
var _x2 = _cpx + lengthdir_x(_cpr, _cps[5]);
|
||||
var _y2 = _cpy + lengthdir_y(_cpr, _cps[5]);
|
||||
|
||||
draw_triangle(_cpx - 1, _cpy - 1, _x0 - 1, _y0 - 1, _x2 - 1, _y2 - 1, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,7 +726,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
var _col_base = dat == noone? _colb.eval(random(1)) : dat.color;
|
||||
|
||||
for( var j = 0; j < array_length(points); j++ ) {
|
||||
for( var j = 0, m = array_length(points); j < m; j++ ) {
|
||||
var p0 = points[j];
|
||||
var _nx = p0.x - 0.5 * _1px + _padx;
|
||||
var _ny = p0.y - 0.5 * _1px + _pady;
|
||||
|
@ -739,7 +750,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
_caps[1] = [ c_grey, _ox, _oy, _ow / 2, _d, _d + 90 ];
|
||||
}
|
||||
|
||||
if(j == array_length(points) - 1) {
|
||||
if(j == m - 1) {
|
||||
_d = _dir;
|
||||
_caps[2] = [ c_grey, _nx, _ny, _nw / 2, _d - 90, _d ];
|
||||
_caps[3] = [ c_grey, _nx, _ny, _nw / 2, _d, _d + 90 ];
|
||||
|
@ -750,7 +761,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
var _nd0 = _dir;
|
||||
var _nd1 = _nd0;
|
||||
|
||||
if(j < array_length(points) - 1) {
|
||||
if(j < m - 1) {
|
||||
var p2 = points[j + 1];
|
||||
var _nnx = p2.x + _padx;
|
||||
var _nny = p2.y + _pady;
|
||||
|
@ -781,8 +792,23 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
for( var j = 0, m = array_length(_caps); j < m; j++ ) {
|
||||
var _cps = _caps[j];
|
||||
var _cpx = _cps[1];
|
||||
var _cpy = _cps[2];
|
||||
var _cpr = _cps[3];
|
||||
|
||||
draw_set_color(_cps[0]);
|
||||
draw_circle_angle(_cps[1], _cps[2], _cps[3], _cps[4], _cps[5], _capP);
|
||||
|
||||
switch(_cap) {
|
||||
case 1 : draw_circle_angle(_cpx, _cpy, _cpr, _cps[4], _cps[5], _capP); break;
|
||||
case 2 :
|
||||
var _x0 = _cpx + lengthdir_x(_cpr, _cps[4]);
|
||||
var _y0 = _cpy + lengthdir_y(_cpr, _cps[4]);
|
||||
var _x2 = _cpx + lengthdir_x(_cpr, _cps[5]);
|
||||
var _y2 = _cpy + lengthdir_y(_cpr, _cps[5]);
|
||||
|
||||
draw_triangle(_cpx - 1, _cpy - 1, _x0 - 1, _y0 - 1, _x2 - 1, _y2 - 1, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
sprites/s_node_line_cap/2b371c09-c37f-4615-b72f-9f5ec7a76996.png
Normal file
BIN
sprites/s_node_line_cap/2b371c09-c37f-4615-b72f-9f5ec7a76996.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 392 B |
BIN
sprites/s_node_line_cap/bb650c2c-56ab-4563-992d-653a14e3a14d.png
Normal file
BIN
sprites/s_node_line_cap/bb650c2c-56ab-4563-992d-653a14e3a14d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 420 B |
BIN
sprites/s_node_line_cap/e2122459-9469-41b0-9ecd-4c03052cf02a.png
Normal file
BIN
sprites/s_node_line_cap/e2122459-9469-41b0-9ecd-4c03052cf02a.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 462 B |
Binary file not shown.
After Width: | Height: | Size: 392 B |
Binary file not shown.
After Width: | Height: | Size: 420 B |
Binary file not shown.
After Width: | Height: | Size: 462 B |
98
sprites/s_node_line_cap/s_node_line_cap.yy
Normal file
98
sprites/s_node_line_cap/s_node_line_cap.yy
Normal file
|
@ -0,0 +1,98 @@
|
|||
{
|
||||
"$GMSprite":"",
|
||||
"%Name":"s_node_line_cap",
|
||||
"bboxMode":0,
|
||||
"bbox_bottom":17,
|
||||
"bbox_left":2,
|
||||
"bbox_right":18,
|
||||
"bbox_top":6,
|
||||
"collisionKind":1,
|
||||
"collisionTolerance":0,
|
||||
"DynamicTexturePage":false,
|
||||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"2b371c09-c37f-4615-b72f-9f5ec7a76996","name":"2b371c09-c37f-4615-b72f-9f5ec7a76996","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"e2122459-9469-41b0-9ecd-4c03052cf02a","name":"e2122459-9469-41b0-9ecd-4c03052cf02a","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"bb650c2c-56ab-4563-992d-653a14e3a14d","name":"bb650c2c-56ab-4563-992d-653a14e3a14d","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":24,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"f9667afb-0905-4cfb-a200-75fd3cb19fc6","blendMode":0,"displayName":"default","isLocked":false,"name":"f9667afb-0905-4cfb-a200-75fd3cb19fc6","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_line_cap",
|
||||
"nineSlice":null,
|
||||
"origin":4,
|
||||
"parent":{
|
||||
"name":"nodes",
|
||||
"path":"folders/sprites/nodes.yy",
|
||||
},
|
||||
"preMultiplyAlpha":false,
|
||||
"resourceType":"GMSprite",
|
||||
"resourceVersion":"2.0",
|
||||
"sequence":{
|
||||
"$GMSequence":"",
|
||||
"%Name":"s_node_line_cap",
|
||||
"autoRecord":true,
|
||||
"backdropHeight":768,
|
||||
"backdropImageOpacity":0.5,
|
||||
"backdropImagePath":"",
|
||||
"backdropWidth":1366,
|
||||
"backdropXOffset":0.0,
|
||||
"backdropYOffset":0.0,
|
||||
"events":{
|
||||
"$KeyframeStore<MessageEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MessageEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"eventStubScript":null,
|
||||
"eventToFunction":{},
|
||||
"length":3.0,
|
||||
"lockOrigin":false,
|
||||
"moments":{
|
||||
"$KeyframeStore<MomentsEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"name":"s_node_line_cap",
|
||||
"playback":1,
|
||||
"playbackSpeed":30.0,
|
||||
"playbackSpeedType":0,
|
||||
"resourceType":"GMSequence",
|
||||
"resourceVersion":"2.0",
|
||||
"showBackdrop":true,
|
||||
"showBackdropImage":false,
|
||||
"timeUnits":1,
|
||||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"2b371c09-c37f-4615-b72f-9f5ec7a76996","path":"sprites/s_node_line_cap/s_node_line_cap.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"154b6ace-b6e7-41f0-8d65-420fded854c1","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"e2122459-9469-41b0-9ecd-4c03052cf02a","path":"sprites/s_node_line_cap/s_node_line_cap.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"7ff41398-06f4-4dd7-806c-927cc014b307","IsCreationKey":false,"Key":1.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"bb650c2c-56ab-4563-992d-653a14e3a14d","path":"sprites/s_node_line_cap/s_node_line_cap.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"6e83f3f3-886c-4446-9030-e55dd8f06e95","IsCreationKey":false,"Key":2.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange":null,
|
||||
"volume":1.0,
|
||||
"xorigin":12,
|
||||
"yorigin":12,
|
||||
},
|
||||
"swatchColours":null,
|
||||
"swfPrecision":0.5,
|
||||
"textureGroupId":{
|
||||
"name":"Default",
|
||||
"path":"texturegroups/Default",
|
||||
},
|
||||
"type":0,
|
||||
"VTile":false,
|
||||
"width":24,
|
||||
}
|
Loading…
Reference in a new issue