From e097e96b4ce335eefda343e4dd3f0d4c31f496b6 Mon Sep 17 00:00:00 2001 From: Tim Haywood Date: Wed, 16 Sep 2020 15:00:32 +1000 Subject: [PATCH 1/3] feat: add text style properties --- src/index.ts | 118 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 113 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 32d12cb..2f24710 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,7 +70,10 @@ export class Comp { const thisComp = new Comp(); export class PropertyGroup { - name: string = "property group base"; + readonly name: string = "property group base"; + constructor(groupName: string) { + this.name = groupName; + } } export type Value = @@ -138,7 +141,7 @@ export class Property { return new Key(); } propertyGroup(countUp: number): PropertyGroup { - return new PropertyGroup(); + return new PropertyGroup("property group from function"); } constructor(readonly value: T) {} } @@ -198,7 +201,10 @@ export class PathProperty extends Property { export type loopType = "cycle" | "pingpong" | "offset" | "continue"; -export class TransformGroup extends PropertyGroup { +export class Transform extends PropertyGroup { + constructor() { + super("Transform"); + } readonly anchorPoint: Property = new Property([0, 0]); readonly position: Property = new Property([0, 0]); readonly scale: Property = new Property([0, 0]); @@ -209,7 +215,108 @@ export class TransformGroup extends PropertyGroup { readonly rotationZ?: Property = new Property(0); } +export class TextStyle { + fontSize: number = 0; + setFontSize(fontSize: number): TextStyle { + this.fontSize = fontSize; + return this; + } + font: string = "Arial"; + setFont(font: string): TextStyle { + this.font = font; + return this; + } + setText(text: string): TextStyle { + return this; + } + isFauxBold: boolean = false; + setFauxBold(isFauxBold: boolean): TextStyle { + this.isFauxBold = isFauxBold; + return this; + } + isFauxItalic: boolean = false; + setFauxItalic(isFauxItalic: boolean): TextStyle { + this.isFauxItalic = isFauxItalic; + return this; + } + isAllCaps: boolean = false; + setAllCaps(isAllCaps: boolean): TextStyle { + this.isAllCaps = isAllCaps; + return this; + } + isSmallCaps: boolean = false; + setSmallCaps(isSmallCaps: boolean): TextStyle { + this.isSmallCaps = isSmallCaps; + return this; + } + tracking: number = 0; + setTracking(tracking: number): TextStyle { + this.tracking = tracking; + return this; + } + leading: number = 60; + setLeading(leading: number): TextStyle { + this.leading = leading; + return this; + } + autoLeading: boolean = false; + setAutoLeading(autoLeading: boolean): TextStyle { + this.autoLeading = autoLeading; + return this; + } + baselineShift: number = 0; + setBaselineShift(baselineShift: number): TextStyle { + this.baselineShift = baselineShift; + return this; + } + applyFill: boolean = true; + setApplyFill(applyFill: boolean): TextStyle { + this.applyFill = applyFill; + return this; + } + fillColor: [number, number, number] = [1, 1, 1]; + setFillColor(fillColor: [number, number, number]): TextStyle { + this.fillColor = fillColor; + return this; + } + applyStroke: boolean = false; + setApplyStroke(applyStroke: boolean): TextStyle { + this.applyStroke = applyStroke; + return this; + } + strokeColor: [number, number, number] = [1, 1, 1]; + setStrokeColor(strokeColor: [number, number, number]): TextStyle { + this.strokeColor = strokeColor; + return this; + } + strokeWidth: number = 0; + setStrokeWidth(strokeWidth: number): TextStyle { + this.strokeWidth = strokeWidth; + return this; + } +} + +export class SourceText extends Property { + constructor(value: string) { + super(value); + } + style = new TextStyle(); + getStyleAt(characterIndex: number, sampleTime: number = time) { + return this.style; + } +} + +export class Text extends PropertyGroup { + constructor() { + super("Text"); + } + readonly sourceText: SourceText = new SourceText("Source text value"); +} + export class MaterialOptions extends PropertyGroup { + constructor() { + super("Material Options"); + } readonly lightTransmission: Property = new Property(0); readonly castShadows: Property = new Property(false); readonly acceptsShadows: Property = new Property(false); @@ -277,8 +384,9 @@ export class Layer { readonly audioLevels?: Property = new Property(0); readonly timeRemap?: Property = new Property(0); readonly marker?: MarkerProperty; - readonly transform?: PropertyGroup = new TransformGroup(); - readonly materialOption?: PropertyGroup = new MaterialOptions(); + readonly transform?: Transform = new Transform(); + readonly text?: Text = new Text(); + readonly materialOption?: MaterialOptions = new MaterialOptions(); toComp(vec: Vector, time?: number): Vector { return vec; } From 66ecc86554f2c3789b4a732bb44cd7c13fcbe6ab Mon Sep 17 00:00:00 2001 From: Tim Haywood Date: Wed, 16 Sep 2020 15:12:59 +1000 Subject: [PATCH 2/3] add aditional text property groups --- src/index.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/index.ts b/src/index.ts index 2f24710..58cf170 100644 --- a/src/index.ts +++ b/src/index.ts @@ -306,11 +306,35 @@ export class SourceText extends Property { } } +export class TextPathOptions extends PropertyGroup { + constructor() { + super("Path Options"); + } + readonly path: string | undefined = "Mask 1"; + readonly reversePath?: boolean = false; + readonly perpendicularToPath?: Property = new Property(false); + readonly forceAlignment?: Property = new Property(false); + readonly firstMargin?: Property = new Property(0); + readonly lastMargin?: Property = new Property(0); +} + +export class TextMoreOptions extends PropertyGroup { + constructor() { + super("More Options"); + } + readonly anchorPointGrouping: number = 1; + readonly groupingAlignment: Property<[number, number]> = new Property([0, 0]); + readonly fillANdStroke: number = 1; + readonly interCharacterBlending: number = 1; +} + export class Text extends PropertyGroup { constructor() { super("Text"); } readonly sourceText: SourceText = new SourceText("Source text value"); + readonly pathOption: TextPathOptions = new TextPathOptions(); + readonly moreOption: TextMoreOptions = new TextMoreOptions(); } export class MaterialOptions extends PropertyGroup { From aa276b6e8d45724cd6430a9a8103ccb8f690f6a1 Mon Sep 17 00:00:00 2001 From: Tim Haywood Date: Wed, 16 Sep 2020 15:14:46 +1000 Subject: [PATCH 3/3] add x, y, z position to transform --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 58cf170..43dea7c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -207,6 +207,9 @@ export class Transform extends PropertyGroup { } readonly anchorPoint: Property = new Property([0, 0]); readonly position: Property = new Property([0, 0]); + readonly xPosition: Property = new Property(0); + readonly yPosition: Property = new Property(0); + readonly zPosition: Property = new Property(0); readonly scale: Property = new Property([0, 0]); readonly rotation: Property = new Property(0); readonly orientation?: Property = new Property([0, 0, 0]);