Пример #1
0
 public DevForm(PixelFarm.Drawing.GraphicsPlatform graphicsPlatform)
 {
     this.graphicsPlatform = graphicsPlatform;
     InitializeComponent();
     this.lstDemoList.DoubleClick += new EventHandler(lstDemoList_DoubleClick);
     LoadDemoList();
 }
Пример #2
0
 public Form1(PixelFarm.Drawing.GraphicsPlatform p)
 {
     InitializeComponent();
     this.uiPlatformWinForm = new LayoutFarm.UI.UIPlatformWinForm();
     LayoutFarm.UI.UIPlatform.CurrentUIPlatform = uiPlatformWinForm;
     this.gfxPlatform = p;
 }
Пример #3
0
 public GLBitmap(PixelFarm.Drawing.Imaging.NativeImage bmp, bool isInvertImage)
 {
     this.width = bmp.Width;
     this.height = bmp.Height;
     this.bmp = bmp;
     this.isInvertImage = isInvertImage;
 }
Пример #4
0
 public static LayoutFarm.WebDom.CssColor ConvertToCssColor(PixelFarm.Drawing.Color color)
 {
     return new LayoutFarm.WebDom.CssColor(
         color.A,
         color.R,
         color.G,
         color.B);
 }
        public override void ClearSurface(PixelFarm.Drawing.Color c)
        {

            gx.Clear(System.Drawing.Color.FromArgb(
                c.A,
                c.R,
                c.G,
                c.B));
        } 
 public override void ClearSurface(PixelFarm.Drawing.Color c)
 {
     painter1.Clear(c);
     //gx.Clear(System.Drawing.Color.FromArgb(
     //    c.A,
     //    c.R,
     //    c.G,
     //    c.B));
 }
Пример #7
0
 /// <summary>
 /// Creates a new HtmlPanel and sets a basic css for it's styling.
 /// </summary>
 public HtmlPanel(PixelFarm.Drawing.GraphicsPlatform p, int w, int h)
 {
     AutoScroll = true;
     BackColor = SystemColors.Window;
     SetStyle(ControlStyles.ResizeRedraw, true);
     SetStyle(ControlStyles.SupportsTransparentBackColor, true);
     this.gfxPlatform = p;
     
     this.renderCanvas = gfxPlatform.CreateCanvas(0, 0,
         this.canvasW = w, this.canvasH = h);
 }
Пример #8
0
        static void UpdateAllArea(PixelFarm.Drawing.Skia.MySkiaCanvas mycanvas, IRenderElement topWindowRenderBox)
        {
            mycanvas.OffsetCanvasOrigin(-mycanvas.Left, -mycanvas.Top);
            Rectangle rect = mycanvas.Rect;
            topWindowRenderBox.DrawToThisCanvas(mycanvas, rect);
#if DEBUG
            topWindowRenderBox.dbugShowRenderPart(mycanvas, rect);
#endif

            mycanvas.IsContentReady = true;
            mycanvas.OffsetCanvasOrigin(mycanvas.Left, mycanvas.Top);
        }
Пример #9
0
        /// <summary>
        /// Init.
        /// </summary>
        public DemoForm(PixelFarm.Drawing.GraphicsPlatform p)
        {
            this.graphicsPlatform = p;
            this._htmlPanel = new LayoutFarm.Demo.HtmlPanel(this.graphicsPlatform, 800, 600);
            this.htmlHost = new LayoutFarm.HtmlBoxes.HtmlHost();
            htmlHost.AttachEssentailHandlers(
                this.HandleImageRequest,
                this.HandleStylesheetRequest);
            _htmlPanel.SetHtmlHost(htmlHost);
            InitializeComponent();
            //_htmlToolTip.ImageLoad += OnImageLoad; 
            //_htmlToolTip.SetToolTip(_htmlPanel, Resources.Tooltip);

            _htmlEditor.Font = new Font(FontFamily.GenericMonospace, 10);
            StartPosition = FormStartPosition.CenterScreen;
            var size = Screen.GetWorkingArea(Point.Empty);
            Size = new Size((int)(size.Width * 0.7), (int)(size.Height * 0.8));
            _updateHtmlTimer = new Timer(OnUpdateHtmlTimerTick);
            this.Text += " : " + Path.GetDirectoryName(Application.ExecutablePath);
            this._samplesTreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(_samplesTreeView_NodeMouseClick);
        }
 public void PrintMe(PixelFarm.Drawing.WinGdi.MyGdiPlusCanvas targetCanvas)
 {
     //paint to external canvas    
     var winBridge = (GdiPlus.MyTopWindowBridgeGdiPlus)this.winBridge;
     if (winBridge != null)
     {
         winBridge.PrintToCanvas(targetCanvas);
     }
 }
