Help me understand how to find x1,x2,y1,y2 in g.setGradientFill
-
My goal is to customize the Osciloscope using a gradient fill but I can't find the values of x1/x2 and y1/y2 as requested in the "ApiCollection" tab:
Currently my scope has both a main "line" (darker) and persistence lines just for style.
const var dp = Synth.getDisplayBufferSource("HardcodedMasterFX1"); const var rb = dp.getDisplayBuffer(0); const var BUFFER_LENGTH = 512; const var properties = { "BufferLength": BUFFER_LENGTH, "NumChannels": 1 }; rb.setRingBufferProperties(properties); const var P1 = Content.getComponent("P1"); // Number of persistence buffers const var NUM_PERSISTENCE_BUFFERS = 6; const var persistenceBuffers = []; for (var i = 0; i < NUM_PERSISTENCE_BUFFERS; i++) { persistenceBuffers.push(rb.createPath(P1.getLocalBounds(0), [0, BUFFER_LENGTH, -8.0, 8.0], 0.0)); } // Timer Callback var currentBufferIndex = 0; P1.setTimerCallback(function() { // Fixed amplitude (?) var amplitude = -8.0; var newPath = rb.createPath(this.getLocalBounds(0), [0, BUFFER_LENGTH, amplitude, -amplitude], 0.0); persistenceBuffers[currentBufferIndex] = newPath; currentBufferIndex = (currentBufferIndex + 1) % NUM_PERSISTENCE_BUFFERS; this.repaint(); }); // Paint Routine P1.setPaintRoutine(function(g) { var area = this.getLocalBounds(0); // Fill background g.fillAll(Colours.black); // Draw persistence buffers for (var i = 0; i < NUM_PERSISTENCE_BUFFERS; i++) { var index = (currentBufferIndex + NUM_PERSISTENCE_BUFFERS - i - 1) % NUM_PERSISTENCE_BUFFERS; g.setOpacity(0.8 - (i * 0.12)); // Fading opacity for trails // colours for each layer g.setColour(0xFF00FFFF); g.drawPath(persistenceBuffers[index], area, 3 + i * 0.5); } // Draw recent buffer with a strong center glow var recentBuffer = persistenceBuffers[(currentBufferIndex - 1 + NUM_PERSISTENCE_BUFFERS) % NUM_PERSISTENCE_BUFFERS]; if (recentBuffer) { // Layered strokes g.setColour(0xFF00CCFF); g.setOpacity(0.7); g.drawPath(recentBuffer, area, 7); g.setOpacity(0.9); g.drawPath(recentBuffer, area, 5); g.setOpacity(1.0); g.drawPath(recentBuffer, area, 3); } });
Since I already have the value of "area", should I use this to find x1/x2 and y1/y2?
HiseSnippet 2187.3oc0Y08aaibDmT1LWst6J5UjqWenOrvnEf9hiNQ+QbRcChskkRLp+P0xI2ADDXrhbozBSwkX2U1V8P.tG6eV2i8w9+Qeo+GzN6tjhj1RJtpI45o.HKN6ryL6u4icFl1blOQHXbK6pmMJgXY+YNcFEK62nOlFacv9V1+RmivBIgiLj1aTBVHHAV11K7bEA6kVzR+4e8r8vQ3XeRNIKqWwn9jCoCnxbps24OSihZgCHmQGTf6M14.eVbCVDaHXOK3T2JA6eAtG4XrhsJNVu.K5aY+0NOYyM8vAgaE5st2S5FD5SVeq5OZisVCu4iCC2pt2FqGrU3FfQdulATIi2QhkDgk8h6wBF0oO6pXiBdEUP6FQTO3Y0AzrgbKVTf5HpnZ0nOMJncFPIrrrcZmCaKXfs66bDMfNldN78qzKfx2QQ.ztRYyagRlmWQyqdAyaBljcASZQiI8ENc74zDY9JJ64ScNHF7lgXvOUzTL7ZUoxRNMX.GwxZCvWPZwgGFuC2GUu9pH3qU1tZ0u4aPMdYmyN4Hzg61BUEbcBI5RLGEjfdJRGEUqGQtOUjDgGs2vvPBuC3ZAwr7Kv7.eFfwlXqVem2xfHyEAuKHhfjase25kXauW1pUySO+vlG+7ydAriM8Vq3xIbVBgKoDAr12WEAeV1HmCIw8j8W9OVVBqZX43gC.+WbLIR.b3U8saWk2slfHOkF2yr+1ikratRJYZs8.clgjvwnAaPBKFdvc415CqB+.M0ExrXgHPDBJ.EP5CpqVEhhP5wu7nya27zNGz4rlG2n44FytCnhGsMBDzQ.VxgXHjjioQnH8wqHRjK98Rk9SQu9MaWMjwQtJNn.g5aC+4OMMkAK9fGrRJNdaAVKYnnuK.T9bBXIswx9ts8TG8CY93n8XCiCDf+aUzqgXnx3N5gOtFPD95MqhpWq9J.97VMBopP.kdvQQcgZAUUVp+PNGvQiZOHNfbs1zqBJC7Q5Mjwua3vXeIkE6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zj5KkYicnv7.jlwWRhfZ9Za7WCE4CwCijYTKmFdDKlkzmESK4zOkH4zd8Hkhkl3AZWoDZltXL7ojHUKZEuY3PnwdLWMb4bhEd+W+VKln+525XLW83fn+W7aeTCyl4UMKbmtp48t89Sv0N1UJneGi9ql1jBnSkx+cNbx.1kD8fhntpKfHv7KCRnQkdMUUNd3fRuPHU2Y11p57l2ek8eyIuQuD0brbxYr1.+tB0L2jSgCypntQL+K5P+qja2cXhwV2Swgqe56AZdZh7dumxRrLSX26HLjaCWi3.Xf48nk8VpTXPEUujlmqqd1b2Wbf9g+M7IcQuw.FrnW1hEZC8Xh7JF+Bc5Y5usr+DkS5yb1WjjQBlKmcUCsGxDZaNTpgwTO7IN0qA+yvVaVznrZU1KX1Tlwu6.XfeY1I3EXwYvbrJOcmgBnu4fSh6.Lqav.BIsOVWK5dsv9.zNRMMhJMS04MDGS307GGOWxZyCgTXr48IWhAkbyZBw.dfYNP2VcEGXWp0MPhw.LuYbl9ta3aUQ6R1zuwAGiiFIH0JwyjriaHl2kknfuHx0YyJbirgaRwR0RKL+qQgMgH0.nPgdyJwAMpvAiPRxJSjMvwLVQW0V8zHkv0H8AhWoV0GGY8JUVfx+MWyyLgJqeoy3WVLJ8+IhzhF2241uF4RUvFG9VxUeyFi9+6Dy6bGMPKl+74lwuxAZ6cMj95QzO82O9wvQ9wPGCv9b149lKlTop+BME3bGqK0rjyQpmQdVWZRSyA1APq5m66WVT2ZiqMuab84ciaLuaby4ciOZd23Vy6Fe76dipIo1cnjMvjm.ST1tooJtsYXRcJi0+AOEuUE
-
@Mighty23 If I understand well you want a gradient for the inner vs outer part of the trace... Bad news, a gradient won't help you because the coordinates are seen in a rectangle area, meaning it is the whole curve that will be affected... don't know if I'm clear here... in other words, it's not following the shape you are drawing.
A shader is what you want for that kind of thing. But I did a trick in the past with a paint routine. Just make the colour with an alpha of let say 0.2, then draw the path with different thickness on top of each other. The downside is that you are drawing 5 times the same thing which is not very CPU friendly especially if the panel is large...
-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