|
| 1 | +// Looks: ready-made global settings. Applying one resets the global sections to |
| 2 | +// their defaults and blends the look in with the requested strength; geometry |
| 3 | +// and local retouching are left alone. |
| 4 | +import { DEFAULT_EDIT, GLOBAL_SECTIONS } from '../state/defaults.js'; |
| 5 | + |
| 6 | +export const LOOKS = [ |
| 7 | + { id: 'original', label: 'Original', values: {} }, |
| 8 | + { |
| 9 | + id: 'portrait', |
| 10 | + label: 'Portrait', |
| 11 | + values: { |
| 12 | + tune: { brightness: 8, shadows: 20, highlights: -12, temperature: 8, vibrance: 15, saturation: -5 }, |
| 13 | + details: { structure: -18 }, |
| 14 | + effects: { glow: 12, vignette: -15 }, |
| 15 | + }, |
| 16 | + }, |
| 17 | + { |
| 18 | + id: 'landscape', |
| 19 | + label: 'Paysage', |
| 20 | + values: { |
| 21 | + tune: { contrast: 15, highlights: -30, shadows: 25, vibrance: 35 }, |
| 22 | + details: { structure: 30, sharpen: 25 }, |
| 23 | + hdr: { strength: 20, detail: 40, spread: 70 }, |
| 24 | + }, |
| 25 | + }, |
| 26 | + { |
| 27 | + id: 'bright', |
| 28 | + label: 'Lumineux', |
| 29 | + values: { |
| 30 | + tune: { brightness: 25, contrast: -10, highlights: -25, shadows: 30, temperature: 6, vibrance: 15 }, |
| 31 | + }, |
| 32 | + }, |
| 33 | + { |
| 34 | + id: 'hdr-natural', |
| 35 | + label: 'HDR naturel', |
| 36 | + values: { |
| 37 | + tune: { highlights: -20, shadows: 15 }, |
| 38 | + hdr: { strength: 45, detail: 40, spread: 65, saturation: 10 }, |
| 39 | + }, |
| 40 | + }, |
| 41 | + { |
| 42 | + id: 'hdr-strong', |
| 43 | + label: 'HDR intense', |
| 44 | + values: { |
| 45 | + details: { structure: 25 }, |
| 46 | + hdr: { strength: 85, detail: 80, spread: 35, saturation: 30 }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + { |
| 50 | + id: 'drama', |
| 51 | + label: 'Drame', |
| 52 | + values: { |
| 53 | + tune: { contrast: 20, saturation: -35 }, |
| 54 | + hdr: { strength: 60, detail: 90, spread: 20 }, |
| 55 | + effects: { vignette: -35 }, |
| 56 | + }, |
| 57 | + }, |
| 58 | + { |
| 59 | + id: 'matte', |
| 60 | + label: 'Mat', |
| 61 | + values: { |
| 62 | + tune: { contrast: -15, blacks: 35, saturation: -15 }, |
| 63 | + split: { shadowHue: 220, shadowAmount: 18, highlightHue: 40, highlightAmount: 12 }, |
| 64 | + }, |
| 65 | + }, |
| 66 | + { |
| 67 | + id: 'film', |
| 68 | + label: 'Film', |
| 69 | + values: { |
| 70 | + tune: { contrast: 12, highlights: -20, blacks: 15, saturation: -10, temperature: 5 }, |
| 71 | + split: { shadowHue: 190, shadowAmount: 12, highlightHue: 45, highlightAmount: 10 }, |
| 72 | + effects: { grain: 25, grainSize: 35 }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + { |
| 76 | + id: 'vintage', |
| 77 | + label: 'Vintage', |
| 78 | + values: { |
| 79 | + tune: { contrast: -10, blacks: 25, saturation: -25, temperature: 25 }, |
| 80 | + split: { shadowHue: 200, shadowAmount: 20, highlightHue: 45, highlightAmount: 25 }, |
| 81 | + effects: { vignette: -35, grain: 30 }, |
| 82 | + }, |
| 83 | + }, |
| 84 | + { |
| 85 | + id: 'teal-orange', |
| 86 | + label: 'Ciné', |
| 87 | + values: { |
| 88 | + tune: { contrast: 15, vibrance: 15, highlights: -15 }, |
| 89 | + split: { shadowHue: 195, shadowAmount: 45, highlightHue: 30, highlightAmount: 40, balance: 10 }, |
| 90 | + }, |
| 91 | + }, |
| 92 | + { |
| 93 | + id: 'cold', |
| 94 | + label: 'Froid', |
| 95 | + values: { |
| 96 | + tune: { contrast: 10, highlights: -10, temperature: -25, tint: 5, saturation: -10 }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + { |
| 100 | + id: 'bw', |
| 101 | + label: 'N&B', |
| 102 | + values: { |
| 103 | + tune: { contrast: 20 }, |
| 104 | + bw: { amount: 100, filter: 'neutral' }, |
| 105 | + }, |
| 106 | + }, |
| 107 | + { |
| 108 | + id: 'bw-contrast', |
| 109 | + label: 'N&B contrasté', |
| 110 | + values: { |
| 111 | + tune: { contrast: 45, blacks: -20 }, |
| 112 | + details: { structure: 25 }, |
| 113 | + bw: { amount: 100, filter: 'red' }, |
| 114 | + effects: { vignette: -20, grain: 15 }, |
| 115 | + }, |
| 116 | + }, |
| 117 | + { |
| 118 | + id: 'noir', |
| 119 | + label: 'Noir', |
| 120 | + values: { |
| 121 | + tune: { contrast: 30 }, |
| 122 | + bw: { amount: 100, filter: 'yellow' }, |
| 123 | + effects: { glow: 25, vignette: -50, grain: 40 }, |
| 124 | + }, |
| 125 | + }, |
| 126 | + { |
| 127 | + id: 'sepia', |
| 128 | + label: 'Sépia', |
| 129 | + values: { |
| 130 | + tune: { contrast: 10 }, |
| 131 | + bw: { amount: 100, filter: 'orange' }, |
| 132 | + split: { shadowHue: 30, shadowAmount: 40, highlightHue: 45, highlightAmount: 30 }, |
| 133 | + }, |
| 134 | + }, |
| 135 | +]; |
| 136 | + |
| 137 | +// Hues and enumerations are taken as is; numbers are blended from the default. |
| 138 | +function blend(defaults, values, amount) { |
| 139 | + const out = { ...defaults }; |
| 140 | + for (const [key, value] of Object.entries(values)) { |
| 141 | + const base = defaults[key]; |
| 142 | + if (typeof value === 'number' && typeof base === 'number' && !/Hue$/.test(key)) { |
| 143 | + out[key] = Math.round(base + (value - base) * amount); |
| 144 | + } else if (value && typeof value === 'object' && !Array.isArray(value)) { |
| 145 | + out[key] = blend(base ?? {}, value, amount); |
| 146 | + } else { |
| 147 | + out[key] = value; |
| 148 | + } |
| 149 | + } |
| 150 | + return out; |
| 151 | +} |
| 152 | + |
| 153 | +export function applyLook(edit, values, amount = 1) { |
| 154 | + const next = { ...edit }; |
| 155 | + for (const section of GLOBAL_SECTIONS) { |
| 156 | + next[section] = values[section] |
| 157 | + ? blend(DEFAULT_EDIT[section], values[section], amount) |
| 158 | + : DEFAULT_EDIT[section]; |
| 159 | + } |
| 160 | + return next; |
| 161 | +} |
0 commit comments