Example #1
0
        internal void Draw(DrawingPathBackendHandler targetHandler, object ctx, VectorImageData cm)
        {
            int di = 0;
            int ci = 0;
            int ii = 0;
            int ri = 0;
            int oi = 0;
            int imi = 0;
            int ti = 0;

            ContextBackendHandler handler = targetHandler as ContextBackendHandler;
            DrawingPathBackendHandler pathHandler = targetHandler;

            for (int n=0; n<cm.Commands.Length; n++)
            {
                switch (cm.Commands [n]) {
                case DrawingCommand.AppendPath:
                    var p = cm.Objects [oi++];
                    if (p is VectorImageData)
                        Draw (targetHandler, ctx, (VectorImageData)p);
                    else
                        pathHandler.AppendPath (ctx, p);
                    break;
                case DrawingCommand.Arc:
                    pathHandler.Arc (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.ArcNegative:
                    pathHandler.ArcNegative (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.Clip:
                    handler.Clip (ctx);
                    break;
                case DrawingCommand.ClipPreserve:
                    handler.ClipPreserve (ctx);
                    break;
                case DrawingCommand.ClosePath:
                    pathHandler.ClosePath (ctx);
                    break;
                case DrawingCommand.CurveTo:
                    pathHandler.CurveTo (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.DrawImage2:
                    handler.DrawImage (ctx, cm.Images [imi++], cm.Rectangles [ri++], cm.Rectangles [ri++]);
                    break;
                case DrawingCommand.DrawImage:
                    handler.DrawImage (ctx, cm.Images [imi++], cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.DrawTextLayout:
                    var lad = (TextLayoutData)cm.TextLayouts [ti++];
                    var la = new TextLayout (toolkit);
                    lad.InitLayout (la);
                    handler.DrawTextLayout (ctx, la, cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.Fill:
                    handler.Fill (ctx);
                    break;
                case DrawingCommand.FillPreserve:
                    handler.FillPreserve (ctx);
                    break;
                case DrawingCommand.LineTo:
                    pathHandler.LineTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.MoveTo:
                    pathHandler.MoveTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.NewPath:
                    handler.NewPath (ctx);
                    break;
                case DrawingCommand.Rectangle:
                    pathHandler.Rectangle (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.RelCurveTo:
                    pathHandler.RelCurveTo (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.RelLineTo:
                    pathHandler.RelLineTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.RelMoveTo:
                    pathHandler.RelMoveTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.Restore:
                    handler.Restore (ctx);
                    break;
                case DrawingCommand.Rotate:
                    handler.Rotate (ctx, cm.Doubles [di++]);
                    break;
                case DrawingCommand.Save:
                    handler.Save (ctx);
                    break;
                case DrawingCommand.Scale:
                    handler.Scale (ctx, cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                case DrawingCommand.SetColor:
                    handler.SetColor (ctx, cm.Colors [ci++]);
                    break;
                case DrawingCommand.SetGlobalAlpha:
                    handler.SetGlobalAlpha (ctx, cm.Doubles [di++]);
                    break;
                case DrawingCommand.SetLineDash:
                    var off = cm.Doubles [di++];
                    var ds = new double [cm.Ints [ii++]];
                    for (int i = 0; i < ds.Length; i++)
                        ds [i] = cm.Doubles [di++];
                    handler.SetLineDash (ctx, off, ds);
                    break;
                case DrawingCommand.SetLineWidth:
                    handler.SetLineWidth (ctx, cm.Doubles [di++]);
                    break;
                case DrawingCommand.SetPattern:
                    handler.SetPattern (ctx, cm.Objects [oi++]);
                    break;
                case DrawingCommand.Stroke:
                    handler.Stroke (ctx);
                    break;
                case DrawingCommand.StrokePreserve:
                    handler.StrokePreserve (ctx);
                    break;
                case DrawingCommand.Translate:
                    handler.Translate (ctx, cm.Doubles [di++], cm.Doubles [di++]);
                    break;
                }
            }
        }
Example #2
0
 public DrawingPath()
 {
     handler = Toolkit.CurrentEngine.VectorImageRecorderContextHandler;
     Backend = handler.CreatePath ();
 }
Example #3
0
 internal DrawingPath(object backend, Toolkit toolkit, DrawingPathBackendHandler h)
     : base(backend, toolkit)
 {
     handler = h;
 }
Example #4
0
 public DrawingPath()
 {
     handler = ToolkitEngine.DrawingPathBackendHandler;
     Backend = handler.CreatePath ();
 }