public void DrawGlyphRun(float baselineOriginX, float baselineOriginY, Graphics.Direct2D.MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ClientDrawingEffect clientDrawingEffect) { using (PathGeometry pathGeometry = _factory.CreatePathGeometry()) { using (GeometrySink sink = pathGeometry.Open()) { glyphRun.FontFace.GetGlyphRunOutline( glyphRun.EmSize, glyphRun.GlyphIndices, glyphRun.GlyphAdvances, glyphRun.GlyphOffsets, glyphRun.IsSideways, glyphRun.BidiLevel != 0, sink); sink.Close(); } CustomGeometrySink customSink = new CustomGeometrySink(); pathGeometry.Stream(customSink); customSink.Close(); System.Diagnostics.Debug.WriteLine(customSink.ToString()); Matrix3x2 matrix = new Matrix3x2(1, 0, 0, 1, baselineOriginX, baselineOriginY); using (TransformedGeometry transformedGeometry = _factory.CreateTransformedGeometry(pathGeometry, matrix)) { _renderTarget.DrawGeometry(_outlineBrush, 5, transformedGeometry); _renderTarget.FillGeometry(_fillBrush, transformedGeometry); } } }
protected override void OnRender(WindowRenderTarget renderTarget) { RectF bounds = new RectF(new PointF(), renderTarget.Size); renderTarget.FillRect(_gridPatternBrush, bounds); renderTarget.FillGeometry(this._radialGradientBrush, this._sunGeometry); this._sceneBrush.Color = Color.FromKnown(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, _sunGeometry); this._sceneBrush.Color = Color.FromKnown(Colors.OliveDrab, 1); renderTarget.FillGeometry(this._sceneBrush, this._leftMountainGeometry); this._sceneBrush.Color = Color.FromKnown(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, this._leftMountainGeometry); this._sceneBrush.Color = Color.FromKnown(Colors.LightSkyBlue, 1); renderTarget.FillGeometry(this._sceneBrush, this._riverGeometry); this._sceneBrush.Color = Color.FromKnown(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, this._riverGeometry); this._sceneBrush.Color = Color.FromKnown(Colors.YellowGreen, 1); renderTarget.FillGeometry(this._sceneBrush, this._rightMountainGeometry); this._sceneBrush.Color = Color.FromKnown(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, this._rightMountainGeometry); }
public void DrawConvexPath(Geometry geo, Brush brush) { AntiAliasing = true; PushTranslation(0.5f, 0.5f); renderTarget.DrawGeometry(geo, brush); PopTransform(); AntiAliasing = false; }
protected override void OnRender(WindowRenderTarget renderTarget) { if (_task != null) { _task.Wait(); _task.Dispose(); } List <Tuple <Geometry, Color> > copy = _geometries; _task = CreateGeometries(_time); if (_time == 0.1f) { renderTarget.Clear(Color.FromKnown(Colors.Black, 1f)); } renderTarget.FillRect(_brush, new RectF(0, 0, ClientSize.Width, ClientSize.Height)); for (int index = 0; index < copy.Count; ++index) { Tuple <Geometry, Color> tuple = copy[index]; using (Geometry geometry = tuple.Item1) { using (SolidColorBrush brush = renderTarget.CreateSolidColorBrush(tuple.Item2.AdjustContrast(1.5f))) { renderTarget.DrawGeometry(brush, 0.1f, geometry); } } } copy.Clear(); _time += 0.002f; }
private void MainWindow_Paint(object sender, PaintEventArgs e) { _renderTarget.BeginDraw(); _renderTarget.Clear(Color.FromKnown(Colors.Blue, 1)); PointF center = new PointF(ClientSize.Width / 2, ClientSize.Height / 2); _renderTarget.Transform = Matrix3x2.Rotation(_angle, center); RoundedRect rr = new RoundedRect(new RectF(30, 30, ClientSize.Width - 60, ClientSize.Height - 60), ClientSize.Width / 2.5f, ClientSize.Height / 2.5f); _renderTarget.FillRoundedRect(RectBrush, rr); _renderTarget.DrawRoundedRect(_strokeBrush, 5, _strokeStyle, rr); Ellipse ellipse = new Ellipse(ClientSize.Width / 2, ClientSize.Height / 2, ClientSize.Width / 4, ClientSize.Height / 4); using (EllipseGeometry eg = _factory.CreateEllipseGeometry(ellipse)) { using (Brush b = CreateEllipseBrush(ellipse)) { _renderTarget.FillGeometry(b, eg); _renderTarget.DrawGeometry(_strokeBrush, 5, _strokeStyle, eg); } } RectF textBounds = new RectF(0, 0, ClientSize.Width, ClientSize.Height); _renderTarget.DrawText("Hello, world!", _textFormat, textBounds, _strokeBrush, DrawTextOptions.None, MeasuringMode.Natural); _renderTarget.DrawLine(_strokeBrush, 5, _strokeStyle, new PointF(0, 0), new PointF(ClientSize.Width, ClientSize.Height)); _renderTarget.EndDraw(); }
public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect) { var pathGeometry = new PathGeometry(_d2DFactory); var geometrySink = pathGeometry.Open(); var fontFace = glyphRun.FontFace; if (glyphRun.Indices.Length > 0) { fontFace.GetGlyphRunOutline(glyphRun.FontSize, glyphRun.Indices, glyphRun.Advances, glyphRun.Offsets, glyphRun.IsSideways, glyphRun.BidiLevel % 2 != 0, geometrySink); } geometrySink.Close(); geometrySink.Dispose(); fontFace.Dispose(); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, pathGeometry, matrix); var brushColor = (Color4)Color.Black; if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect) { brushColor = (clientDrawingEffect as ColorDrawingEffect).Color; } var brush = new SolidColorBrush(_renderTarget, brushColor); _renderTarget.DrawGeometry(transformedGeometry, brush); _renderTarget.FillGeometry(transformedGeometry, brush); pathGeometry.Dispose(); transformedGeometry.Dispose(); brush.Dispose(); return(SharpDX.Result.Ok); }
protected void DrawPolygon(WindowRenderTarget device, Color color, Vector2 start, Vector2 middle, Vector2 end, float strokeWidth = 1f) { using (PathGeometry gmtry = CreatePathGeometry(start, middle, end)) { using (SolidColorBrush brush = new SolidColorBrush(device, color)) { device.DrawGeometry(gmtry, brush); } } }
protected void DrawGeometry(WindowRenderTarget device, Color color, float strokeWidth, params Vector2[] points) { using (PathGeometry gmtry = CreatePathGeometry(points)) { using (SolidColorBrush brush = new SolidColorBrush(device, color)) { device.DrawGeometry(gmtry, brush, strokeWidth); } } }
public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect) { var pathGeometry = new PathGeometry(_d2DFactory); var geometrySink = pathGeometry.Open(); float[] advances; GlyphOffset[] offsets; var indecies = glyphRun.ToArrays(out advances, out offsets); var result = glyphRun.FontFace.GetGlyphRunOutline(glyphRun.FontSize, indecies, advances, offsets, glyphRun.IsSideways, glyphRun.BidiLevel % 2 != 0, geometrySink); geometrySink.Close(); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, pathGeometry, matrix); var brushColor = new Color4(1, 0, 0, 0); if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect) { brushColor = (clientDrawingEffect as ColorDrawingEffect).Color; } var brush = new SolidColorBrush(_renderTarget, brushColor); _renderTarget.DrawGeometry(transformedGeometry, brush); _renderTarget.FillGeometry(transformedGeometry, brush); pathGeometry.Dispose(); transformedGeometry.Dispose(); brush.Dispose(); return(SharpDX.Result.Ok); }
protected override void OnRender(WindowRenderTarget renderTarget) { renderTarget.Clear(Color.FromKnown(Colors.Black, 1)); using (EllipseGeometry geometry = Direct2DFactory.CreateEllipseGeometry(new Graphics.Direct2D.Ellipse(ClientSize.Width / 2, ClientSize.Height / 2, ClientSize.Width / 2 - 25, ClientSize.Height / 2 - 25))) { using (SolidColorBrush brush = renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.Red, 1))) { renderTarget.DrawGeometry(brush, 50, geometry); } } }
public void BorderedLine(float start_x, float start_y, float end_x, float end_y, float stroke, Direct2DColor color, Direct2DColor borderColor) { var geometry = new PathGeometry(_factory); var sink = geometry.Open(); float half = stroke / 2.0f; float quarter = half / 2.0f; sink.BeginFigure(new RawVector2(start_x, start_y - half), FigureBegin.Filled); sink.AddLine(new RawVector2(end_x, end_y - half)); sink.AddLine(new RawVector2(end_x, end_y + half)); sink.AddLine(new RawVector2(start_x, start_y + half)); sink.EndFigure(FigureEnd.Closed); sink.Close(); _sharedBrush.Color = borderColor; _device.DrawGeometry(geometry, _sharedBrush, half); _sharedBrush.Color = color; _device.FillGeometry(geometry, _sharedBrush); sink.Dispose(); geometry.Dispose(); }
public void DrawTriangle(float x_x, float x_y, float y_x, float y_y, float z_x, float z_y, float stroke, Dx2DColor color) { _brush.Color = color; using (var path = new PathGeometry(_factory)) { using (var sink = path.Open()) { sink.BeginFigure(new RawVector2(x_x, x_y), FigureBegin.Hollow); sink.AddLine(new RawVector2(y_x, y_y)); sink.AddLine(new RawVector2(z_x, z_y)); sink.EndFigure(FigureEnd.Closed); sink.Close(); _device.DrawGeometry(path, _brush, stroke); } } }
public void DrawConvexPath(Geometry geo, Brush brush) { PushTranslation(0.5f, 0.5f); renderTarget.DrawGeometry(geo, brush); PopTransform(); }
private void RenderingDrawCircle(float[] center, float radius, double percentage, int[] color, int thickness, bool drawWorldMap, bool fill = false) { if (drawWorldMap) { radius = radius * 10; } double segments = 20; if (drawWorldMap) { segments /= 2; } RawVector2[] pts = new RawVector2[(int)segments + 1]; double angle = 0; double segmentSize = (360 * percentage) / segments; int[] sCenter; if (!Helpers.ViewTransform.ToScreen.WorldToScreen(center, out sCenter, drawWorldMap)) { return; } int count = 0; if (percentage < 1) { pts = new RawVector2[(int)segments + 3]; pts[0] = new RawVector2(sCenter[0], sCenter[1]); count = 1; } while (angle <= (360 * percentage)) { float X = (float)(center[0] + (radius * Math.Cos(angle / (180 / Math.PI)))); float Z = (float)(center[2] + (radius * Math.Sin(angle / (180 / Math.PI)))); int[] screen; if (Helpers.ViewTransform.ToScreen.WorldToScreen(new float[] { X, center[1], Z }, out screen, drawWorldMap)) { pts[count] = new RawVector2(screen[0], screen[1]); } else { return; } angle += segmentSize; count++; } if (percentage < 1) { pts[pts.Length - 1] = pts[0]; } pathGeometry = new PathGeometry(factory); geometrySink = pathGeometry.Open(); geometrySink.BeginFigure(pts[0], new FigureBegin()); geometrySink.AddLines(pts); geometrySink.EndFigure(new FigureEnd()); geometrySink.Close(); ChangeColor(color); device.DrawGeometry(pathGeometry, solidColorBrush); if (fill) { device.FillGeometry(pathGeometry, solidColorBrush); } pathGeometry.Dispose(); geometrySink.Dispose(); }
protected override void OnRender(WindowRenderTarget renderTarget) { RectF bounds = new RectF(new PointF(), renderTarget.Size); renderTarget.FillRect(_gridPatternBrush, bounds); // Draw the geomtries before merging. renderTarget.FillGeometry(this._shapeFillBrush, this._circleGeometry1); renderTarget.DrawGeometry(this._outlineBrush, 1, _circleGeometry1); renderTarget.FillGeometry(this._shapeFillBrush, this._circleGeometry2); renderTarget.DrawGeometry(this._outlineBrush, 1, _circleGeometry2); renderTarget.DrawText( "The circles before combining", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(200, 0); // Draw the geometries merged using the union combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryUnion); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryUnion); renderTarget.DrawText( "CombineMode.Union", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(400, 0); // Draw the geometries merged using the intersect combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryIntersect); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryIntersect); renderTarget.DrawText( "CombineMode.Intersect", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(200, 150); // Draw the geometries merged using the XOR combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryXor); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryXor); renderTarget.DrawText( "CombineMode.Xor", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(400, 150); // Draw the geometries merged using the Exclude combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryExclude); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryExclude); renderTarget.DrawText( "CombineMode.Exclude", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); //// The following code demonstrates how to call various geometric operations. Depending on //// your needs, it lets you decide how to use those output values. //D2D1_GEOMETRY_RELATION result = D2D1_GEOMETRY_RELATION_UNKNOWN; //// Compare circle1 with circle2 //hr = m_pCircleGeometry1->CompareWithGeometry( // m_pCircleGeometry2, // D2D1::IdentityMatrix(), // 0.1f, // &result // ); //if (SUCCEEDED(hr)) //{ // static const WCHAR szGeometryRelation[] = L"Two circles overlap."; // renderTarget.SetTransform(D2D1::IdentityMatrix()); // if (result == D2D1_GEOMETRY_RELATION_OVERLAP) // { // renderTarget.DrawText( // szGeometryRelation, // ARRAYSIZE(szGeometryRelation) - 1, // m_pTextFormat, // D2D1::RectF(25.0f, 160.0f, 200.0f, 300.0f), // m_pTextBrush // ); // } //} //float area; //// Compute the area of circle1 //hr = m_pCircleGeometry1->ComputeArea( // D2D1::IdentityMatrix(), // &area // ); //float length; //// Compute the area of circle1 //hr = m_pCircleGeometry1->ComputeLength( // D2D1::IdentityMatrix(), // &length // ); //if (SUCCEEDED(hr)) //{ // // Process the length of the geometry. //} //D2D1_POINT_2F point; //D2D1_POINT_2F tangent; //hr = m_pCircleGeometry1->ComputePointAtLength( // 10, // NULL, // &point, // &tangent); //if (SUCCEEDED(hr)) //{ // // Retrieve the point and tangent point. //} //D2D1_RECT_F bounds; //hr = m_pCircleGeometry1->GetBounds( // D2D1::IdentityMatrix(), // &bounds // ); //if (SUCCEEDED(hr)) //{ // // Retrieve the bounds. //} //D2D1_RECT_F bounds1; //hr = m_pCircleGeometry1->GetWidenedBounds( // 5.0, // m_pStrokeStyle, // D2D1::IdentityMatrix(), // &bounds1 // ); //if (SUCCEEDED(hr)) //{ // // Retrieve the widened bounds. //} //BOOL containsPoint; //hr = m_pCircleGeometry1->StrokeContainsPoint( // D2D1::Point2F(0,0), // 10, // stroke width // NULL, // stroke style // NULL, // world transform // &containsPoint // ); //if (SUCCEEDED(hr)) //{ // // Process containsPoint. //} //BOOL containsPoint1; //hr = m_pCircleGeometry1->FillContainsPoint( // D2D1::Point2F(0,0), // D2D1::Matrix3x2F::Identity(), // &containsPoint1 // ); }
private void DrawCircle(decimal currentValue, decimal maxValue, int thisIndex, int selectedIndex) { int partyIndex = (Party.PartySize - 4) * -1; PointF location = new PointF(Config.CooldownBarLocation.X + (Config.CooldownBarXOffset * thisIndex), Config.CooldownBarLocation.Y + (Config.CooldownBarXOffset != 0 ? 0 : ((Config.CooldownBarYOffsets[partyIndex] * thisIndex) + Config.PartyNumBarOffsets[partyIndex]))); if (thisIndex == selectedIndex) { if (Config.CooldownBarYOffsets[partyIndex] > 0) { location.X += Config.CooldownBarSelOffset; } else { location.Y += Config.CooldownBarSelOffset; } } int scale = Config.CooldownBarSize.Height; int lineWidth = Config.CooldownBarSize.Width; bool drawPie = Config.CooldownBarSize.Width > Config.CooldownBarSize.Height * 2; int val = (int)(360 - (360 * (currentValue / (maxValue + 0.01M)))); Vector2 circleCenter = new Vector2(location.X, location.Y); Vector2 circleStart = new Vector2(circleCenter.X, circleCenter.Y - scale); Vector2 circleStartBG = new Vector2(circleCenter.X, circleCenter.Y + scale); float thetaDegrees = (float)(val * 0.0174533); float thetaDegreesBG = (float)((360 - (180 - val)) * 0.0174533); Vector2 circleEnd = Matrix3x2.TransformPoint(Matrix3x2.Rotation(thetaDegrees, circleCenter), circleStart); Vector2 circleEndBG = Matrix3x2.TransformPoint(Matrix3x2.Rotation(thetaDegreesBG, circleCenter), circleStartBG); float dx = circleStart.X - circleCenter.X; float dy = circleStart.Y - circleCenter.Y; float radius = (float)Math.Sqrt(dx * dx + dy * dy); if (val < 360 && BGColorBrush.Color.A > 0 && ((thisIndex != selectedIndex && FG1ColorBrush.Color.A > 0) || (thisIndex == selectedIndex && SELColorBrush.Color.A > 0))) { using (PathGeometry pathGeometry = new PathGeometry(Factory)) { using (GeometrySink geometrySink = pathGeometry.Open()) { if (val <= 180) { geometrySink.BeginFigure(drawPie ? circleCenter : circleStartBG, FigureBegin.Filled); if (drawPie) { geometrySink.AddLine(circleStartBG); } geometrySink.AddArc(new ArcSegment() { Point = (val == 0) ? circleStart : circleEndBG, Size = new Size2F(radius, radius), RotationAngle = 0.0f, SweepDirection = SweepDirection.CounterClockwise, ArcSize = ArcSize.Small }); geometrySink.EndFigure(drawPie ? FigureEnd.Closed : FigureEnd.Open); } geometrySink.BeginFigure(drawPie ? circleCenter : circleStart, FigureBegin.Filled); if (drawPie) { geometrySink.AddLine(circleStart); } geometrySink.AddArc(new ArcSegment() { Point = (val <= 180) ? circleStartBG : circleEndBG, Size = new Size2F(radius, radius), RotationAngle = 0.0f, SweepDirection = SweepDirection.CounterClockwise, ArcSize = ArcSize.Small }); geometrySink.EndFigure(drawPie ? FigureEnd.Closed : FigureEnd.Open); geometrySink.Close(); if (drawPie) { Render.FillGeometry(pathGeometry, BGColorBrush); } else { //using(StrokeStyle strokeStyle = new StrokeStyle(Factory, // new StrokeStyleProperties() { DashCap = CapStyle.Flat, DashStyle = DashStyle.Solid, LineJoin = LineJoin.Miter, StartCap = CapStyle.Flat, EndCap = CapStyle.Flat, MiterLimit = 0, DashOffset = 0 })) { //} Render.DrawGeometry(pathGeometry, BGColorBrush, lineWidth); //, strokeStyle); } } } } if ((thisIndex != selectedIndex && FG1ColorBrush.Color.A > 0) || (thisIndex == selectedIndex && SELColorBrush.Color.A > 0) || (FG2ColorBrush.Color.A > 0 && val == 360)) { using (PathGeometry pathGeometry = new PathGeometry(Factory)) { using (GeometrySink geometrySink = pathGeometry.Open()) { geometrySink.BeginFigure(drawPie ? circleCenter : circleStart, FigureBegin.Filled); if (drawPie) { geometrySink.AddLine(circleStart); } geometrySink.AddArc(new ArcSegment() { Point = (val > 180) ? new Vector2(circleStart.X, circleStart.Y + (radius * 2)) : circleEnd, Size = new Size2F(radius, radius), RotationAngle = 0.0f, SweepDirection = SweepDirection.Clockwise, ArcSize = ArcSize.Small }); geometrySink.EndFigure(drawPie ? FigureEnd.Closed : FigureEnd.Open); if (val > 180) { geometrySink.BeginFigure(drawPie ? circleCenter : new Vector2(circleStart.X, circleStart.Y + (radius * 2)), FigureBegin.Filled); if (drawPie) { geometrySink.AddLine(new Vector2(circleStart.X, circleStart.Y + (radius * 2))); } geometrySink.AddArc(new ArcSegment() { Point = circleEnd, Size = new Size2F(radius, radius), RotationAngle = 0.0f, SweepDirection = SweepDirection.Clockwise, ArcSize = ArcSize.Small }); geometrySink.EndFigure(drawPie ? FigureEnd.Closed : FigureEnd.Open); } geometrySink.Close(); if (drawPie) { Render.FillGeometry(pathGeometry, val == 360 ? FG2ColorBrush : thisIndex != selectedIndex ? FG1ColorBrush : SELColorBrush); } else { //using(StrokeStyle strokeStyle = new StrokeStyle(Factory, // new StrokeStyleProperties() { DashCap = CapStyle.Flat, DashStyle = DashStyle.Solid, LineJoin = LineJoin.Miter, StartCap = CapStyle.Flat, EndCap = CapStyle.Flat, MiterLimit = 0, DashOffset = 0 })) { //} Render.DrawGeometry(pathGeometry, val == 360 ? FG2ColorBrush : thisIndex != selectedIndex ? FG1ColorBrush : SELColorBrush, lineWidth); //, strokeStyle); } } } } if (Config.CooldownBarTextFontSize > 0 && Config.CooldownBarTextFontSize > 0 && val == 360 && FG2TColorBrush.Color.A > 0) { DrawText(Config.CooldownBarTextReady != "" ? Config.CooldownBarTextReady : FormatDecimalToString(currentValue, Config.CooldownBarTextDecimal), circleCenter.X + Config.CooldownBarTextOffset.X, circleCenter.Y + Config.CooldownBarTextOffset.Y, FG2TColorBrush, BGTColorBrush); } else if (Config.CooldownBarTextFontSize > 0 && Config.CooldownBarTextFontSize > 0 && val < 360 && thisIndex != selectedIndex && FG1TColorBrush.Color.A > 0) { DrawText(FormatDecimalToString(currentValue, Config.CooldownBarTextDecimal), circleCenter.X + Config.CooldownBarTextOffset.X, circleCenter.Y + Config.CooldownBarTextOffset.Y, FG1TColorBrush, BGTColorBrush); } else if (Config.CooldownBarTextFontSize > 0 && Config.CooldownBarTextFontSize > 0 && val < 360 && thisIndex == selectedIndex && SELTColorBrush.Color.A > 0) { DrawText(FormatDecimalToString(currentValue, Config.CooldownBarTextDecimal), circleCenter.X + Config.CooldownBarTextOffset.X, circleCenter.Y + Config.CooldownBarTextOffset.Y, SELTColorBrush, BGTColorBrush); } }
protected override void OnRender(WindowRenderTarget renderTarget) { RectF bounds = new RectF(new PointF(), renderTarget.Size); renderTarget.FillRect(_gridPatternBrush, bounds); // Draw the geomtries before merging. renderTarget.FillGeometry(this._shapeFillBrush, this._circleGeometry1); renderTarget.DrawGeometry(this._outlineBrush, 1, _circleGeometry1); renderTarget.FillGeometry(this._shapeFillBrush, this._circleGeometry2); renderTarget.DrawGeometry(this._outlineBrush, 1, _circleGeometry2); renderTarget.DrawText( "The circles before combining", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(200, 0); // Draw the geometries merged using the union combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryUnion); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryUnion); renderTarget.DrawText( "CombineMode.Union", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(400, 0); // Draw the geometries merged using the intersect combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryIntersect); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryIntersect); renderTarget.DrawText( "CombineMode.Intersect", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(200, 150); // Draw the geometries merged using the XOR combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryXor); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryXor); renderTarget.DrawText( "CombineMode.Xor", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); renderTarget.Transform = Matrix3x2.Translation(400, 150); // Draw the geometries merged using the Exclude combine mode. renderTarget.FillGeometry(this._shapeFillBrush, this._geometryExclude); renderTarget.DrawGeometry(this._outlineBrush, 1, this._geometryExclude); renderTarget.DrawText( "CombineMode.Exclude", this._textFormat, new RectF(25, 130, 150, 170), _textFillBrush, DrawTextOptions.None, MeasuringMode.Natural); //// The following code demonstrates how to call various geometric operations. Depending on //// your needs, it lets you decide how to use those output values. //D2D1_GEOMETRY_RELATION result = D2D1_GEOMETRY_RELATION_UNKNOWN; //// Compare circle1 with circle2 //hr = m_pCircleGeometry1->CompareWithGeometry( // m_pCircleGeometry2, // D2D1::IdentityMatrix(), // 0.1f, // &result // ); //if (SUCCEEDED(hr)) //{ // static const WCHAR szGeometryRelation[] = L"Two circles overlap."; // renderTarget.SetTransform(D2D1::IdentityMatrix()); // if (result == D2D1_GEOMETRY_RELATION_OVERLAP) // { // renderTarget.DrawText( // szGeometryRelation, // ARRAYSIZE(szGeometryRelation) - 1, // m_pTextFormat, // D2D1::RectF(25.0f, 160.0f, 200.0f, 300.0f), // m_pTextBrush // ); // } //} //float area; //// Compute the area of circle1 //hr = m_pCircleGeometry1->ComputeArea( // D2D1::IdentityMatrix(), // &area // ); //float length; //// Compute the area of circle1 //hr = m_pCircleGeometry1->ComputeLength( // D2D1::IdentityMatrix(), // &length // ); //if (SUCCEEDED(hr)) //{ // // Process the length of the geometry. //} //D2D1_POINT_2F point; //D2D1_POINT_2F tangent; //hr = m_pCircleGeometry1->ComputePointAtLength( // 10, // NULL, // &point, // &tangent); //if (SUCCEEDED(hr)) //{ // // Retrieve the point and tangent point. //} //D2D1_RECT_F bounds; //hr = m_pCircleGeometry1->GetBounds( // D2D1::IdentityMatrix(), // &bounds // ); //if (SUCCEEDED(hr)) //{ // // Retrieve the bounds. //} //D2D1_RECT_F bounds1; //hr = m_pCircleGeometry1->GetWidenedBounds( // 5.0, // m_pStrokeStyle, // D2D1::IdentityMatrix(), // &bounds1 // ); //if (SUCCEEDED(hr)) //{ // // Retrieve the widened bounds. //} //BOOL containsPoint; //hr = m_pCircleGeometry1->StrokeContainsPoint( // D2D1::Point2F(0,0), // 10, // stroke width // NULL, // stroke style // NULL, // world transform // &containsPoint // ); //if (SUCCEEDED(hr)) //{ // // Process containsPoint. //} //BOOL containsPoint1; //hr = m_pCircleGeometry1->FillContainsPoint( // D2D1::Point2F(0,0), // D2D1::Matrix3x2F::Identity(), // &containsPoint1 // ); }
protected override void OnRender(WindowRenderTarget renderTarget) { RectF bounds = new RectF(new PointF(), renderTarget.Size); renderTarget.FillRect(_gridPatternBrush, bounds); renderTarget.FillGeometry(this._radialGradientBrush, this._sunGeometry); this._sceneBrush.Color = Color.FromARGB(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, _sunGeometry); this._sceneBrush.Color = Color.FromARGB(Colors.OliveDrab, 1); renderTarget.FillGeometry(this._sceneBrush, this._leftMountainGeometry); this._sceneBrush.Color = Color.FromARGB(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, this._leftMountainGeometry); this._sceneBrush.Color = Color.FromARGB(Colors.LightSkyBlue, 1); renderTarget.FillGeometry(this._sceneBrush, this._riverGeometry); this._sceneBrush.Color = Color.FromARGB(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, this._riverGeometry); this._sceneBrush.Color = Color.FromARGB(Colors.YellowGreen, 1); renderTarget.FillGeometry(this._sceneBrush, this._rightMountainGeometry); this._sceneBrush.Color = Color.FromARGB(Colors.Black, 1); renderTarget.DrawGeometry(this._sceneBrush, 1, this._rightMountainGeometry); }