Пример #11
0
        public void DrawLine(float x1, float y1, float x2, float y2, PixelFarm.Drawing.Color color)
        {
            SetCurrent();
            CheckViewMatrix();
            //--------------------------------------------

            u_solidColor.SetValue((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f);
            unsafe
            {
                float* vtx = stackalloc float[4];
                vtx[0] = x1; vtx[1] = y1;
                vtx[2] = x2; vtx[3] = y2;
                a_position.UnsafeLoadPureV2f(vtx);
            }
            GL.DrawArrays(BeginMode.Lines, 0, 2);
        }
Пример #12
0
 static SKColor ConvToSkColor(PixelFarm.Drawing.Color c)
 {
     return new SKColor(c.R, c.G, c.B, c.A);
 }
Пример #13
0
 public void DrawSubImageWithMsdf(GLBitmap bmp, ref PixelFarm.Drawing.Rectangle r, float targetLeft, float targetTop, float scale)
 {
     if (bmp.IsBigEndianPixel)
     {
         msdfShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop, scale);
     }
     else
     {
         msdfShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop, scale);
     }
 }
Пример #14
0
 public void DrawSubImage(GLBitmap bmp, ref PixelFarm.Drawing.Rectangle r, float targetLeft, float targetTop)
 {
     if (bmp.IsBigEndianPixel)
     {
         glesTextureShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop);
     }
     else
     {
         gdiImgTextureShader.RenderSubImage(bmp, r.Left, r.Top, r.Width, r.Height, targetLeft, targetTop);
     }
 }
Пример #15
0
 public void SetClipRect(PixelFarm.Drawing.Rectangle r)
 {
     SetClipRect(r.Left, r.Top, r.Width, r.Height);
 }
Пример #16
0
 public void Print(PixelFarm.Drawing.WinGdi.MyGdiPlusCanvas canvas)
 {
     viewportControl.PrintMe(canvas);
 }
Пример #17
0
 public static int ColorToWin32(PixelFarm.Drawing.Color c)
 {
     return ((c.R | (c.G << 8)) | (c.B << 0x10));
 }
 public static SKRect ConvToRect(PixelFarm.Drawing.RectangleF r)
 {
     return new SKRect(r.X, r.Y, r.Right, r.Bottom);
 }
        public static ArrayList<VertexC4V3f> CalculateLinearGradientVxs(
            float x1, float y1,
            float x2, float y2,
            PixelFarm.Drawing.Color c1,
            PixelFarm.Drawing.Color c2)
        {
            //1. gradient distance
            float dx = x2 - x1;
            float dy = y2 - y1;
            float distance = (float)Math.Pow(dx * dx + dy * dy, 0.5f);
            //find angle
            double angleRad = Math.Atan2(dy, dx);
            if (dx < 0)
            {
                //swap
                float tmpx = x2;
                x2 = x1;
                x1 = tmpx;
                float tmpy = y2;
                y2 = y1;
                y1 = tmpy;
                PixelFarm.Drawing.Color tmpc = c2;
                c2 = c1;
                c1 = tmpc;
            }

            ArrayList<VertexC4V3f> vrx = new ArrayList<VertexC4V3f>();
            //left solid rect pane 
            AddRect(vrx,
                c1.ToABGR(), c1.ToABGR(),
                -600, -800,
                x1 + 600, 1800);
            //color gradient pane 
            AddRect(vrx,
                c1.ToABGR(), c2.ToABGR(),
                x1, -800,
                distance, 1800);
            //right solid pane
            if (1200 - (x1 + distance) > 0)
            {
                AddRect(vrx,
                    c2.ToABGR(), c2.ToABGR(),
                    (x1 + distance), -800,
                    1200 - (x1 + distance), 1800);
            }
            //----------------------------------------------
            //translate vertex around x1,y1

            PixelFarm.Agg.Transform.AffinePlan[] affPlans =
                new PixelFarm.Agg.Transform.AffinePlan[]{
                   PixelFarm.Agg.Transform.AffinePlan.Translate(-x1,-y1),
                   PixelFarm.Agg.Transform.AffinePlan.Rotate(angleRad),
                   PixelFarm.Agg.Transform.AffinePlan.Translate(x1,y1)};
            var txMatrix = PixelFarm.Agg.Transform.Affine.NewMatix(affPlans);
            int j = vrx.Count;
            for (int i = j - 1; i >= 0; --i)
            {
                VertexC4V3f v = vrx[i];
                double v_x = v.x;
                double v_y = v.y;
                txMatrix.Transform(ref v_x, ref v_y);
                vrx[i] = new VertexC4V3f(v.color, (float)v_x, (float)v_y);
            }
            return vrx;
        }
