Styles.js

Discussion of the xtools Toolkit

Moderators:xbytor, DavideBarranca, Paul MR

xbytor
Styles.js

Post by xbytor » Fri Mar 03, 2006 6:23 pm

Here is a first cut at retrieving LayerStyle ActionDescriptors. It's now possible with a simple call.

Code: Select allvar desc = Styles.getLayerStyleActionDecriptor(doc, layer);

I have code written up that will also set the LayerStyle, which would be useful if you just wanted to change some specific values in the current layer style. However, there appears to be a yet another PS bug in the toStream/fromStream code that I have found but not yet found a workaround for. I'll work on it later.

Let me know if you find any bugs with this. I have only tested it with a few test cases so far and wouldn't be surprised if there are some cases that break it.

-X

Mike Hale

Styles.js

Post by Mike Hale » Sat Mar 04, 2006 3:39 am

X,

I have tested this one about a dozen styles I use in my templates and it has worked fine.

I have already made a function that puts all the dropshadow settings in an object. I can't tell you how long I have been trying to do this, but I'm glad you made it possible.

Mike

xbytor

Styles.js

Post by xbytor » Thu Mar 09, 2006 7:23 pm

Here's a new rev of Styles.js. This has Styles.setLayerStyleDescriptor working. The test code for this illustrates how easy it is to extract a layer style and set it.

We now 'officially' have read/write access to layer style attributes.

There may still be problems if the layer style has an embedded pattern or gradient or some other construct, but I think I've dealt with these appropriately.

One note: Styles.getLayerStyleDescriptor had a latent bug that would occur if the layer did not have a layer style. It now returns 'undefined' if there is no layer style.

-X

Mike Hale

Styles.js

Post by Mike Hale » Tue Jan 16, 2007 2:09 pm

Hi X,

Your post at the Abode fourn about how to determine current brush settings got me thinking about a releated topic.

I have been trying off and on to find a way to get information about a docs user slices. I can see the info by looking at the file with a hex editor. I can also get exiftool to extract the slices tag and save just that to a file.

Can you give me a rough outline of how I can determine if what I am seeing is the slices's descriptor?

I think that I will be able to read in the descriptor from the information you have in other posts. I'm just not clear on how to determine where a descriptor starts in a file.

Mike

xbytor

Styles.js

Post by xbytor » Tue Jan 16, 2007 2:41 pm

Send me a zipped up file with a slice that you've managed to extract with exiftool. I'll take a quick look and see if there is anything in there that's familiar...

But the basic technique is to look for 4-letter key/tags mixed with binary in some kind of structured layout.

-X

xbytor

Styles.js

Post by xbytor » Sat Apr 28, 2007 1:47 am

Styles.js is the way to get it done, as near as I can remember
You should also get familiar with the code I've got for converting ActionDescriptors to XML. That's the easiest way to decode LayerStyles.

Beyond these things, I don't know if there's any help unless it's in the SDK.

-X

sailoraspasia

Styles.js

Post by sailoraspasia » Wed Jun 23, 2010 1:01 am

I am somewhat new to scripting, and I have run into the problem where I need to create/alter layer styles on the fly. This code is pretty much the ONLY thing I have found on the web to help me with this... but my head absolutely implodes on itself when I try to understand it and use it. Can anyone explain how I would use this to say, make a layer's outer glow visible (but keep invisible its other layer effects) and then change the glow's color? I just do not understand

xbytor

Styles.js

Post by xbytor » Wed Jun 23, 2010 2:43 pm

This is now at bb/viewtopic.php?t=3442.

leezjnu

Styles.js

Post by leezjnu » Fri Nov 05, 2010 1:08 pm

Could I ask a funny question, how to use Styles.js?

rhytha

Styles.js

Post by rhytha » Tue Nov 09, 2010 6:57 pm

i hope when you mean execute when you mean 'use'

File - > Scripts -> Browse - > open styles.js

Post Reply