Technical Note: Printing the Cast Members on the Stage

Updated: 3/15/04
Products: PrintOMatic Xtra 1.6.5, PrintOMatic MX Xtra
Platforms: all

Here's a different approach to printing the Stage: using Lingo to check the cast member in each sprite channel, and adding each cast member individually to a "document object".

Using this method to print the Stage can accomplish a few desirable things:

The script below will print bitmaps, rectangles, and text members on the Stage. It's meant to be a starting point for your own custom Stage-printing code.

on printStageMembers
  set doc = new(xtra "PrintOMatic")
  if not objectP(doc) then exit
  
  -- most Stages are landscape oriented
  setLandscapeMode doc, TRUE
  
  -- create a page
  newPage doc
  
  -- fill the background with the stage color
  set c = color(#paletteindex,the stageColor)
  setColor doc, c.red, c.green, c.blue
  drawRect doc, Rect(0,0, the width of the rect of the Stage, the Height of the rect of the Stage), TRUE
  
  -- loop through all the sprite channels
  repeat with cnt = 1 to 150
    if the type of (sprite cnt) > 0 then
      set ty = the type of the member of sprite cnt
      if ty = #bitmap then
        drawPicture doc, the member of sprite cnt, the rect of sprite cnt
      else if ty = #field then
        if the ink of sprite cnt = 0 then
          set c = color(#paletteindex,the backcolor of the member of sprite cnt)
          setColor doc, c.red, c.green, c.blue
          drawRect doc, the rect of sprite cnt, TRUE
        end if
        set c = color(#paletteindex,the forecolor of the member of sprite cnt)
        setColor doc, c.red, c.green, c.blue
        newFrame doc, the rect of sprite cnt, FALSE
        setTextJust doc, the textAlign of the member of sprite cnt
        append doc, the member of sprite cnt
      else if ty = #shape then
        -- simply assume it's a rectangle, because we can't detect
        -- the type of shape with Lingo. Grrrr.
        set c = color(#paletteindex,the forecolor of sprite cnt)
        setColor doc, c.red, c.green, c.blue
        setLineWeight doc, the lineSize of sprite cnt
        drawRect doc, the rect of sprite cnt, the filled of the member of sprite cnt
      else if ty = #text then
        newFrame doc, the rect of sprite cnt, FALSE
        append doc, the member of sprite cnt
      end if
    end if
  end repeat
  
  if doJobSetup(doc) then print doc
  
  set doc = 0
  
end

To view this and other technical notes on-line, visit http://www.printomatic.com/tech.cfm.