Lesson 17 — Raster Adjustments
Raster adjustments are non-destructive layers that sit above a pixel layer and modify its appearance without altering its pixel data. Every adjustment type has two things: a definition class (used to create a new node) and a command factory (used to modify an existing node's parameters).
What this lesson covers
- Creating adjustment layers programmatically via
*AdjustmentRasterNodeDefinitionfactories - Reading existing adjustment parameters from a selected node
- Setting parameters via
DocumentCommand.createSet*AdjustmentParameters - Every adjustment type the SDK exposes, with parameter ranges
- Inserting adjustments above a specific raster node
- RAW Develop nodes
- Destructive Halftone filter
Creating an adjustment layer
The pattern is the same for every adjustment type:
- Create a definition via
XxxAdjustmentRasterNodeDefinition.create(params)or.createDefault() - Add it via
AddChildNodesCommandBuilder.addXxxAdjustmentRasterNode(def) - Set
InsertionMode.InsideAtTopand target the raster node to place it inside that layer
'use strict';
const { Document } = require('/document.js');
const { BrightnessContrastAdjustmentRasterNodeDefinition } = require('/nodes.js');
const { AddChildNodesCommandBuilder, InsertionMode } = require('/commands.js');
const doc = Document.current;
const node = doc?.selection.nodes.first;
if (!node || !node.isRasterNode) {
console.log('Select a raster node first.');
} else {
const def = BrightnessContrastAdjustmentRasterNodeDefinition.create({
brightness: 0.3,
contrast: 0.2,
isLinear: false
});
const builder = AddChildNodesCommandBuilder.create();
builder.addBrightnessContrastAdjustmentRasterNode(def);
builder.setInsertionTarget(node);
builder.setInsertionMode(InsertionMode.InsideAtTop);
doc.executeCommand(builder.createCommand(true));
console.log('Brightness/Contrast adjustment added.');
}
The adjustment appears in the Layers panel as a child of the raster node, identical to one added manually via the menu.
Reading parameters from an existing adjustment node
To read the current parameters of an adjustment layer, check its type and access .parameters:
'use strict';
const { Document } = require('/document.js');
const Nodes = require('/nodes.js');
const doc = Document.current;
const node = doc?.selection.nodes.first;
if (node instanceof Nodes.BrightnessContrastAdjustmentRasterNode) {
const p = node.parameters;
console.log('Brightness:', p.brightness);
console.log('Contrast: ', p.contrast);
console.log('Linear: ', p.isLinear);
}
if (node instanceof Nodes.HSLShiftAdjustmentRasterNode) {
const p = node.parameters;
const m = p.masterParameters;
console.log('Hue shift: ', m.hueShift); // radians
console.log('Sat shift: ', m.saturationShift);
console.log('Lum shift: ', m.luminosityShift);
}
Brightness / Contrast
// Snippet
const def = BrightnessContrastAdjustmentRasterNodeDefinition.create({
brightness: 0.0, // -1.0 to 1.0
contrast: 0.0, // -1.0 to 1.0
isLinear: false
});
To modify an existing node:
// Snippet
doc.executeCommand(DocumentCommand.createSetBrightnessContrastAdjustmentParameters(sel, {
brightness: 0.3,
contrast: 0.2,
isLinear: false
}));
Levels
LevelsAdjustmentParameters holds a masterParameters object plus per-channel parameter objects (red, green, blue, and two colour-space-specific channels). All values are normalized 0.0–1.0; gamma range is 0.0–2.0.
'use strict';
const { Document } = require('/document.js');
const { DocumentCommand } = require('/commands.js');
const { Selection } = require('/selections.js');
const {
LevelsAdjustmentRasterNodeDefinition,
LevelsAdjustmentChannelParameters
} = require('/nodes.js');
const doc = Document.current;
const node = doc?.selection.nodes.first;
if (node) {
// Create with a default definition, then adjust master parameters
const def = LevelsAdjustmentRasterNodeDefinition.createDefault(doc);
const params = def.parameters;
params.masterParameters = {
blackLevel: 0.05, // lift shadows (0.0–1.0)
whiteLevel: 0.95, // clip highlights (0.0–1.0)
gamma: 1.0, // midpoint gamma (0.0–2.0; 1.0 = linear)
outputBlackLevel: 0.0,
outputWhiteLevel: 1.0
};
def.parameters = params; // write back after mutation
// Apply to selection
const sel = Selection.create(doc, node);
doc.executeCommand(DocumentCommand.createSetLevelsAdjustmentParameters(sel, params));
}
Curves
CurvesAdjustmentParameters holds a master spline and optional per-channel splines. Import Spline from /geometry.
'use strict';
const { Document } = require('/document.js');
const { DocumentCommand } = require('/commands.js');
const { Selection } = require('/selections.js');
const { CurvesAdjustmentRasterNodeDefinition, CurvesAdjustmentParameters } = require('/nodes.js');
const { Spline } = require('/geometry.js');
const doc = Document.current;
const node = doc?.selection.nodes.first;
if (node) {
const params = CurvesAdjustmentParameters.create();
// Build an S-curve: slightly boost contrast
const sCurve = Spline.create();
sCurve.insertPointXY(0.0, 0.0); // shadow anchor
sCurve.insertPointXY(0.25, 0.15); // shadow lift
sCurve.insertPointXY(0.75, 0.85); // highlight pull-down
sCurve.insertPointXY(1.0, 1.0); // highlight anchor
params.masterSpline = sCurve;
const def = CurvesAdjustmentRasterNodeDefinition.createDefault(doc);
def.parameters = params;
const sel = Selection.create(doc, node);
doc.executeCommand(DocumentCommand.createSetCurvesAdjustmentParameters(sel, params));
}
Per-channel splines use params.setChannelSpline(channel, spline) where channel indices are 0 = Red, 1 = Green, 2 = Blue.
HSL Shift
HSLShiftAdjustmentParameters.create() returns a parameters object. Call .setChannelParameters(channel, params) where channel 0 = master. hueShift is in radians (full circle = 2π ≈ 6.28).
'use strict';
const { Document } = require('/document.js');
const { DocumentCommand } = require('/commands.js');
const { Selection } = require('/selections.js');
const {
HSLShiftAdjustmentRasterNodeDefinition,
HSLShiftAdjustmentParameters
} = require('/nodes.js');
const doc = Document.current;
const node = doc?.selection.nodes.first;
if (node) {
const hslParams = HSLShiftAdjustmentParameters.create();
// Shift master channel
hslParams.setChannelParameters(0, {
hueShift: 0.1, // radians
saturationShift: 0.2, // -1.0 to 1.0
luminosityShift: 0.0 // -1.0 to 1.0
});
const def = HSLShiftAdjustmentRasterNodeDefinition.create(hslParams);
const sel = Selection.create(doc, node);
doc.executeCommand(DocumentCommand.createSetHSLShiftAdjustmentParameters(sel, hslParams));
}
White Balance
// Snippet
doc.executeCommand(DocumentCommand.createSetWhiteBalanceAdjustmentParameters(sel, {
whiteBalance: 0.3, // -1.0 (cool) to 1.0 (warm)
tint: 0.0 // -1.0 to 1.0
}));
Vibrance
// Snippet
doc.executeCommand(DocumentCommand.createSetVibranceAdjustmentParameters(sel, {
vibrance: 0.4, // -1.0 to 1.0
saturation: 0.1 // -1.0 to 1.0
}));
Exposure
// Snippet
doc.executeCommand(DocumentCommand.createSetExposureAdjustmentParameters(sel, {
exposure: 1.5 // -20.0 to 20.0 (EV stops)
}));
Colour Balance
Applies to shadow, midtone, and highlight tonal ranges independently. Range index: 0 = Highlights, 1 = Midtones, 2 = Shadows (use TonalRangeType enum if available, or the integer directly).
// Snippet
doc.executeCommand(DocumentCommand.createSetColourBalanceAdjustmentParameters(sel, {
values: [
{ cyanRed: 0.1, magentaGreen: -0.1, yellowBlue: 0.0 }, // highlights
{ cyanRed: 0.0, magentaGreen: 0.1, yellowBlue: 0.0 }, // midtones
{ cyanRed: 0.0, magentaGreen: 0.0, yellowBlue: 0.1 } // shadows
],
preserveLuminosity: true
}));
Posterise
// Snippet
doc.executeCommand(DocumentCommand.createSetPosteriseAdjustmentParameters(sel, {
levels: 4 // 2 to 256 integer
}));
Threshold
// Snippet
doc.executeCommand(DocumentCommand.createSetThresholdAdjustmentParameters(sel, {
threshold: 0.5 // 0.0 to 1.0
}));
Invert
InvertAdjustmentRasterNodeDefinition has no parameters — it just inverts all channels.
// Snippet
const { InvertAdjustmentRasterNodeDefinition } = require('/nodes.js');
const def = InvertAdjustmentRasterNodeDefinition.create();
Recolour
Maps all colours to a single hue/saturation (like a tinted duotone).
// Snippet
doc.executeCommand(DocumentCommand.createSetRecolourAdjustmentParameters(sel, {
hue: 1.0, // 0.0 to 2π radians
saturation: 0.8, // 0.0 to 1.0
lightness: 0.0 // -1.0 to 1.0
}));
Split Toning
Applies separate hue/saturation to highlights and shadows.
// Snippet
doc.executeCommand(DocumentCommand.createSetSplitToningAdjustmentParameters(sel, {
highlightsHue: 0.1, // 0.0 to 2π
highlightsSaturation: 0.3,
shadowsHue: 3.5,
shadowsSaturation: 0.2,
balance: 0.5 // 0.0 (shadows) to 1.0 (highlights)
}));
Black & White
Converts to greyscale with per-channel luminance weights.
// Snippet
doc.executeCommand(DocumentCommand.createSetBlackAndWhiteAdjustmentParameters(sel, {
red: 0.4, // -2.0 to 3.0
green: 0.6,
blue: 0.2,
cyan: 0.5,
magenta: 0.3,
yellow: 0.5
}));
Tone Compression and Tone Stretch
Used in HDR / tone-mapping workflows.
// Snippet
const { ToneCompressionMethod } = require('/nodes.js');
doc.executeCommand(DocumentCommand.createSetToneCompressionAdjustmentParameters(sel, {
method: ToneCompressionMethod.Reinhard, // or check available enum values
exposure: 1.0, // 0.0 to 2.0
gamma: 1.0, // 0.0 to 2.0
colour: 1.0 // 0.0 to 1.0
}));
Normals (normal map rotation)
Used on normal map textures.
// Snippet
doc.executeCommand(DocumentCommand.createSetNormalsAdjustmentParameters(sel, {
rotation: 0.0, // -π to π radians
scale: 1.0, // 0.0 to 2.0
flipX: false,
flipY: false
}));
RAW Develop
A DevelopNode represents a RAW image opened in the Develop persona. Unlike the adjustment nodes above, it is not created programmatically — it appears when the user opens a RAW file. Read its DevelopParameters via .parameters and .sourceIsRaw, then push changes back with createSetDevelopParameters.
'use strict';
const { Document } = require('/document.js');
const { DocumentCommand } = require('/commands.js');
const Nodes = require('/nodes.js');
const doc = Document.current;
if (!doc) { console.log('No document open.'); }
else {
const developNode = doc.layers.all.find(n => n.isDevelopNode);
if (!developNode) {
console.log('No RAW develop node found — open a RAW file first.');
} else {
const params = developNode.parameters;
console.log('Source is RAW:', developNode.sourceIsRaw);
// Tweak the develop parameters, then write back:
// doc.executeCommand(DocumentCommand.createSetDevelopParameters(
// doc.selection, params));
console.log('Develop parameters read.');
}
}
Supporting enums (from /nodes): DevelopDetailRefinementMethod (UnsharpMask/HighPass/MultiBand), DevelopToneCurveMethod (Standard/Compressed/Natural/HighContrast/Log), and DevelopInvertMethod (InfraredRB/InfraredRGB/Negative). There is no addDevelopNode builder method — RAW develop nodes are created by the application, not by scripts.
All adjustment types — quick reference
| Adjustment | Definition class | Parameter command |
|---|---|---|
| Brightness/Contrast | BrightnessContrastAdjustmentRasterNodeDefinition | createSetBrightnessContrastAdjustmentParameters |
| Levels | LevelsAdjustmentRasterNodeDefinition | createSetLevelsAdjustmentParameters |
| Curves | CurvesAdjustmentRasterNodeDefinition | createSetCurvesAdjustmentParameters |
| HSL Shift | HSLShiftAdjustmentRasterNodeDefinition | createSetHSLShiftAdjustmentParameters |
| White Balance | WhiteBalanceAdjustmentRasterNodeDefinition | createSetWhiteBalanceAdjustmentParameters |
| Vibrance | VibranceAdjustmentRasterNodeDefinition | createSetVibranceAdjustmentParameters |
| Exposure | ExposureAdjustmentRasterNodeDefinition | createSetExposureAdjustmentParameters |
| Colour Balance | ColourBalanceAdjustmentRasterNodeDefinition | createSetColourBalanceAdjustmentParameters |
| Shadows/Highlights | ShadowsHighlightsAdjustmentRasterNodeDefinition | createSetShadowsHighlightsAdjustmentParameters |
| Posterise | PosteriseAdjustmentRasterNodeDefinition | createSetPosteriseAdjustmentParameters |
| Threshold | ThresholdAdjustmentRasterNodeDefinition | createSetThresholdAdjustmentParameters |
| Invert | InvertAdjustmentRasterNodeDefinition | (no parameters) |
| Recolour | RecolourAdjustmentRasterNodeDefinition | createSetRecolourAdjustmentParameters |
| Black & White | BlackAndWhiteAdjustmentRasterNodeDefinition | createSetBlackAndWhiteAdjustmentParameters |
| Split Toning | SplitToningAdjustmentRasterNodeDefinition | createSetSplitToningAdjustmentParameters |
| Selective Colour | SelectiveColourAdjustmentRasterNodeDefinition | createSetSelectiveColourAdjustmentParameters |
| Tone Compression | ToneCompressionAdjustmentRasterNodeDefinition | createSetToneCompressionAdjustmentParameters |
| Tone Stretch | ToneStretchAdjustmentRasterNodeDefinition | createSetToneStretchAdjustmentParameters |
| Normals | NormalsAdjustmentRasterNodeDefinition | createSetNormalsAdjustmentParameters |
Live filters vs adjustments
Adjustments are non-destructive layers. Live filters are the destructive counterpart: DocumentCommand.create*Filter(sel, params) applies that filter to the selection in one step, and createSet*FilterParameters(sel, params) retunes an already-applied live filter. The pattern matches adjustments — factory plus parameter setter — but there is no node:
'use strict';
const { Document } = require('/document.js');
const { DocumentCommand } = require('/commands.js');
const { BloomFilterParameters } = require('/nodes.js');
const doc = Document.current;
const sel = doc?.selection;
if (!sel?.nodes || sel.nodes.isEmpty) { console.log('Select a raster node first.'); }
else {
const params = BloomFilterParameters.create();
doc.executeCommand(DocumentCommand.createBloomFilter(sel, params));
console.log('Bloom filter applied.');
}
Available live-filter families: AddNoise, BilateralBlur, Bloom, BoxBlur, Clarity, Defringe, Denoise, DepthOfField, Diffuse, DiffuseGlow, DustAndScratch, FieldBlur, HighPass, LensBlur, MaximumBlur, MedianBlur, MinimumBlur, MotionBlur, PinchPunch, Pixelate, RadialBlur, Ripple, ShadowsHighlights, Spherical, Twirl, UnsharpMask, Voronoi. Each has create*Filter and createSet*FilterParameters factories following the Bloom example above.
Handle-backed parameters
Every adjustment and live-filter parameter class is a handle-backed object. Create it with the static create() factory — never new — edit through its properties, and pass it to node definitions or command factories:
// Snippet — assumes LevelsAdjustmentParameters is required from /nodes.js
const parameters = LevelsAdjustmentParameters.create();
parameters.masterParameters.gamma = 1.2;
parameters.channelParameters[0].blackLevel = 0.1;
Nested structures are live views: assigning a field writes through to the containing parameter object. Colour Balance, Levels and Selective Colour arrays also accept whole-array assignment. Out-of-range reads return undefined; out-of-range writes throw RangeError. Count and callback-based enumeration APIs cover Colour Balance tonal-range values, Curves channel splines, HSL channel parameters and colour ranges, Levels channel parameters, Selective Colour weights, and Field Blur items.
HalftoneFilter
HalftoneFilter is a raster filter that applies a halftone screen effect. Two approaches:
Direct apply (via /nodes)
Applied via createSetHalftoneFilterParameters on a selection — no CompoundCommandBuilder.
'use strict';
const { Document } = require('/document.js');
const { DocumentCommand } = require('/commands.js');
const { HalftoneFilterParameters, HalftoneScreenType, HalftoneDotType } = require('/nodes.js');
const doc = Document.current;
const sel = doc.selection;
if (!sel.nodes.isEmpty) {
const params = HalftoneFilterParameters.create();
params.screenType = HalftoneScreenType.Colour; // Colour, Grey, Line, Dot
params.dotType = HalftoneDotType.Round; // Round, Square, Diamond, Line
params.cellSize = 32; // cell size in pixels
params.screenAngle = Math.PI / 6; // angle in radians
params.contrast = 75; // contrast percentage
params.greyComponentReplacement = 25; // GCR percentage
params.underColourRemoval = 10; // UCR percentage
doc.executeCommand(DocumentCommand.createSetHalftoneFilterParameters(sel, params));
console.log('Halftone filter applied.');
}
HalftoneFilter is not a
CompoundCommandBuilderoperation. Execute it directly viaexecuteCommand. Do not wrap it in a compound command — it silently fails.
HalftoneScreenType values: Colour, Grey, Line, Dot.
HalftoneDotType values: Round, Square, Diamond, Line, Ellipse, Character, Custom.
Live filter node (via /nodes)
HalftoneFilterRasterNode is a live filter node with full HalftoneFilterParameters:
'use strict';
const { Document } = require('/document.js');
const { HalftoneFilterRasterNodeDefinition } = require('/nodes.js');
const { AddChildNodesCommandBuilder, InsertionMode } = require('/commands.js');
const doc = Document.current;
const node = doc?.selection.nodes.filter(n => n.isRasterNode).first;
if (!node) { console.log('Select a raster node.'); }
else {
const def = HalftoneFilterRasterNodeDefinition.createDefault();
const builder = AddChildNodesCommandBuilder.create();
builder.addHalftoneFilterRasterNode(def);
builder.setInsertionTarget(node);
builder.setInsertionMode(InsertionMode.InsideAtTop);
doc.executeCommand(builder.createCommand(true));
// Modify parameters later
const { HalftoneScreenType, HalftoneDotType } = require('/nodes.js');
doc.executeCommand(DocumentCommand.createSetHalftoneFilterRasterNodeParameters(
sel, // the halftone node
HalftoneScreenType.Screen, // Screen, Dot, Line
HalftoneDotType.Sine, // Sine, Round, Diamond, Line, Square, Ellipse
0.5, // cell size
45, // screen angle (degrees)
0.1, // contrast
0, // grey-component replacement
0 // under-colour removal
));
console.log('Live halftone filter node added.');
}
Key gotchas
createDefault(doc) requires the document argument for Levels and Curves. Both LevelsAdjustmentRasterNodeDefinition.createDefault(doc) and CurvesAdjustmentRasterNodeDefinition.createDefault(doc) require a document handle. Calling them with no argument throws.
Write back after mutating a parameters object. For Levels: read def.parameters, mutate the result, then set def.parameters = params. The object is not a live reference.
setChannelParameters for HSL takes an integer channel index, not an enum. Channel 0 = master, 1–6 = individual colour ranges. Using the wrong index is a silent no-op.
Hue values are in radians. Both RecolourAdjustmentParameters.hue and HSLShiftAdjustmentChannelParameters.hueShift are in radians. Full circle = 2π (≈ 6.283). To convert degrees: degrees * Math.PI / 180.
InsertionMode.InsideAtTop places the adjustment above the raster node's content. For a simple document where the raster node has no children, any insertion mode works. If the raster node already has children (e.g. masks), use InsideAtTop to ensure the adjustment is the topmost child.
Adjustment layers only affect raster pixel data. Adding a Curves layer above a vector shape has no visual effect — the shape must be rasterised first.
Exercises
Exercise 17.1 — Batch brightness boost
Select multiple raster nodes. Add a Brightness/Contrast adjustment (brightness: 0.2, contrast: 0.1) inside each. Use CompoundCommandBuilder to make the whole operation a single undo step.
Exercise 17.2 — Levels dialog
Show a dialog with five UnitValueEditor controls (black, white, gamma, output black, output white). Apply the chosen values as a Levels adjustment on the selected raster node. Use live preview while the dialog is open.
Exercise 17.3 — HSL shift batch
Walk every raster node in the document. On each, add an HSL adjustment that boosts saturation by 0.15 and shifts hue by +0.1 radians. Log a count of adjusted layers.
Exercise 17.4 — Invert stack reporter
Walk every node in the document tree. Find any InvertAdjustmentRasterNode and log its parent node's name. Count the total.
SDK modules used in this lesson
/nodes— All*AdjustmentRasterNodeDefinitionand*AdjustmentRasterNodeclasses,CurvesAdjustmentParameters,HSLShiftAdjustmentParameters,LevelsAdjustmentChannelParameters,ToneCompressionMethod,ToneStretchMethod/commands—DocumentCommand,AddChildNodesCommandBuilder,InsertionMode/document—Document/selections—Selection/geometry—Spline(for Curves)/layereffects—HalftoneFilter
See also
Example scripts
17a-brightness-batch.js
Download 17a-brightness-batch.js
'use strict';
// Example 16a — Brightness batch adjuster
// Lesson 16: Raster Adjustments
//
// Adds a Brightness/Contrast adjustment layer inside every selected raster node.
// All additions are wrapped in a CompoundCommand for single-step undo.
//
// Usage: select one or more raster/image nodes, then run.
const { Document } = require('/document.js');
const { BrightnessContrastAdjustmentRasterNodeDefinition } = require('/nodes.js');
const { AddChildNodesCommandBuilder, CompoundCommandBuilder, InsertionMode } = require('/commands.js');
const BRIGHTNESS = 0.2; // -1.0 to 1.0
const CONTRAST = 0.1; // -1.0 to 1.0
const doc = Document.current;
if (!doc) { console.log('No document open.'); }
else {
const nodes = [...doc.selection.nodes].filter(n => n.isRasterNode || n.isImageNode);
if (nodes.length === 0) {
console.log('Select at least one raster or image node.');
} else {
const compound = CompoundCommandBuilder.create();
for (const node of nodes) {
const def = BrightnessContrastAdjustmentRasterNodeDefinition.create({
brightness: BRIGHTNESS,
contrast: CONTRAST,
isLinear: false
});
const builder = AddChildNodesCommandBuilder.create();
builder.addBrightnessContrastAdjustmentRasterNode(def);
builder.setInsertionTarget(node);
builder.setInsertionMode(InsertionMode.InsideAtTop);
compound.addCommand(builder.createCommand(false));
}
doc.executeCommand(compound.createCommand());
console.log(`Brightness/Contrast adjustment added to ${nodes.length} node(s).`);
}
}
17b-levels-dialog.js
'use strict';
// Example 16b — Levels dialog with live preview
// Lesson 16: Raster Adjustments
//
// Shows a dialog with controls for the five Levels master parameters.
// Applies a live preview while the dialog is open and commits on OK.
//
// Usage: select a raster or image node, then run.
const { Document } = require('/document.js');
const { DocumentCommand, AddChildNodesCommandBuilder, InsertionMode } = require('/commands.js');
const { Dialog, DialogResult } = require('/dialog.js');
const { LevelsAdjustmentRasterNodeDefinition } = require('/nodes.js');
const { Selection } = require('/selections.js');
const { UnitType } = require('/units.js');
const doc = Document.current;
const node = doc?.selection.nodes.first;
if (!doc || !node || (!node.isRasterNode && !node.isImageNode)) {
console.log('Select a raster or image node first.');
} else {
const dlg = Dialog.create('Levels');
const col = dlg.addColumn();
const grp = col.addGroup('Master channel');
const blackEdit = grp.addUnitValueEditor('Black', UnitType.Percentage, UnitType.Percentage, 0, 0, 100);
const whiteEdit = grp.addUnitValueEditor('White', UnitType.Percentage, UnitType.Percentage, 100, 0, 100);
const gammaEdit = grp.addUnitValueEditor('Gamma', UnitType.Percentage, UnitType.Percentage, 100, 1, 200);
const outBEdit = grp.addUnitValueEditor('Output black', UnitType.Percentage, UnitType.Percentage, 0, 0, 100);
const outWEdit = grp.addUnitValueEditor('Output white', UnitType.Percentage, UnitType.Percentage, 100, 0, 100);
function buildParams() {
return {
blackLevel: blackEdit.value / 100,
whiteLevel: whiteEdit.value / 100,
gamma: gammaEdit.value / 100,
outputBlackLevel: outBEdit.value / 100,
outputWhiteLevel: outWEdit.value / 100
};
}
function applyPreview(preview) {
const def = LevelsAdjustmentRasterNodeDefinition.createDefault(doc);
const params = def.parameters;
Object.assign(params.masterParameters, buildParams());
def.parameters = params;
const builder = AddChildNodesCommandBuilder.create();
builder.addLevelsAdjustmentRasterNode(def);
builder.setInsertionTarget(node);
builder.setInsertionMode(InsertionMode.InsideAtTop);
doc.executeCommand(builder.createCommand(false), preview);
}
dlg.onControlValueChangedHandler = () => applyPreview(true);
applyPreview(true);
while (dlg.runModal() == DialogResult.Ok) {
applyPreview(false);
break;
}
doc.clearPreviews();
console.log('Done.');
}