From 994584f13a550c889779cfddc47d2d13acc75dcf Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Sun, 23 Nov 2014 09:39:02 -0800 Subject: [PATCH] Shapes now handle radial gradient fills. Handled one sprite (new Anya attack) export including initializing a container with movie clip arguments for no apparent reason, so loosened SpriteParser a bit to handle this. --- app/lib/sprites/SpriteBuilder.coffee | 2 ++ app/lib/sprites/SpriteParser.coffee | 9 +++++++-- app/schemas/models/thang_type.coffee | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/lib/sprites/SpriteBuilder.coffee b/app/lib/sprites/SpriteBuilder.coffee index 91ee6a07e..dde680984 100644 --- a/app/lib/sprites/SpriteBuilder.coffee +++ b/app/lib/sprites/SpriteBuilder.coffee @@ -96,6 +96,8 @@ module.exports = class SpriteBuilder shape.graphics.lf shapeData.lf... else if shapeData.fc? shape.graphics.f @colorMap[shapeKey] or shapeData.fc + else if shapeData.rf? + shape.graphics.rf shapeData.rf... if shapeData.ls? shape.graphics.ls shapeData.ls... else if shapeData.sc? diff --git a/app/lib/sprites/SpriteParser.coffee b/app/lib/sprites/SpriteParser.coffee index 408664220..361dc8411 100644 --- a/app/lib/sprites/SpriteParser.coffee +++ b/app/lib/sprites/SpriteParser.coffee @@ -52,7 +52,7 @@ module.exports = class SpriteParser container.bounds[0] -= @width / 2 container.bounds[1] -= @height / 2 [shapeKeys, localShapes] = @getShapesFromBlock container, source - localContainers = @getContainersFromMovieClip container, source + localContainers = @getContainersFromMovieClip container, source, true # Added true because anya attack was breaking, but might break other imports addChildArgs = @getAddChildCallArguments container, source instructions = [] for bn in addChildArgs @@ -248,9 +248,13 @@ module.exports = class SpriteParser if fillCall.callee.property.name is 'lf' linearGradientFillSource = @subSourceFromRange fillCall.parent.range, source linearGradientFill = @grabFunctionArguments linearGradientFillSource.replace(/.*?lf\(/, 'lf('), true + else if fillCall.callee.property.name is 'rf' + radialGradientFillSource = @subSourceFromRange fillCall.parent.range, source + radialGradientFill = @grabFunctionArguments radialGradientFillSource.replace(/.*?lf\(/, 'lf('), true else fillColor = fillCall.arguments[0]?.value ? null - console.error 'What is this?! Not a fill!' unless fillCall.callee.property.name is 'f' + callName = fillCall.callee.property.name + console.error 'What is this?! Not a fill!', callName unless callName is 'f' strokeCall = node.parent.parent.parent.parent if strokeCall.object.callee.property.name is 'ls' linearGradientStrokeSource = @subSourceFromRange strokeCall.parent.range, source @@ -301,6 +305,7 @@ module.exports = class SpriteParser shape.ss = strokeStyle if strokeStyle shape.fc = fillColor if fillColor shape.lf = linearGradientFill if linearGradientFill + shape.rf = radialGradientFill if radialGradientFill shape.ls = linearGradientStroke if linearGradientStroke if name.search('shape') isnt -1 and shape.fc is 'rgba(0,0,0,0.451)' and not shape.ss and not shape.sc console.log 'Skipping a shadow', name, shape, 'because we\'re doing shadows separately now.' diff --git a/app/schemas/models/thang_type.coffee b/app/schemas/models/thang_type.coffee index 5f9183745..b32713a6c 100644 --- a/app/schemas/models/thang_type.coffee +++ b/app/schemas/models/thang_type.coffee @@ -7,6 +7,7 @@ c.extendNamedProperties ThangTypeSchema # name first ShapeObjectSchema = c.object {title: 'Shape'}, fc: {type: 'string', title: 'Fill Color'} lf: {type: 'array', title: 'Linear Gradient Fill'} + rf: {type: 'array', title: 'Radial Gradient Fill'} ls: {type: 'array', title: 'Linear Gradient Stroke'} p: {type: 'string', title: 'Path'} de: {type: 'array', title: 'Draw Ellipse'}