From c49f894ef27153c2ef6bc30c02ecf884e7e38032 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 24 Sep 2014 10:55:33 -0700 Subject: [PATCH] Refactored SPRITE_PLACEHOLDER_RADIUS to SPRITE_PLACEHOLDER_WIDTH. --- app/application.coffee | 2 +- app/lib/surface/LayerAdapter.coffee | 8 ++++---- app/lib/surface/SegmentedSprite.coffee | 8 ++++---- app/lib/surface/SingularSprite.coffee | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/application.coffee b/app/application.coffee index abe2df04f..fe13be467 100644 --- a/app/application.coffee +++ b/app/application.coffee @@ -11,7 +11,7 @@ marked.setOptions {gfm: true, sanitize: true, smartLists: true, breaks: false} # TODO, add C-style macro constants like this? window.SPRITE_RESOLUTION_FACTOR = 3 -window.SPRITE_PLACEHOLDER_RADIUS = 30 +window.SPRITE_PLACEHOLDER_WIDTH = 60 # Prevent Ctrl/Cmd + [ / ], P, S ctrlDefaultPrevented = [219, 221, 80, 83] diff --git a/app/lib/surface/LayerAdapter.coffee b/app/lib/surface/LayerAdapter.coffee index 0766ac69f..7e8b0febe 100644 --- a/app/lib/surface/LayerAdapter.coffee +++ b/app/lib/surface/LayerAdapter.coffee @@ -208,7 +208,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass return true if @willRender or not @buildAutomatically @willRender = _.defer => @renderNewSpriteSheet() return true - + #- Rendering sprite sheets renderNewSpriteSheet: -> @@ -223,10 +223,10 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass # The first frame is always the 'loading', ie placeholder, image. placeholder = @createPlaceholder() - dimension = @resolutionFactor*SPRITE_PLACEHOLDER_RADIUS*2 + dimension = @resolutionFactor * SPRITE_PLACEHOLDER_WIDTH placeholder.setBounds(0, 0, dimension, dimension) builder.addFrame(placeholder) - + groups = {} if NEVER_RENDER_ANYTHING for bundleGrouping in _.values(groups) thangType = bundleGrouping[0].thangType @@ -288,7 +288,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass g.setStrokeStyle(5) g.beginStroke(createjs.Graphics.getRGB(64,64,64)) g.beginFill(createjs.Graphics.getRGB(64,64,64,0.7)) - radius = @resolutionFactor*SPRITE_PLACEHOLDER_RADIUS + radius = @resolutionFactor * SPRITE_PLACEHOLDER_WIDTH / 2 g.drawCircle(radius, radius, radius) new createjs.Shape(g) diff --git a/app/lib/surface/SegmentedSprite.coffee b/app/lib/surface/SegmentedSprite.coffee index 85a6be2f8..815ed9c99 100644 --- a/app/lib/surface/SegmentedSprite.coffee +++ b/app/lib/surface/SegmentedSprite.coffee @@ -62,8 +62,8 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer bounds = @thangType.get('raw').containers[action.container].b sprite.x = bounds[0] sprite.y = bounds[1] - sprite.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) - sprite.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) + sprite.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) + sprite.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) else sprite.scaleX = sprite.scaleY = 1 / scale @children = [] @@ -125,8 +125,8 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer bounds = @thangType.get('raw').containers[localContainer.gn].b innerContainer.x = bounds[0] innerContainer.y = bounds[1] - innerContainer.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) - innerContainer.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) + innerContainer.scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) + innerContainer.scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) else innerContainer.scaleX = innerContainer.scaleY = 1 / (@resolutionFactor * (@thangType.get('scale') or 1)) outerContainer.addChild(innerContainer) diff --git a/app/lib/surface/SingularSprite.coffee b/app/lib/surface/SingularSprite.coffee index 5ea91ecf0..043c7ef26 100644 --- a/app/lib/surface/SingularSprite.coffee +++ b/app/lib/surface/SingularSprite.coffee @@ -36,8 +36,8 @@ module.exports = class WebGLSprite extends createjs.Sprite @_gotoAndStop(0) @notifyActionNeedsRender(action) bounds = @thangType.get('raw').animations[action.animation].bounds - @scaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) - @scaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) + @scaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) + @scaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) @regX = (- reg.x - bounds[0]) / @scaleX @regY = (- reg.y - bounds[1]) / @scaleY return @@ -57,8 +57,8 @@ module.exports = class WebGLSprite extends createjs.Sprite @_gotoAndStop(0) @notifyActionNeedsRender(action) bounds = @thangType.get('raw').containers[action.container].b - @scaleX = @baseScaleX = bounds[2] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) - @scaleY = @baseScaleY = bounds[3] / (SPRITE_PLACEHOLDER_RADIUS * @resolutionFactor * 2) + @scaleX = @baseScaleX = bounds[2] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) + @scaleY = @baseScaleY = bounds[3] / (SPRITE_PLACEHOLDER_WIDTH * @resolutionFactor) @regX = (bounds[0] - reg.x) / @scaleX @regY = (bounds[1] - reg.y) / @scaleY # I don't think you can properly position the placeholder without either