brand-intent 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/parser/compositionParser.ts +10 -1
package/package.json
CHANGED
|
@@ -34,6 +34,8 @@ export interface ParsedIllustration {
|
|
|
34
34
|
fit: 'width' | 'height';
|
|
35
35
|
/** Scale as fraction 0–1 (e.g. 0.9 = 90% of canvas dimension). */
|
|
36
36
|
scale: number;
|
|
37
|
+
/** Offset from anchor position in % of canvas [x, y]. Positive = right/down. */
|
|
38
|
+
offset?: [number, number];
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
const ILLUSTRATION_ANCHORS = new Set<string>([
|
|
@@ -296,7 +298,14 @@ export function parseCompositionFile(content: string, fileName: string): ParsedC
|
|
|
296
298
|
if (!scaleMatch) throw new Error(`${fileName}:${lineNum}: invalid illustration scale "${scaleStr}" (expected e.g. "90%")`);
|
|
297
299
|
const scale = parseFloat(scaleMatch[1]) / 100;
|
|
298
300
|
if (scale <= 0 || scale > 2) throw new Error(`${fileName}:${lineNum}: illustration scale out of range (expected 1%–200%)`);
|
|
299
|
-
|
|
301
|
+
const illu: ParsedIllustration = { anchor: anchor as IllustrationAnchor, fit: fitStr === 'fit-width' ? 'width' : 'height', scale };
|
|
302
|
+
// Optional: "offset X Y" in % of canvas (positive = right/down)
|
|
303
|
+
if (parts.length >= 5 && parts[3] === 'offset') {
|
|
304
|
+
const ox = parseFloat(parts[4]);
|
|
305
|
+
const oy = parts.length >= 6 ? parseFloat(parts[5]) : 0;
|
|
306
|
+
if (!isNaN(ox) && !isNaN(oy)) illu.offset = [ox, oy];
|
|
307
|
+
}
|
|
308
|
+
illustration = illu;
|
|
300
309
|
continue;
|
|
301
310
|
}
|
|
302
311
|
|