4 Replies Latest reply on May 13, 2016 6:59 PM by vad3

    Notifier for Canvas Redraw?




      I am aware of enums for draw and Redraw Complete flags, but rather than posting an Action to wait for redraw - id like to be notified of a pending canvas redraw, or of canvas redraw completion (see type RdCm), so I can fire a function whenever pixels are finished being drawn to a canvas in a way that triggers a visual update.


      My goal is to play back recorded actions that have had tool recording enabled, so that I can record every frame within a brush stroke 'action' - export them as a movie at very very high resolution. Currently, I can have a brush stroke be applied, and then once completed, save a frame (which currently works, but is not ideal as the resulting frames feel more like a stop motion animation and have no gesture). Screen recording is not ideal as the image fidelity is lower, even at 4K (these are very very large images, for fine art purposes).


      Is there a way to be notified of "charIDToTypeID("RdCm") " events - even though RdCM is not an event type? Or some other clever mechanism? Perhaps even a custom plugin (I am an experienced developer, having written After Effects Mercury Transmit plugins)

      My script is currently using the "All " fourcc code to listen for every event, however, brush stroke, pen moves, are not passed as an event. Can one get mouse moves, or programatic mouse down/move/drags as replayed by actions?


      Seeking some guidance. Thank you.

        • 1. Re: Notifier for Canvas Redraw?
          JJMack Most Valuable Participant

          You can record tool use in actions like brush strokes you can not do that in scripts and you can not get the mouse cursor position in a script.  You can get Key events in a script. You can not get recorded keyevents the action player would be handling those.  Do not think you can start recording an action in a script


          In Adobe Photoshop Java script manual I see this Action manager code for redraw.


          // A helper function for debugging

          // It also helps the user see what is going on

          // if you turn it off for this example you

          // get a flashing cursor for a number time

          function WaitForRedraw()


          var eventWait = charIDToTypeID("Wait")

          var enumRedrawComplete = charIDToTypeID("RdCm")

          var typeState = charIDToTypeID("Stte")

          var keyState = charIDToTypeID("Stte")

          var desc = new ActionDescriptor()

          desc.putEnumerated(keyState, typeState, enumRedrawComplete)

          executeAction(eventWait, desc, DialogModes.NO)


          • 2. Re: Notifier for Canvas Redraw?
            vad3 Level 1



            I'm aware you can record tool use via record in actions. Key events are generally unhelpful, and I dont need to start recording in a script.

            What I am looking for is a "call back", or a notifier for redraw, aka what "RdCm" supplies but as an event, not as an enum. With that, I can evoke a save action during painting, effectively turning recorded tool playback in to a key framed animation I save to disk as a frame sequence.

            I currently am able to shim in save actions in between each recorded brush stroke. However, this means an entire brush action is done before a save file operation, and there is no 'gesture' progress being made (ie, you dont see a stroke begin, move *in* the recorded files. You do see it on screen however.




            * Is there an event type other than the four char code "All " which evokes a notifier on tool use like brush stroke or playback of recorded tool use as saved in an action?


            * Is there a callback or event for document redraw, or document re-paining when pixels are applied to a layer, or in the document as a whole?


            * Is there a callback or event for a document being modified from one state to another - as a result of pixels being modified?


            Ideally I need a non screen recorded solution since files are in the 40Mpixel range and we want full raster near 8K frame sequences.

            Thank you for taking the time to respond.

            • 3. Re: Notifier for Canvas Redraw?
              vad3 Level 1

              Also to be clear, the WaitForRedraw snippet is only evoked after a full action is completed. In other words,as far as I have been able to tell, the wait for redraw happens after a brush stroke moves from point a to b painting the entirety of the stroke. The wait occurs during the NEXT redraw after.


              I need to "playback" a brush stroke from a to b, and during the stroke (as it paints partway from a to be and updates the canvas), have a notification that the contents of a layer, or the contents of the document, or some other mechanism, that the screen has drawn, intercede by writing that current state as an image to disk, and then let the brush continue until the next update (where I will intercede again, until the brush action has completed and I de-register for those notifications).


              Thanks again.