Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

rotating brushes using file stream of saved brushes in javascript

Community Expert ,
Sep 06, 2009 Sep 06, 2009

Once again I’m fascinated by a query in the MacIntosh-forum which’s solution I suspect is within JavaScript’s reach but out of my depth – namely:

Can one rotate a brush by Keyboard Shortcut, like in- or decreasing its size or softness?

I mostly use the round brushes myself, so it’s not like I even miss the capability …

I suspect by saving a Brush Preset, then saving that one alone as an abr-file, deleting the Brush Preset, reading and editing the abr.file, loading it, selecting the single Brush Preset contained and deleting it, too, one might achieve it.

Of course editing the abr-file with a Script seems a bit risky to me.

On xbytor’s advice I downloaded HexEditor, but the Brush Tip Shape-Angle-setting mystifies me … »AnglUntF#Ang@« seems to be the one but I fail to understand the angle-value …

Furthermore the total number of brushes (for indexing purposes) eludes me.

Anyway, the procedure may be too complicated or time-consuming to make any practical sense (apart from inserting numerous steps in the history, which might be a further drawback in real working conditions), but I guess some of You like exploring theoretical applications of Scripting-techniques, so maybe You could give me Your opinions/advice on the whole matter.

TOPICS
Actions and scripting
10.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Beginner ,
Sep 08, 2009 Sep 08, 2009

Wow wow wow!! It's works like a charm!!

Fantastico!

I repeat: Amazing and generous and smart as all get out!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2009 Sep 09, 2009

I was thinking... would it be possible to have the solid color layer that is briefly created and then discarded have only a tiny spot of color on it (like 1 pixel at the outer edge or something like that) so that when it is briefly invoked it doesn't cover up the image with a wall of color? I say that because the way I paint (and Christoph is right, I'm an illustrator and you can see my work at www.zinasaunders.com), when I open the Color Picker the traditional way to pick a color to paint with, I hover it over my image and I select by comparing the shades of color in the Color Picker against the painting. So, if a blank, see through layer were created, it would make it possible to make that kind of comparison.

About the title of this thread...would it be helpful if I started a new thread with a pertinent title and then copied and pasted in the last script and made a link to this thread so people could reference it?

And, last but not least, thanks again. And again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2009 Sep 09, 2009

I think You need only insert the lines

var originalUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

app.activeDocument.selection.select([[0,0],[1,0],[1,1],[0,1]]);

app.preferences.rulerUnits = originalUnits;

before line 16 (or so), where it goes:

// create colour layer

CreateSolidLayer();

This creates a 1-pixel-selection and should make the layer less obvious.

Nice work on Your site, by the way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2009 Sep 09, 2009

Oh. My. God.

It works like a dream!

What about me creating a new thread about this here? Would that be a good idea? I don't know what the "etiquette" of this particular forum is. I would think lots of artists who work in Photoshop would find this invaluable! I've been requesting this for years in the Photoshop feature Request section of the Adobe forums.

Again, thank you, one and all!

Edit: Oh! Christoph, I just read your follow-up note about history states...I think that's an extremely good point and  very good idea.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2009 Sep 09, 2009

I suppose a forum-search for »color picker« should turn up this thread anyway, but maybe Michael or Paul can make a more informed recommendation regarding the matter …

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 09, 2009 Sep 09, 2009

Most things dissapear from this forum after 6 months, maybe Mike could put it on ps-scripts.com and then it would be there for all?

www.ps-scripts.com is the best source of Photoshop scripting outside of Adobe.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2009 Sep 09, 2009

I've been thinking about your (excellent!) suggestion about going back in History states, Christoph, but wouldn't going back in History Undo the new color choice, too?

It's a terrific suggestion, though, because I can imagine the History states ballooning pretty fast...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2009 Sep 09, 2009

Not necessarily, because the backstepping refers to actions in Photoshop, the Script can hold the values independent of that operation.

So if one were to return to the history-state at the time of invoking the Script before setting the foreground-color it would still work.

And then one could remove the line »activeDocument.activeLayer.remove();«.

Another thing I noticed is that canceling the Color Picker causes an error, the only way I know to avoid that would be a try-clause.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 09, 2009 Sep 09, 2009

Is this any better?