Пример #20
0
        static public int LoadLionData(PathWriter path, PixelFarm.Drawing.Color[] colors, int[] path_idx)
        {
            // Parse the lion and then detect its bounding
            // box and arrange polygons orientations (make all polygons
            // oriented clockwise or counterclockwise)

            int npaths = 0;
            string[] splitOnNL = g_lion.Split('\n');
            foreach (string line in splitOnNL)
            {
                int newColor;
                if (line.Length > 0
                    && line[0] != 'M'
                    && Int32.TryParse(line, NumberStyles.HexNumber, null, out newColor))
                {
                    // New color. Every new color creates new path in the path object.
                    path.CloseFigure();
                    colors[npaths] = PixelFarm.Drawing.Color.CreatRGB8Packed((int)newColor);
                    path_idx[npaths] = path.StartFigure();
                    npaths++;
                }
                else
                {
                    bool startedPoly = false;
                    string[] splitOnSpace = line.Split(' ');
                    for (int i = 0; i < splitOnSpace.Length; i++)
                    {
                        string[] splitOnComma = splitOnSpace[i].Split(',');
                        if (splitOnComma.Length > 1)
                        {
                            double x = 0.0;
                            double y = 0.0;
                            double.TryParse(splitOnComma[0], NumberStyles.Number, null, out x);
                            double.TryParse(splitOnComma[1], NumberStyles.Number, null, out y);
                            if (!startedPoly)
                            {
                                startedPoly = true;
                                path.CloseFigure();
                                path.MoveTo(x, y);
                            }
                            else
                            {
                                path.LineTo(x, y);
                            }
                        }
                    }
                }
            }

            //path.ArrangeOrientationsAll(ShapePath.FlagsAndCommand.FlagCW);

            VertexHelper.ArrangeOrientationsAll(path.Vxs, true);
            return npaths;
        }
 public override void ClearSurface(PixelFarm.Drawing.Color c)
 {
     skCanvas.Clear(Conv1.ConvToColor(c));
 }
Пример #22
0
        EaseBox CreateGripper(PixelFarm.Drawing.Color bgcolor, bool isVertical)
        {
            int controllerBoxWH = 10;
            var gripperBox = new SimpleBox(controllerBoxWH, controllerBoxWH);
            gripperBox.BackColor = bgcolor;
            //---------------------------------------------------------------------

            gripperBox.MouseDrag += (s, e) =>
            {
                Point pos = gripperBox.Position;
                if (isVertical)
                {
                    gripperBox.SetLocation(pos.X, pos.Y + e.YDiff);
                }
                else
                {
                    gripperBox.SetLocation(pos.X + e.XDiff, pos.Y);
                }

                this.ninespaceGrippers.UpdateNinespaces();
                e.MouseCursorStyle = MouseCursorStyle.Pointer;
                e.CancelBubbling = true;
            };
            gripperBox.MouseUp += (s, e) =>
            {
                e.MouseCursorStyle = MouseCursorStyle.Default;
                e.CancelBubbling = true;
            };
            return gripperBox;
        }
 public void PrintToCanvas(PixelFarm.Drawing.WinGdi.MyGdiPlusCanvas canvas)
 {
     this.gdiPlusViewport.PaintMe(canvas);
 }
 static SkiaSharp.SKPath CreatePolygon(PixelFarm.Drawing.PointF[] points)
 {
     SkiaSharp.SKPath p = new SkiaSharp.SKPath();
     int j = points.Length;
     PixelFarm.Drawing.PointF p0 = new PixelFarm.Drawing.PointF();
     for (int i = 0; i < j; ++i)
     {
         if (i == 0)
         {
             p0 = points[0];
             p.MoveTo(p0.X, p0.Y);
         }
         else if (i == j - 1)
         {
             //last one
             var point = points[i];
             p.LineTo(point.X, point.Y);
             p.LineTo(p0.X, p0.Y);
             p.Close();
             break;
         }
         else
         {
             var point = points[i];
             p.LineTo(point.X, point.Y);
         }
     }
     return p;
 }
