diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index b961c5cdc..069597ca1 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -812,6 +812,7 @@ {"name":"node_gradient_palette","order":11,"path":"scripts/node_gradient_palette/node_gradient_palette.yy",}, {"name":"node_gradient_points","order":1,"path":"scripts/node_gradient_points/node_gradient_points.yy",}, {"name":"node_gradient_replace_color","order":12,"path":"scripts/node_gradient_replace_color/node_gradient_replace_color.yy",}, + {"name":"node_gradient_sample","order":16,"path":"scripts/node_gradient_sample/node_gradient_sample.yy",}, {"name":"node_gradient_shift","order":10,"path":"scripts/node_gradient_shift/node_gradient_shift.yy",}, {"name":"node_grain","order":19,"path":"scripts/node_grain/node_grain.yy",}, {"name":"node_graph_preview","order":20,"path":"scripts/node_graph_preview/node_graph_preview.yy",}, @@ -2207,6 +2208,7 @@ {"name":"s_node_gradient_out","order":10,"path":"sprites/s_node_gradient_out/s_node_gradient_out.yy",}, {"name":"s_node_gradient_palette","order":11,"path":"sprites/s_node_gradient_palette/s_node_gradient_palette.yy",}, {"name":"s_node_gradient_replace","order":12,"path":"sprites/s_node_gradient_replace/s_node_gradient_replace.yy",}, + {"name":"s_node_gradient_sample","order":22,"path":"sprites/s_node_gradient_sample/s_node_gradient_sample.yy",}, {"name":"s_node_gradient_shift","order":13,"path":"sprites/s_node_gradient_shift/s_node_gradient_shift.yy",}, {"name":"s_node_gradient_type","order":6,"path":"sprites/s_node_gradient_type/s_node_gradient_type.yy",}, {"name":"s_node_gradient","order":1,"path":"sprites/s_node_gradient/s_node_gradient.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 1a464c985..a5f372750 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1370,6 +1370,7 @@ {"id":{"name":"node_gradient_palette","path":"scripts/node_gradient_palette/node_gradient_palette.yy",},}, {"id":{"name":"node_gradient_points","path":"scripts/node_gradient_points/node_gradient_points.yy",},}, {"id":{"name":"node_gradient_replace_color","path":"scripts/node_gradient_replace_color/node_gradient_replace_color.yy",},}, + {"id":{"name":"node_gradient_sample","path":"scripts/node_gradient_sample/node_gradient_sample.yy",},}, {"id":{"name":"node_gradient_shift","path":"scripts/node_gradient_shift/node_gradient_shift.yy",},}, {"id":{"name":"node_gradient","path":"scripts/node_gradient/node_gradient.yy",},}, {"id":{"name":"node_grain","path":"scripts/node_grain/node_grain.yy",},}, @@ -2935,6 +2936,7 @@ {"id":{"name":"s_node_gradient_out","path":"sprites/s_node_gradient_out/s_node_gradient_out.yy",},}, {"id":{"name":"s_node_gradient_palette","path":"sprites/s_node_gradient_palette/s_node_gradient_palette.yy",},}, {"id":{"name":"s_node_gradient_replace","path":"sprites/s_node_gradient_replace/s_node_gradient_replace.yy",},}, + {"id":{"name":"s_node_gradient_sample","path":"sprites/s_node_gradient_sample/s_node_gradient_sample.yy",},}, {"id":{"name":"s_node_gradient_shift","path":"sprites/s_node_gradient_shift/s_node_gradient_shift.yy",},}, {"id":{"name":"s_node_gradient_type","path":"sprites/s_node_gradient_type/s_node_gradient_type.yy",},}, {"id":{"name":"s_node_gradient","path":"sprites/s_node_gradient/s_node_gradient.yy",},}, diff --git a/scripts/node_gradient_sample/node_gradient_sample.gml b/scripts/node_gradient_sample/node_gradient_sample.gml new file mode 100644 index 000000000..8dbdc6e02 --- /dev/null +++ b/scripts/node_gradient_sample/node_gradient_sample.gml @@ -0,0 +1,52 @@ +function Node_Gradient_Sample(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { + name = "Sample Gradient"; + setDimension(96); + + newInput(0, nodeValue_Gradient("Gradient", self, new gradientObject([cola(c_black), cola(c_white)])) ) + .setVisible(true, true); + + newInput(1, nodeValue_Int("Step", self, 16)); + + newInput(2, nodeValue_Float("Shift", self, 0)) + .setDisplay(VALUE_DISPLAY.slider, { range: [-1, 1, 0.01] }); + + newOutput(0, nodeValue_Output("Colors", self, VALUE_TYPE.color, [ c_black ])) + .setDisplay(VALUE_DISPLAY.palette); + + _pal = -1; + + static processData_prebatch = function() { + setDimension(96, process_length[0] * 32); + } + + static processData = function(_outSurf, _data, _output_index, _array_index) { + var grad = _data[0]; + var stp = _data[1]; + var shf = _data[2]; + + _outSurf = array_verify(_outSurf, stp); + for( var i = 0; i < stp; i++ ) { + var _t = frac(shf + i / stp); + _outSurf[i] = grad.eval(_t); + } + + return _outSurf; + } + + static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { + var bbox = drawGetBbox(xx, yy, _s); + if(bbox.h < 1) return; + + var pal = outputs[0].getValue(); + if(array_empty(pal)) return; + if(!is_array(pal[0])) pal = [ pal ]; + + var _y = bbox.y0; + var gh = bbox.h / array_length(pal); + + for( var i = 0, n = array_length(pal); i < n; i++ ) { + drawPalette(pal[i], bbox.x0, _y, bbox.w, gh); + _y += gh; + } + } +} \ No newline at end of file diff --git a/scripts/node_gradient_sample/node_gradient_sample.yy b/scripts/node_gradient_sample/node_gradient_sample.yy new file mode 100644 index 000000000..75c53bde6 --- /dev/null +++ b/scripts/node_gradient_sample/node_gradient_sample.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"node_gradient_sample", + "isCompatibility":false, + "isDnD":false, + "name":"node_gradient_sample", + "parent":{ + "name":"color", + "path":"folders/nodes/data/value/color.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 1a775b8f7..0b09d39d3 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -1037,6 +1037,7 @@ function __initNodes() { addNodeObject(color, "Gradient Shift", s_node_gradient_shift, "Node_Gradient_Shift", [1, Node_Gradient_Shift],, "Move gradients keys."); addNodeObject(color, "Gradient Replace", s_node_gradient_replace, "Node_Gradient_Replace_Color", [1, Node_Gradient_Replace_Color],, "Replace color inside a gradient.").setVersion(1135); addNodeObject(color, "Gradient Data", s_node_gradient_data, "Node_Gradient_Extract", [1, Node_Gradient_Extract],, "Get palatte and array of key positions from gradient.").setVersion(1135); + addNodeObject(color, "Sample Gradient", s_node_gradient_sample, "Node_Gradient_Sample", [1, Node_Gradient_Sample], ["gradient sample"], "Sample gradient into palette.").setVersion(1_18_04_1); #endregion #region animation diff --git a/sprites/s_node_gradient_sample/2b4cc30b-1457-4a03-aa42-bdf4086ca7b9.png b/sprites/s_node_gradient_sample/2b4cc30b-1457-4a03-aa42-bdf4086ca7b9.png new file mode 100644 index 000000000..3c69e9c63 Binary files /dev/null and b/sprites/s_node_gradient_sample/2b4cc30b-1457-4a03-aa42-bdf4086ca7b9.png differ diff --git a/sprites/s_node_gradient_sample/layers/2b4cc30b-1457-4a03-aa42-bdf4086ca7b9/f91fe59c-c806-4364-901c-861258a8525c.png b/sprites/s_node_gradient_sample/layers/2b4cc30b-1457-4a03-aa42-bdf4086ca7b9/f91fe59c-c806-4364-901c-861258a8525c.png new file mode 100644 index 000000000..3c69e9c63 Binary files /dev/null and b/sprites/s_node_gradient_sample/layers/2b4cc30b-1457-4a03-aa42-bdf4086ca7b9/f91fe59c-c806-4364-901c-861258a8525c.png differ diff --git a/sprites/s_node_gradient_sample/s_node_gradient_sample.yy b/sprites/s_node_gradient_sample/s_node_gradient_sample.yy new file mode 100644 index 000000000..1e5eb0883 --- /dev/null +++ b/sprites/s_node_gradient_sample/s_node_gradient_sample.yy @@ -0,0 +1,90 @@ +{ + "$GMSprite":"", + "%Name":"s_node_gradient_sample", + "bboxMode":0, + "bbox_bottom":63, + "bbox_left":2, + "bbox_right":61, + "bbox_top":0, + "collisionKind":1, + "collisionTolerance":0, + "DynamicTexturePage":false, + "edgeFiltering":false, + "For3D":false, + "frames":[ + {"$GMSpriteFrame":"","%Name":"2b4cc30b-1457-4a03-aa42-bdf4086ca7b9","name":"2b4cc30b-1457-4a03-aa42-bdf4086ca7b9","resourceType":"GMSpriteFrame","resourceVersion":"2.0",}, + ], + "gridX":0, + "gridY":0, + "height":64, + "HTile":false, + "layers":[ + {"$GMImageLayer":"","%Name":"f91fe59c-c806-4364-901c-861258a8525c","blendMode":0,"displayName":"default","isLocked":false,"name":"f91fe59c-c806-4364-901c-861258a8525c","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,}, + ], + "name":"s_node_gradient_sample", + "nineSlice":null, + "origin":4, + "parent":{ + "name":"color", + "path":"folders/nodes/icons/value/color.yy", + }, + "preMultiplyAlpha":false, + "resourceType":"GMSprite", + "resourceVersion":"2.0", + "sequence":{ + "$GMSequence":"", + "%Name":"s_node_gradient_sample", + "autoRecord":true, + "backdropHeight":768, + "backdropImageOpacity":0.5, + "backdropImagePath":"", + "backdropWidth":1366, + "backdropXOffset":0.0, + "backdropYOffset":0.0, + "events":{ + "$KeyframeStore":"", + "Keyframes":[], + "resourceType":"KeyframeStore", + "resourceVersion":"2.0", + }, + "eventStubScript":null, + "eventToFunction":{}, + "length":1.0, + "lockOrigin":false, + "moments":{ + "$KeyframeStore":"", + "Keyframes":[], + "resourceType":"KeyframeStore", + "resourceVersion":"2.0", + }, + "name":"s_node_gradient_sample", + "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":"","Keyframes":[ + {"$Keyframe":"","Channels":{ + "0":{"$SpriteFrameKeyframe":"","Id":{"name":"2b4cc30b-1457-4a03-aa42-bdf4086ca7b9","path":"sprites/s_node_gradient_sample/s_node_gradient_sample.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",}, + },"Disabled":false,"id":"adece9c5-dc7d-489a-8527-89cc9b78e9da","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe","resourceVersion":"2.0","Stretch":false,}, + ],"resourceType":"KeyframeStore","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,}, + ], + "visibleRange":null, + "volume":1.0, + "xorigin":32, + "yorigin":32, + }, + "swatchColours":null, + "swfPrecision":0.5, + "textureGroupId":{ + "name":"Default", + "path":"texturegroups/Default", + }, + "type":0, + "VTile":false, + "width":64, +} \ No newline at end of file