Group local mask shapes into editable components.
A local adjustment is now a list of shapes composited in order (add, subtract, intersect) instead of a single shape, so dodging and burning can be built from several brushes, gradients and auto masks without spending layer channels. Existing edits migrate on load: the flat layer fields become components[0], keeping geometry, invert, feather and the layer's blend mode unchanged. The panel gains a shape list with active-shape editing, and the render gate now asserts a subtract shape clears the group while an intersect keeps it.
This commit is contained in:
@@ -96,7 +96,7 @@ const PAGE_HTML = `<!doctype html>
|
||||
<script type="module">
|
||||
import { parsePreview16 } from '/src/lib/preview16.ts';
|
||||
import { Renderer } from '/src/gl/renderer.ts';
|
||||
import { defaultEdits, defaultLocalLayer } from '/src/lib/edits.ts';
|
||||
import { defaultEdits, defaultLocalComponent, defaultLocalLayer } from '/src/lib/edits.ts';
|
||||
const pre = document.getElementById('out');
|
||||
const half = (bits) => {
|
||||
const s = bits >> 15 ? -1 : 1;
|
||||
@@ -229,16 +229,48 @@ try {
|
||||
// curve and then with one that halves the output. The mask must leave the
|
||||
// frame alone with the identity curve and darken it with the real one.
|
||||
const maskLayer = defaultLocalLayer('radial', 0);
|
||||
maskLayer.feather = 0;
|
||||
maskLayer.radial = { cx: 0.5, cy: 0.5, rx: 1.2, ry: 1.2 };
|
||||
const maskShape = maskLayer.components[0];
|
||||
maskShape.feather = 0;
|
||||
maskShape.radial = { cx: 0.5, cy: 0.5, rx: 1.2, ry: 1.2 };
|
||||
const darkCurve = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 1, y: 0.4 },
|
||||
];
|
||||
const maskedEdits = defaultEdits();
|
||||
maskedEdits.local = [{ ...maskLayer, curve: [{ x: 0, y: 0 }, { x: 1, y: 1 }] }];
|
||||
renderer.render(maskedEdits, { width: w, height: h });
|
||||
const maskIdentityPixel = sampleBand(2);
|
||||
maskedEdits.local = [{ ...maskLayer, curve: [{ x: 0, y: 0 }, { x: 1, y: 0.4 }] }];
|
||||
maskedEdits.local = [{ ...maskLayer, curve: darkCurve }];
|
||||
renderer.render(maskedEdits, { width: w, height: h });
|
||||
const maskCurvePixel = sampleBand(2);
|
||||
|
||||
// Mask groups: a second shape has to composite into the layer's own mask.
|
||||
// Subtracting a frame-wide shape from an equally wide add shape clears the
|
||||
// group, so the darkened curve must stop touching the frame; intersecting
|
||||
// with the same shape keeps full coverage, so it must still darken.
|
||||
const groupShape = defaultLocalComponent('radial');
|
||||
groupShape.feather = 0;
|
||||
groupShape.radial = { cx: 0.5, cy: 0.5, rx: 1.2, ry: 1.2 };
|
||||
const groupEdits = defaultEdits();
|
||||
groupEdits.local = [
|
||||
{
|
||||
...maskLayer,
|
||||
curve: darkCurve,
|
||||
components: [maskShape, { ...groupShape, mode: 'subtract' }],
|
||||
},
|
||||
];
|
||||
renderer.render(groupEdits, { width: w, height: h });
|
||||
const maskGroupSubtractPixel = sampleBand(2);
|
||||
groupEdits.local = [
|
||||
{
|
||||
...maskLayer,
|
||||
curve: darkCurve,
|
||||
components: [maskShape, { ...groupShape, mode: 'intersect' }],
|
||||
},
|
||||
];
|
||||
renderer.render(groupEdits, { width: w, height: h });
|
||||
const maskGroupIntersectPixel = sampleBand(2);
|
||||
|
||||
pre.textContent = 'RESULT ' + JSON.stringify({
|
||||
clipPixels,
|
||||
clipRed: near(clipPixels[0], RED_MARK),
|
||||
@@ -261,6 +293,10 @@ try {
|
||||
maskCurvePixel,
|
||||
maskIdentityFlat: near(maskIdentityPixel, [61, 71, 89]),
|
||||
maskCurveDarkens: maskCurvePixel[0] < maskIdentityPixel[0] * 0.75,
|
||||
maskGroupSubtractPixel,
|
||||
maskGroupSubtractCleared: near(maskGroupSubtractPixel, maskIdentityPixel),
|
||||
maskGroupIntersectPixel,
|
||||
maskGroupIntersectDarkens: maskGroupIntersectPixel[0] < maskIdentityPixel[0] * 0.75,
|
||||
flagHonouredForBitmap: !same(proxyTop, proxyNoFlipTop),
|
||||
proxyTop: +proxyTop.toFixed(4),
|
||||
sidecarTop: +sideTop.toFixed(4),
|
||||
@@ -419,6 +455,10 @@ async function main() {
|
||||
`render check: mask curve identity=${JSON.stringify(result.maskIdentityPixel)}` +
|
||||
` darkened=${JSON.stringify(result.maskCurvePixel)}`,
|
||||
);
|
||||
console.log(
|
||||
`render check: mask group subtract=${JSON.stringify(result.maskGroupSubtractPixel)}` +
|
||||
` intersect=${JSON.stringify(result.maskGroupIntersectPixel)}`,
|
||||
);
|
||||
if (!result.matchTop || !result.matchBottom) {
|
||||
console.error(
|
||||
result.reversed
|
||||
@@ -450,6 +490,14 @@ async function main() {
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
if (!result.maskGroupSubtractCleared || !result.maskGroupIntersectDarkens) {
|
||||
console.error(
|
||||
'render check FAILED: mask group shapes are not compositing ' +
|
||||
`(subtract=${JSON.stringify(result.maskGroupSubtractPixel)}, ` +
|
||||
`intersect=${JSON.stringify(result.maskGroupIntersectPixel)}).`,
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
if (!result.shadowFollowsExposure) {
|
||||
console.error(
|
||||
'render check FAILED: the shadow clipping overlay does not follow Exposure; ' +
|
||||
|
||||
Reference in New Issue
Block a user