1 Reply Latest reply on Jul 29, 2008 7:48 AM by Newsgroup_User

    Method for best Graphics API performance

    czcollier
      We're writing a Flex application with a custom UIComponent that draws many (possibly thousands) simple shapes on the screen using the Graphics API (lineTo(), drawEllipse(), etc.). I'm wondering what will yield the best performance: should we pass around the Graphics object from the main canvas area, and render using that directly, or instantiate a Shape object for each line/ellipse/rectangle drawn, and use the member Graphics object in each Shape, to draw itself?

      We'll sacrifice code cleanliness for performance. Any ideas?

      thanks,

      Chris
        • 1. Re: Method for best Graphics API performance
          Level 7

          "czcollier" <webforumsuser@macromedia.com> wrote in message
          news:g6n4cr$nms$1@forums.macromedia.com...
          > We're writing a Flex application with a custom UIComponent that draws many
          > (possibly thousands) simple shapes on the screen using the Graphics API
          > (lineTo(), drawEllipse(), etc.). I'm wondering what will yield the best
          > performance: should we pass around the Graphics object from the main
          > canvas
          > area, and render using that directly, or instantiate a Shape object for
          > each
          > line/ellipse/rectangle drawn, and use the member Graphics object in each
          > Shape,
          > to draw itself?
          >
          > We'll sacrifice code cleanliness for performance. Any ideas?

          I haven't done this, but someone once asked a similar question on the
          flexCoders group. One of the Adobe engineers suggested the op could get
          best performance by only drawing so much at a time, then converting the
          result to a bitmap.

          HTH;

          Amy