colorPicker();
/////////////////////////////////////////////////////////////////
// Function: colorPicker
// Description: Creates a temp solidcolor adjustment layer to
//                let the user set the forground color
//                  
// Usage: colorpicker()
// Input: None
// Return: None
// Dependencies: None
// Notes:             
//////////////////////////////////////////////////////////////////
function colorPicker(){
    // set starting color
var historyState = activeDocument.activeHistoryState;
    var startColor = app.foregroundColor;
var originalUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.activeDocument.selection.select([[0,0],[1,0],[1,1],[0,1]]);
app.preferences.rulerUnits = originalUnits;
    // create colour layer
    CreateSolidLayer();
    // call the color picker
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putEnumerated( stringIDToTypeID( "contentLayer" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
    desc.putReference( charIDToTypeID( "null" ), ref );
    var modeDesc = new ActionDescriptor();
        var colorDesc = new ActionDescriptor();
            colorDesc.putDouble( charIDToTypeID( "Rd  " ), startColor.rgb.red );
            colorDesc.putDouble( charIDToTypeID( "Grn " ), startColor.rgb.green );
            colorDesc.putDouble( charIDToTypeID( "Bl  " ), startColor.rgb.blue );
        modeDesc.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), colorDesc );
    desc.putObject( charIDToTypeID( "T   " ), stringIDToTypeID( "solidColorLayer" ), modeDesc );
try{
    executeAction( charIDToTypeID( "setd" ), desc, DialogModes.ALL )
}catch(e){}
    // get user's color and set to forground color
    var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var desc = executeActionGet(ref)
    var adjList = desc.getList(stringIDToTypeID('adjustment'));
    var adjDesc = adjList.getObjectValue(0);
    var colorDesc = adjDesc.getObjectValue(stringIDToTypeID('color'));
    var Colour = new SolidColor();
        Colour.rgb.red = colorDesc.getDouble(charIDToTypeID('Rd  '));
        Colour.rgb.green = colorDesc.getDouble(charIDToTypeID('Grn '));
        Colour.rgb.blue = colorDesc.getDouble(charIDToTypeID('Bl  '));
    // restore
activeDocument.activeHistoryState = historyState;
  //  activeDocument.activeLayer.remove();
    app.foregroundColor = Colour;
    }


    function CreateSolidLayer() {
        var startColor = app.foregroundColor;
        var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putClass( stringIDToTypeID('contentLayer') );
        desc.putReference( charIDToTypeID('null'), ref );
            var desc1 = new ActionDescriptor();
                var desc2 = new ActionDescriptor();
                    var desc3 = new ActionDescriptor();
                    desc3.putDouble( charIDToTypeID('Rd  '), startColor.rgb.red );
                    desc3.putDouble( charIDToTypeID('Grn '), startColor.rgb.green );
                    desc3.putDouble( charIDToTypeID('Bl  '), startColor.rgb.blue );
                desc2.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc3 );
            desc1.putObject( charIDToTypeID('Type'), stringIDToTypeID('solidColorLayer'), desc2 );
        desc.putObject( charIDToTypeID('Usng'), stringIDToTypeID('contentLayer'), desc1 );
        executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );
};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2009 Sep 09, 2009

Thanks, You seem to have ironed out all the potential problem-sources I noticed.

By the way, I’m still trying to work through Michael’s Brush-code on PS-Scripts, because the brushAngle-function seems to reset the Brush Tip Shape. But he has provided a collection of the Keys for the Brush Descriptor and the Tool Options, so I suppose all necessary ingredients are available to tackle that matter …

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2009 Sep 09, 2009

When I run the new version, if I cancel out I get this:

Error 8007: User cancelled the operation

Line 34

-> executeAction( charIDToTypeID( "setd" ). desc,DialogModes.ALL )

Also, when I don't cancel and choose a color, the steps show up in teh History palette.

Not complaining in the least, mind you, just thought you might like to know how it works here, on PS CS3.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Sep 09, 2009 Sep 09, 2009

Are you sure that you are using Paul's latest version?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2009 Sep 09, 2009

You're right, it works perfectly. I must have been using the older version, I'm very sorry.

Would it be alright for me to post a link to this thread on the PS Macintosh forum, in case others might find this fantastic script useful?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Sep 09, 2009 Sep 09, 2009

It's fine with me. I have also made a post at http://ps-scripts.com/bb/viewtopic.php?p=12641 that just has the final script. You may want to share that link instead so they do not have to wade through whole thread here.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2009 Sep 09, 2009
LATEST

Excellent, will do.

Many, many thanks again.

-Zina

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2009 Sep 09, 2009

If I may add one comment to Your Script: I think it might be beneficial to an illustrator’s workflow to go back in the history instead of removing the layer, because that could – especially with repeated color-selections – crowd out older history-states.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 08, 2009 Sep 08, 2009

Is this the type of Color Picker you are talking about:  http://ps-scripts.com/bb/viewtopic.php?t=659

Larry

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2009 Sep 08, 2009

I think Zina mentioned she does illustration so she probably prefers the handling and representation of the Adobe Colorpicker.

Anyway: Amazing how far this thread has drifted, unfortunately I can’t seem to edit the original heading to better represent the actual content for future reference.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines