Beispiel #1
0
 public void LoadFromSvg(SvgRenderVx svgRenderVx)
 {
     _svgRenderVx = svgRenderVx;
     UpdateBounds();
     //find center
     center.x = (boundingRect.Right - boundingRect.Left) / 2.0;
     center.y = (boundingRect.Top - boundingRect.Bottom) / 2.0;
 }
Beispiel #2
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            if (recreatePathAgain)
            {
                recreatePathAgain = false;

                var transform = Affine.NewMatix(
                    AffinePlan.Translate(-_spriteShape.Center.x, -_spriteShape.Center.y),
                    AffinePlan.Scale(spriteScale, spriteScale),
                    AffinePlan.Rotate(angle + Math.PI),
                    AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0),
                    AffinePlan.Translate(Width / 2, Height / 2)
                    );
                //create vertextStore again from original path


                //temp fix
                SvgRenderVx renderVx = _spriteShape.GetRenderVx();
                int         count    = renderVx.SvgVxCount;
                for (int i = 0; i < count; ++i)
                {
                    SvgPart vx = renderVx.GetInnerVx(i);
                    if (vx.Kind != SvgRenderVxKind.Path)
                    {
                        continue;
                    }
                    //Temp fix,
                    //TODO: review here,
                    //permanent transform each part?
                    //or create a copy.
                    vx.RestoreOrg();
                    VertexStore vxvxs  = vx.GetVxs();
                    VertexStore newVxs = new VertexStore();
                    transform.TransformToVxs(vxvxs, newVxs);
                    vx.SetVxs(newVxs);
                }
                _spriteShape.UpdateBounds();

                //if (AutoFlipY)
                //{
                //    //flip the lion
                //    PixelFarm.Agg.Transform.Affine aff = PixelFarm.Agg.Transform.Affine.NewMatix(
                //      PixelFarm.Agg.Transform.AffinePlan.Scale(-1, -1),
                //      PixelFarm.Agg.Transform.AffinePlan.Translate(0, 600));
                //    //
                //    var v2 = new VertexStore();
                //    myvxs = transform.TransformToVxs(myvxs, v2);
                //}
            }
            //---------------------------------------------------------------------------------------------
            {
                float ox = p.OriginX;
                float oy = p.OriginY;
                p.SetOrigin(ox + _posX, oy + _posY);
                _spriteShape.Paint(p);
                //#if DEBUG
                //                RectD bounds = lionShape.Bounds;
                //                bounds.Offset(_posX, _posY);
                //                //draw lion bounds
                //                var savedStrokeColor = p.StrokeColor;
                //                var savedFillColor = p.FillColor;
                //                var savedSmoothMode = p.SmoothingMode;

                //                p.SmoothingMode = SmoothingMode.HighSpeed;
                //                p.StrokeColor = Color.Black;
                //                p.DrawRect(bounds.Left, bounds.Top - bounds.Height, bounds.Width, bounds.Height);

                //                p.StrokeColor = Color.Red;
                //                p.DrawRect(_mouseDownX, _mouseDownY, 4, 4);


                //                //restore
                //                p.SmoothingMode = savedSmoothMode;
                //                p.StrokeColor = savedStrokeColor;
                //                p.FillColor = savedFillColor;


                //#endif

                p.SetOrigin(ox, oy);


                //int j = lionShape.NumPaths;
                //int[] pathList = lionShape.PathIndexList;
                //Drawing.Color[] colors = lionShape.Colors;
                ////graphics2D.UseSubPixelRendering = true;
                //for (int i = 0; i < j; ++i)
                //{
                //    p.FillColor = colors[i];
                //    p.Fill(new VertexStoreSnap(myvxs, pathList[i]));
                //}
            }
            //test
            if (SharpenRadius > 0)
            {
                //p.DoFilter(new RectInt(0, p.Height, p.Width, 0), 2);
                //PixelFarm.Agg.Imaging.SharpenFilterARGB.Sharpen()
            }
        }
Beispiel #3
0
 public SpriteShape(SvgRenderVx svgRenderVx)
 {
     _svgRenderVx = svgRenderVx;
 }