// //==================== CSSsprite ============== // Stephen M James // smjdesign.com // function CSSsprite() { // Convert Mode // ======================================================= var dialogMode = DialogModes.NO; var desc1 = new ActionDescriptor(); desc1.putClass(PSKey.To, PSClass.RGBColorMode); executeAction(sTID('convertMode'), desc1, dialogMode); // Make Guide // ======================================================= var dialogMode = DialogModes.NO; var desc1 = new ActionDescriptor(); var desc2 = new ActionDescriptor(); desc2.putUnitDouble(PSKey.Position, PSUnit.Percent, 100); desc2.putEnumerated(PSKey.Orientation, PSKey.Orientation, PSEnum.Horizontal); desc1.putObject(PSKey.New, PSClass.Guide, desc2); executeAction(PSEvent.Make, desc1, dialogMode); // Switch to document -1 // ======================================================= var id17 = charIDToTypeID( "slct" ); var desc7 = new ActionDescriptor(); var id18 = charIDToTypeID( "null" ); var ref5 = new ActionReference(); var id19 = charIDToTypeID( "Dcmn" ); ref5.putOffset( id19, -1 ); desc7.putReference( id18, ref5 ); executeAction( id17, desc7, DialogModes.NO ); // Convert Mode // ======================================================= var dialogMode = DialogModes.NO; var desc1 = new ActionDescriptor(); desc1.putClass(PSKey.To, PSClass.RGBColorMode); executeAction(sTID('convertMode'), desc1, dialogMode); // Duplicate layer to Next Document // ======================================================= var id4422 = charIDToTypeID( "Dplc" ); var desc902 = new ActionDescriptor(); var id4423 = charIDToTypeID( "null" ); var ref621 = new ActionReference(); var id4424 = charIDToTypeID( "Lyr " ); var id4425 = charIDToTypeID( "Ordn" ); var id4426 = charIDToTypeID( "Trgt" ); ref621.putEnumerated( id4424, id4425, id4426 ); desc902.putReference( id4423, ref621 ); var id4427 = charIDToTypeID( "T " ); var ref622 = new ActionReference(); var id4428 = charIDToTypeID( "Dcmn" ); ref622.putOffset( id4428, 1 ); desc902.putReference( id4427, ref622 ); var id4429 = charIDToTypeID( "Vrsn" ); desc902.putInteger( id4429, 2 ); executeAction( id4422, desc902, DialogModes.NO ); // Switch to document +1 // ======================================================= var id40 = charIDToTypeID( "slct" ); var desc13 = new ActionDescriptor(); var id41 = charIDToTypeID( "null" ); var ref11 = new ActionReference(); var id42 = charIDToTypeID( "Dcmn" ); ref11.putOffset( id42, 1 ); desc13.putReference( id41, ref11 ); executeAction( id40, desc13, DialogModes.NO ); // Canvas Size // ======================================================= var dialogMode = DialogModes.NO; var desc1 = new ActionDescriptor(); desc1.putBoolean(PSKey.Relative, true); desc1.putUnitDouble(PSKey.Height, PSUnit.Percent, 100); desc1.putEnumerated(PSKey.Vertical, PSType.VerticalLocation, PSEnum.Top); desc1.putEnumerated(PSString.canvasExtensionColorType, PSString.canvasExtensionColorType, PSEnum.BackgroundColor); executeAction(sTID('canvasSize'), desc1, dialogMode); // Move Layer down 50% of canvas height // ======================================================= var id447 = charIDToTypeID( "Trnf" ); var desc80 = new ActionDescriptor(); var id448 = charIDToTypeID( "null" ); var ref42 = new ActionReference(); var id449 = charIDToTypeID( "Lyr " ); var id450 = charIDToTypeID( "Ordn" ); var id451 = charIDToTypeID( "Trgt" ); ref42.putEnumerated( id449, id450, id451 ); desc80.putReference( id448, ref42 ); var id452 = charIDToTypeID( "FTcs" ); var id453 = charIDToTypeID( "QCSt" ); var id454 = charIDToTypeID( "Qcsa" ); desc80.putEnumerated( id452, id453, id454 ); var id455 = charIDToTypeID( "Ofst" ); var desc81 = new ActionDescriptor(); var id456 = charIDToTypeID( "Hrzn" ); var id457 = charIDToTypeID( "#Pxl" ); desc81.putUnitDouble( id456, id457, 0.000000 ); var id458 = charIDToTypeID( "Vrtc" ); var id459 = charIDToTypeID( "#Prc" ); desc81.putUnitDouble( id458, id459, 50.000000 ); var id460 = charIDToTypeID( "Ofst" ); desc80.putObject( id455, id460, desc81 ); executeAction( id447, desc80, DialogModes.NO ); // Zoom In // ======================================================= var dialogMode = DialogModes.NO; var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(PSClass.MenuItem, PSType.MenuItem, PSEnum.ZoomIn); desc1.putReference(PSString.Null, ref1); executeAction(PSEvent.Select, desc1, dialogMode); var dialogMode = DialogModes.NO; var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(PSClass.MenuItem, PSType.MenuItem, PSEnum.ZoomIn); desc1.putReference(PSString.Null, ref1); executeAction(PSEvent.Select, desc1, dialogMode); }; cTID = function(s) { return app.charIDToTypeID(s); }; sTID = function(s) { return app.stringIDToTypeID(s); }; // // CSSsprite.loadSymbols // Loading up the symbol definitions like this makes it possible // to include several of these generated files in one master file // provided a prefix is specified other than the default. It also // skips the definitions if PSConstants has already been loaded. // CSSsprite.loadSymbols = function() { try { PSConstants; return; // only if PSConstants is defined } catch (e) { } var needDefs = true; try { PSClass; needDefs = false; } catch (e) { } if (needDefs) { PSClass = function() {}; PSEnum = function() {}; PSEvent = function() {}; PSForm = function() {}; PSKey = function() {}; PSType = function() {}; PSUnit = function() {}; PSString = function() {}; } // We may still end up duplicating some of the following definitions // but at least we don't redefine PSClass, etc... and wipe out others PSClass.Application = cTID('capp'); PSClass.Guide = cTID('Gd '); PSClass.GuidesPrefs = cTID('GdPr'); PSClass.MenuItem = cTID('Mn '); PSClass.Property = cTID('Prpr'); PSClass.RGBColorMode = cTID('RGBM'); PSEnum.BackgroundColor = cTID('BckC'); PSEnum.Horizontal = cTID('Hrzn'); PSEnum.RulerPixels = cTID('RrPx'); PSEnum.Target = cTID('Trgt'); PSEnum.ToggleGrid = cTID('TgGr'); PSEnum.Top = cTID('Top '); PSEnum.ZoomIn = cTID('ZmIn'); PSEvent.Make = cTID('Mk '); PSEvent.Select = cTID('slct'); PSEvent.Set = cTID('setd'); PSKey.GridMajor = cTID('GrdM'); PSKey.GridUnits = cTID('Grdt'); PSKey.Height = cTID('Hght'); PSKey.New = cTID('Nw '); PSKey.Orientation = cTID('Ornt'); PSKey.Position = cTID('Pstn'); PSKey.Relative = cTID('Rltv'); PSKey.To = cTID('T '); PSKey.Vertical = cTID('Vrtc'); PSString.Null = sTID('null'); PSString.canvasExtensionColorType = sTID('canvasExtensionColorType'); PSString.newGuide = sTID('newGuide'); PSType.MenuItem = cTID('MnIt'); PSType.Ordinal = cTID('Ordn'); PSType.RulerUnits = cTID('RlrU'); PSType.VerticalLocation = cTID('VrtL'); PSUnit.Percent = cTID('#Prc'); PSUnit.Pixels = cTID('#Pxl'); }; CSSsprite.loadSymbols(); // load up our symbols //========================================= // CSSsprite.main //========================================= // CSSsprite.main = function () { CSSsprite(); }; CSSsprite.main(); // EOF