In Depth Banner
Skip Navigation Links

Select your preferred language

A typical painting method

    public void Paint(Graphics g)

    {

      //The current state of the graphics object is saved.

      GraphicsState gs=g.Save();

      //An identity matrix

      Matrix mx=new Matrix();

      //is multiplied by the current transform

      mx.Multiply(g.Transform);

      //and then by the transform of the object being drawn

      mx.Multiply(this.Transform);

      g.Transform=mx;

      //The object being drawn paints itself

      DoPaint(g);

      //Each child object paints itself also

      //by recursing into this method

      foreach(GraphicObject o in this.Nodes)

      {

        o.Paint(g);

      }

      //The original state of the graphics object is restored.

      g.Restore(gs);

    }

 

Return to the article.

Copyright © Bob Powell 2003-2009. All rights reserved