AuburnSounds / AuburnSounds/Dplug

dplug:canvas enhancements

Open
#466 6 comments 0 reactions 0 assignees View on GitHub
Enhancement
Dominant language
D
Stars
564
Forks
34
PR merge metrics
No merged PRs in 30d

Description

- [x] **ways to do multiple lineTo in one call.**
- [ ] **Clipping rect**, to avoid reinitializing the canvas for each dirtyRect (need to fix gradients coordinates I think)
- [ ] Note that if we had arbitrary clipping rect, would redraw even less, perhaps doable in canvasity!
- [ ] Gradients coordinates should be transformed on use based on current matrix and not before, breaking => superseded by `canvasity` somehow
- [ ] fillStyle should be saveable, breaking too
- [x] **add even-odd rule** (savable state) in order to allows circles with holes
- [x] bypass transform if just a translation? => not worth it
- [ ] backport the new circle gradient from upstream `dg2d`, which is like in a browser
Behaviour observed in both Chrome and Firefox.
- [x] is it possible to blit on separate buffer then composite afterwards? In order to have more operations than source-over?
* blitting white on black can makes a coverage mask! => **yes, but only a few blend modes doable**
- [x] make extra sure no down reallocate are happening
- [x] it should be possible to pass an ImageRef!L16 as destination. Colors should be converted L16 to RGBA8, using the 1/3 trick, and blitted back. This will allow to remove more oldschool draw.d methods => superseded by `canvasity`
- [x] globalAlpha (non-optimal path), state-saveable => superseded by `canvasity`

````html

Your browser does not support the HTML5 canvas tag.

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);

```

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.

Contributor guide

Open the contributing guide

Research direction

Start with the dplug:canvas enhancement list and identify which unchecked items remain relevant, especially clipping rectangles and gradient-coordinate handling. Compare those items with canvasity and the upstream dg2d circle-gradient behavior mentioned in the issue. Done should be defined as a narrowed, current scope with corresponding canvas behavior and validation identified.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.