AuburnSounds / Dplug

Audio plugin framework. VST2/VST3/AU/AAX/LV2 for Linux/macOS/Windows.
https://dplug.org/
Other
486 stars 32 forks source link

dplug:canvas enhancements #466

Open p0nce opened 4 years ago

p0nce commented 4 years ago
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var grd = ctx.createRadialGradient(75, 50, 5, 90, 60, 100);
grd.addColorStop(0, "red");
grd.addColorStop(1, "white");
ctx.fillStyle = grd;
ctx.translate(20,0);
ctx.fillRect(10, 10, 150, 100);
ctx.translate(50,0);
ctx.fillRect(10, 120, 150, 100);
</script>
</body>
</html>

On second fillRect center of gradient is translated vs the first rectangle. It is indeed more intuitive on use. This will also allow to reuse gradients over several dirty rects.

I do'nt know how to do it in case of scale(x, y) with x different from y as then it's not circles anymore.

p0nce commented 4 years ago

But it gets much harder with scale since circles won't stay circles, this is actually supported in browsers. (EDIT: it worked, but wouldn't work if shearing was allowed)

p0nce commented 4 years ago

Point coord

p0nce commented 11 months ago

Reference for possible composite operations: https://www.w3schools.com/tags/playcanvas.php?filename=playcanvas_globalcompop

Is globalCompositeOperation implementable?

All explained in https://ssp.impulsetrain.com/porterduff.html

p0nce commented 11 months ago

From my understanding:

image
p0nce commented 11 months ago

Implemented sourceOver, add, subtract. We don't follow html spec here, in that background alpha is always assumed to be opaque (= 255). (EDIT: added lighten and darken modes too) Eventually we could also add globalAlpha which also breaks the fast path. Well that's 5 interesting modes without unpremultiply or redo the blitters.

p0nce commented 11 months ago

image