Пример #25
0
 public void Clear(PixelFarm.Drawing.Color c)
 {
     GL.ClearColor(
        (float)c.R / 255f,
        (float)c.G / 255f,
        (float)c.B / 255f,
        (float)c.A / 255f);
     GL.ClearStencil(0);
     //actual clear here !
     GL.Clear(ClearBufferMask.ColorBufferBit |
         ClearBufferMask.DepthBufferBit |
         ClearBufferMask.StencilBufferBit);
 }
        //----------------------------------------------------------------------------
        public static void CalculateLinearGradientVxs2(
            float x1, float y1,
            float x2, float y2,
            PixelFarm.Drawing.Color c1,
            PixelFarm.Drawing.Color c2,
            out float[] v2f,
            out float[] colors)
        {
            //1. gradient distance
            float dx = x2 - x1;
            float dy = y2 - y1;
            float distance = (float)Math.Pow(dx * dx + dy * dy, 0.5f);
            //find angle
            double angleRad = Math.Atan2(dy, dx);
            if (dx < 0)
            {
                //swap
                float tmpx = x2;
                x2 = x1;
                x1 = tmpx;
                float tmpy = y2;
                y2 = y1;
                y1 = tmpy;
                PixelFarm.Drawing.Color tmpc = c2;
                c2 = c1;
                c1 = tmpc;
            }

            ArrayList<VertexC4V3f> vrx = new ArrayList<VertexC4V3f>();
            //left solid rect pane 

            AddRect(vrx,
                c1.ToABGR(), c1.ToABGR(),
                -600, -800,
                x1 + 600, 1800);
            //color gradient pane 
            AddRect(vrx,
                c1.ToABGR(), c2.ToABGR(),
                x1, -800,
                distance, 1800);
            //right solid pane
            if (1200 - (x1 + distance) > 0)
            {
                AddRect(vrx,
                    c2.ToABGR(), c2.ToABGR(),
                    (x1 + distance), -800,
                    1200 - (x1 + distance), 1800);
            }
            //----------------------------------------------
            //translate vertex around x1,y1

            PixelFarm.Agg.Transform.AffinePlan[] affPlans =
                new PixelFarm.Agg.Transform.AffinePlan[]{
                   PixelFarm.Agg.Transform.AffinePlan.Translate(-x1,-y1),
                   PixelFarm.Agg.Transform.AffinePlan.Rotate(angleRad),
                   PixelFarm.Agg.Transform.AffinePlan.Translate(x1,y1)};
            var txMatrix = PixelFarm.Agg.Transform.Affine.NewMatix(affPlans);
            int j = vrx.Count;
            List<float> v2fList = new List<float>();
            List<float> colorList = new List<float>();
            for (int i = 0; i < j; ++i)
            {
                VertexC4V3f v = vrx[i];
                double v_x = v.x;
                double v_y = v.y;
                txMatrix.Transform(ref v_x, ref v_y);
                //vrx[i] = new VertexC4V3f(v.color, (float)v_x, (float)v_y);
                v2fList.Add((float)v_x);
                v2fList.Add((float)v_y);
                var color = v.color;
                //a,b,g,r

                colorList.Add((color & 0xff) / 255f);//r
                colorList.Add(((color >> 8) & 0xff) / 255f);//g 
                colorList.Add(((color >> 16) & 0xff) / 255f); //b
                colorList.Add(((color >> 24) & 0xff) / 255f); //a
            }
            v2f = v2fList.ToArray();
            colors = colorList.ToArray();
        }
Пример #27
0
        static PaintVisitor GetSharedPainter(LayoutFarm.HtmlBoxes.HtmlContainer htmlCont, PixelFarm.Drawing.Canvas canvas)
        {
            PaintVisitor painter = null;
            if (painterStock.Count == 0)
            {
                painter = new PaintVisitor();
            }
            else
            {
                painter = painterStock.Dequeue();
            }

            painter.Bind(htmlCont, canvas);
            return painter;
        }
 static CustomWidgets.EaseBox CreateSpaceBox(SpaceName name, PixelFarm.Drawing.Color bgcolor)
 {
     int controllerBoxWH = 10;
     var tinyBox = new CustomWidgets.SimpleBox(controllerBoxWH, controllerBoxWH);
     tinyBox.BackColor = bgcolor;
     tinyBox.Tag = name;
     return tinyBox;
 }
 public LazyAggBitmapBufferProvider(PixelFarm.Agg.ActualImage image)
 {
     this.image = image;
 }