3 Replies Latest reply: Aug 15, 2008 12:21 PM by (xbytor) RSS

    Detecting The Current Brush Size

    Inchindown Community Member
      Hi all,

      Is there anyway in javascript to detect the pixel size of the current brush? I want to use that value as a variable in a script.

      Thanks for any help.
        • 1. Re: Detecting The Current Brush Size
          Community Member
          >
          > Is there anyway in javascript to detect the pixel size of the current brush?

          It's fairly easy to set the current brush size via scripting listener code, but
          reading the current value does not appear to be as simple.

          If I had to do it, I would create a new (temporary) brush preset, save the
          preset to disk, delete the temporary in-memory preset, then pick apart the saved
          brush file to extract the brush size.

          The last part is the only part that gets a bit tedious. The others can all be
          taken care of via SL code. Or, even easier, the PresetsManager script in xtools.

          -X
          --
          for photoshop scripting solutions of all sorts
          contact: xbytor@gmail.com
          • 2. Re: Detecting The Current Brush Size
            Inchindown Community Member
            Thanks X.

            When you say "pick apart the saved brush file" do mean the SL code created when you saved the preset?
            • 3. Re: Detecting The Current Brush Size
              Community Member
              > When you say "pick apart the saved brush file" do mean the SL code created when you saved the preset?

              No. The SL code is relatively easy to deal with. What I was referring to was the
              binary .abr file that brushes get stored in. There are a couple of bytes (or
              more) of information that define the size of a brush in the preset file. It
              should be possible to determine which bytes they are, but it might take a bit of
              work.

              -X
              --
              for photoshop scripting solutions of all sorts
              contact: xbytor@gmail.com