Ejemplo n.º 1
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            //----------------
            //5. use PixelFarm's Agg to render to bitmap...
            //5.1 clear background
            p.Clear(PixelFarm.Drawing.Color.White);

            if (FillBG)
            {
                //5.2
                p.FillColor = PixelFarm.Drawing.Color.Black;
                //5.3
                //p.Fill(vxs);

                float x = p.OriginX;
                float y = p.OriginY;


                p.Fill(_left_vxs);
                p.SetOrigin(x + 50, y + 50);
                p.Fill(_right_vxs);
                p.SetOrigin(x, y);
            }

            if (FillBorder)
            {
                //5.4
                p.StrokeColor = PixelFarm.Drawing.Color.Green;
                //user can specific border width here...
                p.StrokeWidth = 2;
                //5.5

                float x = p.OriginX;
                float y = p.OriginY;
                p.Draw(_left_vxs);
                p.SetOrigin(x + 50, y + 20);
                p.Draw(_right_vxs);
                p.SetOrigin(x, y);
            }
        }
Ejemplo n.º 2
0
        public void RenderChar(char testChar, HintTechnique hint)
        {
            builder.SetHintTechnique(hint);
#if DEBUG
            GlyphBoneJoint.dbugTotalId        = 0;//reset
            builder.dbugAlwaysDoCurveAnalysis = true;
#endif
            _infoView.Clear();
            _latestHint = hint;
            _testChar   = testChar;
            //----------------------------------------------------
            //
            builder.Build(testChar, _sizeInPoint);
            var txToVxs1 = new GlyphTranslatorToVxs();
            builder.GlyphDynamicEdgeOffset = this.GlyphEdgeOffset;

            builder.ReadShapes(txToVxs1);

#if DEBUG
            var ps = txToVxs1.dbugGetPathWriter();
            _infoView.ShowOrgBorderInfo(ps.Vxs);
#endif
            PixelFarm.Drawing.VertexStore vxs = new PixelFarm.Drawing.VertexStore();

            txToVxs1.WriteOutput(vxs);
            //----------------------------------------------------

            //----------------------------------------------------
            painter.UseSubPixelLcdEffect = this.UseLcdTechnique;
            //5. use PixelFarm's Agg to render to bitmap...
            //5.1 clear background
            painter.Clear(PixelFarm.Drawing.Color.White);

            RectD bounds = new RectD();
            BoundingRect.GetBoundingRect(new PixelFarm.Drawing.VertexStoreSnap(vxs), ref bounds);
            //----------------------------------------------------
            float scale = _typeface.CalculateScaleToPixelFromPointSize(_sizeInPoint);
            _pxscale = scale;
            this._infoView.PxScale = scale;


            var   left2   = 0;
            int   floor_1 = (int)left2;
            float diff    = left2 - floor_1;
            //----------------------------------------------------
            if (OffsetMinorX)
            {
                MinorOffsetInfo = left2.ToString() + " =>" + floor_1 + ",diff=" + diff;
            }
            else
            {
                MinorOffsetInfo = left2.ToString();
            }


            //5. use PixelFarm's Agg to render to bitmap...
            //5.1 clear background
            painter.Clear(PixelFarm.Drawing.Color.White);

            if (FillBackGround)
            {
                //5.2
                painter.FillColor = PixelFarm.Drawing.Color.Black;

                float xpos = 5;// - diff;
                if (OffsetMinorX)
                {
                    xpos -= diff;
                }

                painter.SetOrigin(xpos, 10);
                painter.Fill(vxs);
            }
            if (DrawBorder)
            {
                //5.4
                painter.StrokeColor = PixelFarm.Drawing.Color.Green;
                //user can specific border width here...
                //5.5
                painter.Draw(vxs);
                //--------------
                int    markOnVertexNo = _infoView.DebugMarkVertexCommand;
                double x, y;
                vxs.GetVertex(markOnVertexNo, out x, out y);
                painter.FillRect(x, y, 4, 4, PixelFarm.Drawing.Color.Red);
                //--------------
                _infoView.ShowFlatternBorderInfo(vxs);
                //--------------
            }
#if DEBUG
            builder.dbugAlwaysDoCurveAnalysis = false;
#endif

            if (ShowTess)
            {
                RenderTessTesult();
            }

            //if (DrawDynamicOutline)
            //{
            //    GlyphDynamicOutline dynamicOutline = builder.LatestGlyphFitOutline;
            //    WalkDynamicOutline(painter, dynamicOutline, scale, DrawRegenerateOutline);

            //}
        }
Ejemplo n.º 3
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()
            }
        }
Ejemplo n.º 4
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.RenderQuality = RenderQuality.Fast;
            Brush prevBrush = p.CurrentBrush;
            Brush selectedBrush;

            p.Clear(Color.White);

            switch (SelectedBrushKind)
            {
            default: throw new NotSupportedException();

            case BrushKind.SolidBrush:
                selectedBrush = _solidBrush;
                break;

            case BrushKind.LinearGradient:
                selectedBrush = _linearGrBrush;
                break;

            case BrushKind.CircularGradient:
                selectedBrush = _circularGrBrush;
                break;

            case BrushKind.PolygonGradient:
                selectedBrush = _polygonGradientBrush;
                break;
            }

            //
            p.CurrentBrush = selectedBrush;

            //special set for our GLPainter
            bool glPainter2MaskColor = false;

            DrawingGL.GLPainter glPainter = p as DrawingGL.GLPainter;
            if (glPainter != null)
            {
                glPainter2MaskColor        = glPainter.UseTwoColorsMask;
                glPainter.UseTwoColorsMask = EnableGLPainterTwoColorsMask;
            }

            //p.FillRect(0, 100, 500, 500);
            //p.FillRect(0, 200, 200, 50);

            if (UseClipRegion)
            {
                //fill vxs region1
                p.FillRegion(_triangleVxs);
                //fill vxs region2
                if (UseOffset)
                {
                    float prev_ox = p.OriginX;
                    float prev_oy = p.OriginY;
                    p.SetOrigin(100, 120);
                    p.FillRegion(_triangleVxs);
                    p.SetOrigin(prev_ox, prev_oy);//restore
                }
                else
                {
                    p.FillRegion(_triangleVxs2);
                }
            }
            else
            {
                p.Fill(_triangleVxs);
                if (UseOffset)
                {
                    float prev_ox = p.OriginX;
                    float prev_oy = p.OriginY;
                    p.SetOrigin(100, 120);
                    p.Fill(_triangleVxs);
                    p.SetOrigin(prev_ox, prev_oy);//restore
                }
                else
                {
                    p.Fill(_triangleVxs2);
                }
            }


            //-------------

            p.CurrentBrush = prevBrush;

            if (glPainter != null)
            {
                //restore
                glPainter.UseTwoColorsMask = glPainter2MaskColor;
            }
        }