예제 #1
0
        public override void FillPath(Brush brush, GraphicsPath path)
        {
            var solidBrush = (SolidBrush)brush;
            var vertices = path.Triangulate(v => new GLPoint((float)v.X, (float)v.Y, 0.0f, solidBrush.Color));

            _canvas.DrawTriangles(vertices.ToArray(), false);
        }
예제 #2
0
        public override void FillPath(Brush brush, GraphicsPath path)
        {
            var vertices = path.Triangulate(v => new SharpDX.Vector2((float)v.X, (float)v.Y));
            var triangles = new List<SharpDX.Direct2D1.Triangle>();

            for (int i = 0; i < vertices.Count; i += 3)
            {
                SharpDX.Direct2D1.Triangle triangle = new SharpDX.Direct2D1.Triangle();
                triangle.Point1 = vertices[i];
                triangle.Point2 = vertices[i + 1];
                triangle.Point3 = vertices[i + 2];
                triangles.Add(triangle);
            }

            using (var mesh = new SharpDX.Direct2D1.Mesh(_renderTarget, triangles.ToArray()))
            {
                var oldMode = _renderTarget.AntialiasMode;
                _renderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.Aliased;
                _renderTarget.FillMesh(mesh, new SharpDX.Direct2D1.SolidColorBrush(_renderTarget, ((SolidBrush)brush).Color.ToColor4()));
                _renderTarget.AntialiasMode = oldMode;
            }
        }