Created
August 31, 2012 22:39
-
-
Save nuzelac/3560268 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setStrokeColor = function(strokeColor) { | |
var currentLayerEffects, currentStroke, key, layer, newLayerEffects, newStroke, target, _i, _j, _len, _len1, _ref, _ref1, effectColor; | |
currentLayerEffects = getTargetLayerEffects(); | |
currentStroke = currentLayerEffects.getObjectValue($t('frameFX')); | |
newLayerEffects = new ActionDescriptor(); | |
newStroke = new ActionDescriptor(); | |
effectColor = new ActionDescriptor(); | |
effectColor.putDouble(charIDToTypeID("Rd "), strokeColor.rgb.red); | |
effectColor.putDouble(charIDToTypeID("Grn "), strokeColor.rgb.green); | |
effectColor.putDouble(charIDToTypeID("Bl "), strokeColor.rgb.blue); | |
// loop through the keys of currentStroke, copying them over, | |
// unless the key is 'color', in which case set it to strokeColor argument | |
_ref = getKeys(currentStroke); | |
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
key = _ref[_i]; | |
if (key === ($t('color'))) { | |
newStroke.putObject(charIDToTypeID("Clr "), charIDToTypeID("RGBC"), effectColor); | |
} else { | |
copyDescriptorValue(currentStroke, newStroke, key); | |
} | |
} | |
// loop through the keys of currentLayerEffects, copying them over, | |
// unless the key is 'frameFX' (stroke ID), in which case set it to newStroke | |
_ref1 = getKeys(currentLayerEffects); | |
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { | |
key = _ref1[_j]; | |
if (key === ($t('frameFX'))) { | |
newLayerEffects.putObject($t('frameFX'), $t('frameFX'), newStroke); | |
} else { | |
copyDescriptorValue(currentLayerEffects, newLayerEffects, key); | |
} | |
} | |
layer = new ActionDescriptor(); | |
layer.putObject($t('layerEffects'), $t('layerFXVisible'), newLayerEffects); | |
target = new ActionReference(); | |
target.putEnumerated($t('layer'), $t('ordinal'), $t('targetEnum')); | |
executeSet(target, layer, $t('layer')); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment