<?xml version='1.0' encoding='utf-8'?>
<MNPreset formatVersion="1"><metadata name="Paint" description="Draw with the mouse: the painting kept in Buffer A, colours and sizes to pick. Edit the Shader Code node to change the drawing, or set its File to follow your own GLSL file." author="MNodes" category="Scene Studio" pluginVersion="1.1.5" createdAt="1790467200000" modifiedAt="1790467200000" type="Utility" preferredOpenMode="perform" tags="scene, visual, interface" /><state><marionietoworld.MNodes_State gridActive="0" gridSize="20" viewOffsetX="0" viewOffsetY="48" zoom="0.80" didInitView="1" toolbarExpanded="0" pv="1.1.5"><nodes nextId="6"><node id="1" type="visual.shadercode" title="Code - Paint" expanded="1" x="32" y="200" w="310" h="240"><state file="" textsize="13.0" out="0.0" code="// Paint&#10;//&#10;// Draw with the mouse. The painting is kept in Buffer A, which each frame&#10;// starts from what it was and adds the stroke since the frame before (Buffer&#10;// B remembers where the mouse was): a canvas remembers whatever its buffers&#10;// keep. Pick a colour and a size at the bottom; Clear starts again.&#10;&#10;const vec3 COLOURS[6] = vec3[6](vec3(0.95, 0.25, 0.3), vec3(1.0, 0.6, 0.2), vec3(1.0, 0.9, 0.3),&#10;                                vec3(0.3, 0.9, 0.5), vec3(0.3, 0.6, 1.0), vec3(0.95));&#10;&#10;vec3 brushColour()&#10;{&#10;    for (int i = 0; i &lt; 6; ++i)&#10;        if (zoneValue(i) &gt; 0.5) return COLOURS[i];&#10;    return COLOURS[5];&#10;}&#10;&#10;float brushSize() { return mix(2.0, 26.0, zoneValue(Size)); }&#10;&#10;float sdSegment(vec2 p, vec2 a, vec2 b)&#10;{&#10;    vec2 pa = p - a, ba = b - a;&#10;    float l = dot(ba, ba);&#10;    return length(pa - ba * (l &gt; 0.0 ? clamp(dot(pa, ba) / l, 0.0, 1.0) : 0.0));&#10;}&#10;&#10;#pass A&#10;void mainImage(out vec4 o, in vec2 fragCoord)&#10;{&#10;    o = readA(fragCoord);&#10;    if (zonePressed(Clear) &gt; 0.5 || iFrame &lt; 1) { o = vec4(0.0); return; }&#10;    if (MouseDown &gt; 0.5 &amp;&amp; ZoneActive &lt; 0)&#10;    {&#10;        vec4 last = readB(ivec2(0, 0));   // where the mouse was, and whether it was painting&#10;        vec2 now = iMouse.xy;&#10;        vec2 from = last.z &gt; 0.5 ? last.xy : now;&#10;        float d = sdSegment(fragCoord, from, now) - brushSize();&#10;        float a = clamp(0.5 - d, 0.0, 1.0) * 0.9;&#10;        o.rgb = mix(o.rgb, brushColour(), a);&#10;        o.a = max(o.a, a);&#10;    }&#10;}&#10;&#10;#pass B&#10;void mainImage(out vec4 o, in vec2 fragCoord)&#10;{&#10;    o = vec4(iMouse.xy, MouseDown &gt; 0.5 &amp;&amp; ZoneActive &lt; 0 ? 1.0 : 0.0, 0.0);&#10;}&#10;&#10;#pass Image&#10;float px;&#10;float fillOf(float d) { return clamp(0.5 - d / px, 0.0, 1.0); }&#10;&#10;float sdRound(vec2 p, vec2 h, float r)&#10;{&#10;    vec2 q = abs(p) - h + r;&#10;    return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;&#10;}&#10;&#10;void mainImage(out vec4 fragColor, in vec2 fragCoord)&#10;{&#10;    px = 1.0 / max(mnPixelScale, 0.001);&#10;    vec2 R = iResolution.xy, p = fragCoord;&#10;&#10;    // the paper, and the painting on it&#10;    vec3 col = vec3(0.93, 0.91, 0.86) - texture(iChannel2, p / 180.0).r * 0.05;&#10;    vec4 paint = readA(p);&#10;    col = mix(col, paint.rgb, paint.a);&#10;&#10;    // the bar at the bottom: the colours, the size, Clear&#10;    if (p.y &lt; R.y * 0.14)&#10;    {&#10;        col = mix(col, vec3(0.12, 0.12, 0.14), 0.92);&#10;        for (int i = 0; i &lt; 6; ++i)&#10;        {&#10;            float r = min(zoneSize(i).x, zoneSize(i).y) * 0.4;&#10;            float d = length(p - zoneCenter(i)) - r * (1.0 + 0.12 * zoneHover(i));&#10;            col = mix(col, COLOURS[i], fillOf(d));&#10;            col = mix(col, vec3(1.0), fillOf(abs(d - 3.0) - 1.0) * zoneValue(i));&#10;        }&#10;        vec4 s = zoneRect(Size);&#10;        col = mix(col, vec3(0.35), fillOf(sdRound(p - (s.xy + s.zw * 0.5), vec2(s.z * 0.5, 2.0), 2.0)));&#10;        vec2 knobAt = vec2(s.x + s.z * zoneValue(Size), s.y + s.w * 0.5);&#10;        col = mix(col, brushColour(), fillOf(length(p - knobAt) - brushSize() * 0.5 - 2.0));&#10;        vec4 c = zoneRect(Clear);&#10;        vec2 cc = c.xy + c.zw * 0.5;&#10;        col = mix(col, mix(vec3(0.3, 0.1, 0.12), vec3(0.8, 0.2, 0.25), zonePressed(Clear) * 0.7 + zoneHover(Clear) * 0.3),&#10;                  fillOf(sdRound(p - cc, c.zw * 0.5, 6.0)));&#10;        vec2 q = abs(p - cc);&#10;        col = mix(col, vec3(1.0), fillOf(abs(q.x - q.y) - 1.2) * step(max(q.x, q.y), c.w * 0.28));&#10;    }&#10;    else if (MouseOver &gt; 0.5 &amp;&amp; ZoneHovered &lt; 0)&#10;    {&#10;        // the brush, where the pointer is&#10;        vec2 at = vec2(MouseHoverX, MouseHoverY) * R;&#10;        col = mix(col, brushColour(), 0.8 * fillOf(abs(length(p - at) - brushSize()) - 0.8));&#10;    }&#10;    fragColor = vec4(col, 1.0);&#10;}&#10;" live="1" ui_only="1" hide_unconnected="1" /></node><node id="2" type="visual.gpucanvas" title="Scene" expanded="1" x="754" y="200" w="600" h="420"><state in="0.0" inb="0.0" codein="0.0" zonesin="0.0" setrow="0.0" scriptin="0.0" editObjects="0" appearanceRow="0.0" pcount="8" speed="1.0" p1="0.0" p2="0.0" p3="0.0" p4="0.0" p5="0.0" p6="0.0" p7="0.0" p8="0.0" mousex="0.5" mousey="0.5" wheel="0.0" dragx="0.0" dragy="0.0" imouse="0 0 0 0" code="" zones="[&#10;  { &quot;id&quot;: 1, &quot;name&quot;: &quot;Red&quot;, &quot;type&quot;: &quot;radio&quot;, &quot;shape&quot;: &quot;circle&quot;, &quot;x&quot;: 0.02, &quot;y&quot;: 0.02, &quot;w&quot;: 0.06, &quot;h&quot;: 0.1, &quot;default&quot;: 1, &quot;group&quot;: &quot;colour&quot; },&#10;  { &quot;id&quot;: 2, &quot;name&quot;: &quot;Orange&quot;, &quot;type&quot;: &quot;radio&quot;, &quot;shape&quot;: &quot;circle&quot;, &quot;x&quot;: 0.09, &quot;y&quot;: 0.02, &quot;w&quot;: 0.06, &quot;h&quot;: 0.1, &quot;group&quot;: &quot;colour&quot; },&#10;  { &quot;id&quot;: 3, &quot;name&quot;: &quot;Yellow&quot;, &quot;type&quot;: &quot;radio&quot;, &quot;shape&quot;: &quot;circle&quot;, &quot;x&quot;: 0.16, &quot;y&quot;: 0.02, &quot;w&quot;: 0.06, &quot;h&quot;: 0.1, &quot;group&quot;: &quot;colour&quot; },&#10;  { &quot;id&quot;: 4, &quot;name&quot;: &quot;Green&quot;, &quot;type&quot;: &quot;radio&quot;, &quot;shape&quot;: &quot;circle&quot;, &quot;x&quot;: 0.23, &quot;y&quot;: 0.02, &quot;w&quot;: 0.06, &quot;h&quot;: 0.1, &quot;group&quot;: &quot;colour&quot; },&#10;  { &quot;id&quot;: 5, &quot;name&quot;: &quot;Blue&quot;, &quot;type&quot;: &quot;radio&quot;, &quot;shape&quot;: &quot;circle&quot;, &quot;x&quot;: 0.3, &quot;y&quot;: 0.02, &quot;w&quot;: 0.06, &quot;h&quot;: 0.1, &quot;group&quot;: &quot;colour&quot; },&#10;  { &quot;id&quot;: 6, &quot;name&quot;: &quot;White&quot;, &quot;type&quot;: &quot;radio&quot;, &quot;shape&quot;: &quot;circle&quot;, &quot;x&quot;: 0.37, &quot;y&quot;: 0.02, &quot;w&quot;: 0.06, &quot;h&quot;: 0.1, &quot;group&quot;: &quot;colour&quot; },&#10;  { &quot;id&quot;: 7, &quot;name&quot;: &quot;Size&quot;, &quot;type&quot;: &quot;slider&quot;, &quot;shape&quot;: &quot;rect&quot;, &quot;x&quot;: 0.46, &quot;y&quot;: 0.035, &quot;w&quot;: 0.3, &quot;h&quot;: 0.07, &quot;default&quot;: 0.3, &quot;vertical&quot;: false },&#10;  { &quot;id&quot;: 8, &quot;name&quot;: &quot;Clear&quot;, &quot;type&quot;: &quot;button&quot;, &quot;shape&quot;: &quot;rect&quot;, &quot;x&quot;: 0.8, &quot;y&quot;: 0.025, &quot;w&quot;: 0.18, &quot;h&quot;: 0.09 }&#10;]" zonevalues="" labels="" image1="" image2="" fontFile="" preserveBuffers="1" resolution="0" framerate="1" transparent="0" background="FF0F131A" keyboard="0" zoneinputs="1" showOrientation="0" showObjectAxes="0" visible="1" ignoreClicks="0" panelX="0.0" panelY="0.0" panelW="0.0" panelH="0.0" tooltipStyle="" exposeToDAW="0" ui_only="1" hide_unconnected="1" /></node><node id="3" type="comment" title="Comment" expanded="0" x="24" y="18" w="1320" h="48"><state text="Paint" fontSize="32" fontWeight="3" align="0" textColour="ffe5ecee" bgColour="00000000" borderColour="80ffffff" borderOn="0" borderStroke="1.0" fontFamily="Inter" /></node><node id="4" type="comment" title="Comment" expanded="0" x="24" y="78" w="1320" h="94"><state text="Draw with the mouse: the painting kept in Buffer A, colours and sizes to pick. Edit the Shader Code node to change the drawing, or set its File to follow your own GLSL file." fontSize="20" fontWeight="1" align="0" textColour="ffcad5d9" bgColour="00000000" borderColour="80ffffff" borderOn="0" borderStroke="1.0" fontFamily="Inter" /></node><node id="5" type="comment" title="Comment" expanded="0" x="754" y="654" w="580" h="116"><state text="Select a node for its settings. Open the separate Code or Script to change the drawing. Show Zones reveals interaction areas." fontSize="20" fontWeight="1" align="0" textColour="ff80d9de" bgColour="00000000" borderColour="80ffffff" borderOn="0" borderStroke="1.0" fontFamily="Inter" /></node></nodes><edges><e fn="1" fp="0" tn="2" tp="2" /></edges><panel width="720" height="440" locked="1" zoom="1" performScale="1" gridEnabled="0" toolbarExpanded="0" panelBgColour="ff101820"><entry nodeId="2" x="0" y="0" w="720" h="440" z="0" auto="0" /></panel></marionietoworld.MNodes_State></state></MNPreset>