public override void OnDraw(Graphics2D graphics2D) { byte alpha = (byte)(alphaSlider.Value * 255); for (int i = 0; i < lionShape.NumPaths; i++) { lionShape.Colors[i].Alpha0To255 = alpha; } Affine transform = Affine.NewIdentity(); transform *= Affine.NewTranslation(-lionShape.Center.X, -lionShape.Center.Y); transform *= Affine.NewScaling(lionScale, lionScale); transform *= Affine.NewRotation(angle + Math.PI); transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0); transform *= Affine.NewTranslation(Width / 2, Height / 2); // This code renders the lion: VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(lionShape.Path, transform); graphics2D.Render(transformedPathStorage, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths); graphics2D.DrawString("test", 40, 40, 50); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { if (!putUpDiagnostics) { //DiagnosticWidget diagnosticView = new DiagnosticWidget(this); putUpDiagnostics = true; } this.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255)); base.OnDraw(graphics2D); long milliseconds = totalTime.ElapsedMilliseconds; graphics2D.DrawString("ms: ", Width - 60, Height - 14); graphics2D.DrawString(milliseconds.ToString() + " ", Width, Height - 14, justification: Justification.Right); totalTime.Restart(); }
public override void OnDraw(Graphics2D graphics2D) { byte alpha = (byte)(alphaSlider.Value * 255); foreach (var shape in lionShape.Shapes) { shape.Color = new Color(shape.Color, alpha); } Affine transform = Affine.NewIdentity(); transform *= Affine.NewTranslation(-lionShape.Center.X, -lionShape.Center.Y); transform *= Affine.NewScaling(lionScale, lionScale); transform *= Affine.NewRotation(angle + Math.PI); transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0); transform *= Affine.NewTranslation(Width / 2, Height / 2); // This code renders the lion: foreach (var shape in lionShape.Shapes) { VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(shape.VertexStorage, transform); graphics2D.Render(transformedPathStorage, shape.Color); } graphics2D.DrawString("test", 40, 40, 50); base.OnDraw(graphics2D); }
public FloodFillDemo() { BackgroundColor = RGBA_Bytes.White; imageToFillOn = new ImageBuffer(400, 300, 32, new BlenderBGRA()); Graphics2D imageToFillGraphics = imageToFillOn.NewGraphics2D(); imageToFillGraphics.Clear(RGBA_Bytes.White); imageToFillGraphics.DrawString("Click to fill", 20, 30); imageToFillGraphics.Circle(new Vector2(200, 150), 35, RGBA_Bytes.Black); imageToFillGraphics.Circle(new Vector2(200, 150), 30, RGBA_Bytes.Green); imageToFillGraphics.Rectangle(20, 50, 210, 280, RGBA_Bytes.Black); imageToFillGraphics.Rectangle(imageToFillOn.GetBounds(), RGBA_Bytes.Blue); Random rand = new Random(); for (int i = 0; i < 20; i++) { Ellipse elipse = new Ellipse(rand.Next(imageToFillOn.Width), rand.Next(imageToFillOn.Height), rand.Next(10, 60), rand.Next(10, 60)); Stroke outline = new Stroke(elipse); imageToFillGraphics.Render(outline, RGBA_Bytes.Black); } m_slider1 = new Slider(new Vector2(80, 10), 510); m_slider2 = new Slider(new Vector2(80, 10 + 20), 510); m_slider1.ValueChanged += new EventHandler(NeedsRedraw); m_slider2.ValueChanged += new EventHandler(NeedsRedraw); AddChild(m_slider1); AddChild(m_slider2); m_slider1.Text = "Pixel size={0:F3}"; m_slider1.SetRange(8, 100); m_slider1.NumTicks = 23; m_slider1.Value = 32; m_slider2.Text = "gamma={0:F3}"; m_slider2.SetRange(0.0, 3.0); m_slider2.Value = 1.0; }
public override void OnDraw(Graphics2D graphics2D) { double textHeight = 20; double textY = 200; base.OnDraw(graphics2D); graphics2D.DrawString("YOffset = {0:0.00}".FormatWith(yOffsetUpper), 20, Height - 20); graphics2D.DrawString("YScale = {0:0.00}".FormatWith(ySizeUpper), 140, Height - 20); graphics2D.DrawString("YOffset = {0:0.00}".FormatWith(yOffsetLower), 20, Height - 40); graphics2D.DrawString("YScale = {0:0.00}".FormatWith(ySizeLower), 140, Height - 40); graphics2D.DrawString(alphabet, 20, textY); graphics2D.DrawString(alphabet.ToLower(), 310, textY); TypeFacePrinter upperPrinter = new TypeFacePrinter(alphabet); TypeFacePrinter lowerPrinter = new TypeFacePrinter(alphabet.ToLower()); graphics2D.Render(new VertexSourceApplyTransform(upperPrinter, Affine.NewScaling(1, (12 + ySizeUpper) / 12)), 20, textY - textHeight + yOffsetUpper, Color.Black); graphics2D.Render(new VertexSourceApplyTransform(lowerPrinter, Affine.NewScaling(1, (12 + ySizeLower) / 12)), 310, textY - textHeight + yOffsetLower, Color.Black); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage); clippingProxy.clear(new ColorF(1, 1, 1)); m_ras.SetVectorClipBox(0, 0, Width, Height); Affine move = Affine.NewTranslation(10, 10); Perspective shadow_persp = new Perspective(m_shape_bounds.Left, m_shape_bounds.Bottom, m_shape_bounds.Right, m_shape_bounds.Top, m_shadow_ctrl.polygon()); IVertexSource shadow_trans; if (m_FlattenCurves.Checked) { shadow_trans = new VertexSourceApplyTransform(m_shape, shadow_persp); } else { shadow_trans = new VertexSourceApplyTransform(m_path, shadow_persp); // this will make it very smooth after the transform //shadow_trans = new conv_curve(shadow_trans); } // Render shadow m_ras.add_path(shadow_trans); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, new ColorF(0.2, 0.3, 0).ToColor()); // Calculate the bounding box and extend it by the blur radius RectangleDouble bbox = new RectangleDouble(); bounding_rect.bounding_rect_single(shadow_trans, 0, ref bbox); bbox.Left -= m_radius.Value; bbox.Bottom -= m_radius.Value; bbox.Right += m_radius.Value; bbox.Top += m_radius.Value; if (m_method.SelectedIndex == 1) { // The recursive blur method represents the true Gaussian Blur, // with theoretically infinite kernel. The restricted window size // results in extra influence of edge pixels. It's impossible to // solve correctly, but extending the right and top areas to another // radius value produces fair result. //------------------ bbox.Right += m_radius.Value; bbox.Top += m_radius.Value; } stopwatch.Restart(); if (m_method.SelectedIndex != 2) { // Create a new pixel renderer and attach it to the main one as a child image. // It returns true if the attachment succeeded. It fails if the rectangle // (bbox) is fully clipped. //------------------ #if SourceDepth24 ImageBuffer image2 = new ImageBuffer(new BlenderBGR()); #else ImageBuffer image2 = new ImageBuffer(new BlenderBGRA()); #endif if (image2.Attach(widgetsSubImage, (int)bbox.Left, (int)bbox.Bottom, (int)bbox.Right, (int)bbox.Top)) { // Blur it if (m_method.SelectedIndex == 0) { // More general method, but 30-40% slower. //------------------ //m_stack_blur.blur(pixf2, agg::uround(m_radius.Value)); // Faster, but bore specific. // Works only for 8 bits per channel and only with radii <= 254. //------------------ stack_blur test = new stack_blur(); test.Blur(image2, agg_basics.uround(m_radius.Value), agg_basics.uround(m_radius.Value)); } else { // True Gaussian Blur, 3-5 times slower than Stack Blur, // but still constant time of radius. Very sensitive // to precision, doubles are must here. //------------------ m_recursive_blur.blur(image2, m_radius.Value); } } } else { /* * // Blur separate channels * //------------------ * if(m_channel_r.Checked) * { * typedef agg::pixfmt_alpha_blend_gray< * agg::blender_gray8, * agg::rendering_buffer, * 3, 2> pixfmt_gray8r; * * pixfmt_gray8r pixf2r(m_rbuf2); * if(pixf2r.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) * { * agg::stack_blur_gray8(pixf2r, agg::uround(m_radius.Value), * agg::uround(m_radius.Value)); * } * } * * if(m_channel_g.Checked) * { * typedef agg::pixfmt_alpha_blend_gray< * agg::blender_gray8, * agg::rendering_buffer, * 3, 1> pixfmt_gray8g; * * pixfmt_gray8g pixf2g(m_rbuf2); * if(pixf2g.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) * { * agg::stack_blur_gray8(pixf2g, agg::uround(m_radius.Value), * agg::uround(m_radius.Value)); * } * } * * if(m_channel_b.Checked) * { * typedef agg::pixfmt_alpha_blend_gray< * agg::blender_gray8, * agg::rendering_buffer, * 3, 0> pixfmt_gray8b; * * pixfmt_gray8b pixf2b(m_rbuf2); * if(pixf2b.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) * { * agg::stack_blur_gray8(pixf2b, agg::uround(m_radius.Value), * agg::uround(m_radius.Value)); * } * } */ } double tm = stopwatch.ElapsedMilliseconds; // Render the shape itself //------------------ if (m_FlattenCurves.Checked) { m_ras.add_path(m_shape); } else { m_ras.add_path(m_path); } scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, new ColorF(0.6, 0.9, 0.7, 0.8).ToColor()); graphics2D.DrawString(string.Format("{0:F2} ms", tm), 140, 30); base.OnDraw(graphics2D); }
public static void Main(string[] args) { // first we will show how to use the simple drawing functions in graphics 2D { ImageBuffer simpleImage = new ImageBuffer(640, 480, 32, new BlenderBGRA()); Graphics2D simpleImageGraphics2D = simpleImage.NewGraphics2D(); // clear the image to white simpleImageGraphics2D.Clear(Color.White); // draw a circle simpleImageGraphics2D.Circle(50, 50, 30, Color.Blue); // draw a line simpleImageGraphics2D.Line(10, 100, 520, 50, new Color(20, 200, 200)); // draw a filled box simpleImageGraphics2D.FillRectangle(60, 260, 200, 280, Color.Yellow); // and an outline around it simpleImageGraphics2D.Rectangle(60, 260, 200, 280, Color.Magenta); // draw some text simpleImageGraphics2D.DrawString("A Simple Example", 300, 400, 20); // and save this image out ImageTgaIO.Save(simpleImage, "SimpleDrawAndSave.tga"); } // now we will we will show how to use the render function to draw more complex things { ImageBuffer lessSimpleImage = new ImageBuffer(640, 480, 32, new BlenderBGRA()); Graphics2D lessSimpleImageGraphics2D = lessSimpleImage.NewGraphics2D(); // clear the image to white lessSimpleImageGraphics2D.Clear(Color.White); // draw a circle Ellipse ellipseTest = new Ellipse(0, 0, 100, 50); for (double angleDegrees = 0; angleDegrees < 180; angleDegrees += 22.5) { VertexSourceApplyTransform rotatedTransform = new VertexSourceApplyTransform(ellipseTest, Affine.NewRotation(MathHelper.DegreesToRadians(angleDegrees))); VertexSourceApplyTransform rotatedAndTranslatedTransform = new VertexSourceApplyTransform(rotatedTransform, Affine.NewTranslation(lessSimpleImage.Width / 2, 150)); lessSimpleImageGraphics2D.Render(rotatedAndTranslatedTransform, Color.Yellow); Stroke ellipseOutline = new Stroke(rotatedAndTranslatedTransform, 3); lessSimpleImageGraphics2D.Render(ellipseOutline, Color.Blue); } // and a little polygon VertexStorage littlePoly = new VertexStorage(); littlePoly.MoveTo(50, 50); littlePoly.LineTo(150, 50); littlePoly.LineTo(200, 200); littlePoly.LineTo(50, 150); littlePoly.LineTo(50, 50); lessSimpleImageGraphics2D.Render(littlePoly, Color.Cyan); // draw some text TypeFacePrinter textPrinter = new TypeFacePrinter("Printing from a printer", 30, justification: Justification.Center); IVertexSource translatedText = new VertexSourceApplyTransform(textPrinter, Affine.NewTranslation(new Vector2(lessSimpleImage.Width / 2, lessSimpleImage.Height / 4 * 3))); lessSimpleImageGraphics2D.Render(translatedText, Color.Red); Stroke strokedText = new Stroke(translatedText); lessSimpleImageGraphics2D.Render(strokedText, Color.Black); IVertexSource rotatedText = new VertexSourceApplyTransform(textPrinter, Affine.NewRotation(MathHelper.DegreesToRadians(90))); IVertexSource rotatedTranslatedText = new VertexSourceApplyTransform(rotatedText, Affine.NewTranslation(new Vector2(40, lessSimpleImage.Height / 2))); lessSimpleImageGraphics2D.Render(rotatedTranslatedText, Color.Black); // and save this image out ImageTgaIO.Save(lessSimpleImage, "LessSimpleDrawAndSave.tga"); } }
public override void OnDraw(Graphics2D graphics2D) { if(needRedraw) { needRedraw = false; rayTraceScene(); } trackBallTransform.AxisToWorld = trackBallController.GetTransform4X4(); graphics2D.FillRectangle(new rect_d(0, 0, 1000, 1000), RGBA_Bytes.Red); graphics2D.Render(destImage, 0, 0); trackBallController.DrawRadius(graphics2D); graphics2D.DrawString("Ray Trace: " + renderTime.ElapsedMilliseconds.ToString(), 20, 10); base.OnDraw(graphics2D); }
void EditorDraw(Graphics2D pDestFrame) { Vector2 WayPointPos = m_pCurWayPoint.GetPosition(); if (m_pParent != null) { RGBA_Bytes LineColor = new RGBA_Bytes(128, 128, 128); Vector2 ParentPos = m_pParent.m_pCurWayPoint.GetPosition(); // draw a line back to your parent pDestFrame.Line(WayPointPos.x, WayPointPos.y, ParentPos.x, ParentPos.y, LineColor); } // print out the stats for this point int LineSpacing = 12; int LineOffset = -LineSpacing; string Text = ""; Text.FormatWith("G: {0:0.0}", m_AccumulatedCostFromStartG); pDestFrame.DrawString(Text, WayPointPos.x, WayPointPos.y + LineOffset, justification: Justification.Center); LineOffset += LineSpacing; Text.FormatWith("H: {0:0.0}", m_EstimatedCostToDestH); pDestFrame.DrawString(Text, WayPointPos.x, WayPointPos.y + LineOffset, justification: Justification.Center); LineOffset += LineSpacing; Text.FormatWith("F: {0:0.0}", m_TotalCostForThisNodeF); pDestFrame.DrawString(Text, WayPointPos.x, WayPointPos.y + LineOffset, justification: Justification.Center); LineOffset += LineSpacing; }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage); clippingProxy.clear(new RGBA_Floats(1, 1, 1)); m_ras.SetVectorClipBox(0, 0, Width, Height); Affine move = Affine.NewTranslation(10, 10); Perspective shadow_persp = new Perspective(m_shape_bounds.Left, m_shape_bounds.Bottom, m_shape_bounds.Right, m_shape_bounds.Top, m_shadow_ctrl.polygon()); IVertexSource shadow_trans; if (m_FlattenCurves.Checked) { shadow_trans = new VertexSourceApplyTransform(m_shape, shadow_persp); } else { shadow_trans = new VertexSourceApplyTransform(m_path, shadow_persp); // this will make it very smooth after the transform //shadow_trans = new conv_curve(shadow_trans); } // Render shadow m_ras.add_path(shadow_trans); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, new RGBA_Floats(0.2, 0.3, 0).GetAsRGBA_Bytes()); // Calculate the bounding box and extend it by the blur radius RectangleDouble bbox = new RectangleDouble(); bounding_rect.bounding_rect_single(shadow_trans, 0, ref bbox); bbox.Left -= m_radius.Value; bbox.Bottom -= m_radius.Value; bbox.Right += m_radius.Value; bbox.Top += m_radius.Value; if (m_method.SelectedIndex == 1) { // The recursive blur method represents the true Gaussian Blur, // with theoretically infinite kernel. The restricted window size // results in extra influence of edge pixels. It's impossible to // solve correctly, but extending the right and top areas to another // radius value produces fair result. //------------------ bbox.Right += m_radius.Value; bbox.Top += m_radius.Value; } stopwatch.Restart(); if (m_method.SelectedIndex != 2) { // Create a new pixel renderer and attach it to the main one as a child image. // It returns true if the attachment succeeded. It fails if the rectangle // (bbox) is fully clipped. //------------------ #if SourceDepth24 ImageBuffer image2 = new ImageBuffer(new BlenderBGR()); #else ImageBuffer image2 = new ImageBuffer(new BlenderBGRA()); #endif if (image2.Attach(widgetsSubImage, (int)bbox.Left, (int)bbox.Bottom, (int)bbox.Right, (int)bbox.Top)) { // Blur it if (m_method.SelectedIndex == 0) { // More general method, but 30-40% slower. //------------------ //m_stack_blur.blur(pixf2, agg::uround(m_radius.Value)); // Faster, but bore specific. // Works only for 8 bits per channel and only with radii <= 254. //------------------ stack_blur test = new stack_blur(); test.Blur(image2, agg_basics.uround(m_radius.Value), agg_basics.uround(m_radius.Value)); } else { // True Gaussian Blur, 3-5 times slower than Stack Blur, // but still constant time of radius. Very sensitive // to precision, doubles are must here. //------------------ m_recursive_blur.blur(image2, m_radius.Value); } } } else { /* // Blur separate channels //------------------ if(m_channel_r.Checked) { typedef agg::pixfmt_alpha_blend_gray< agg::blender_gray8, agg::rendering_buffer, 3, 2> pixfmt_gray8r; pixfmt_gray8r pixf2r(m_rbuf2); if(pixf2r.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) { agg::stack_blur_gray8(pixf2r, agg::uround(m_radius.Value), agg::uround(m_radius.Value)); } } if(m_channel_g.Checked) { typedef agg::pixfmt_alpha_blend_gray< agg::blender_gray8, agg::rendering_buffer, 3, 1> pixfmt_gray8g; pixfmt_gray8g pixf2g(m_rbuf2); if(pixf2g.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) { agg::stack_blur_gray8(pixf2g, agg::uround(m_radius.Value), agg::uround(m_radius.Value)); } } if(m_channel_b.Checked) { typedef agg::pixfmt_alpha_blend_gray< agg::blender_gray8, agg::rendering_buffer, 3, 0> pixfmt_gray8b; pixfmt_gray8b pixf2b(m_rbuf2); if(pixf2b.attach(pixf, int(bbox.x1), int(bbox.y1), int(bbox.x2), int(bbox.y2))) { agg::stack_blur_gray8(pixf2b, agg::uround(m_radius.Value), agg::uround(m_radius.Value)); } } */ } double tm = stopwatch.ElapsedMilliseconds; // Render the shape itself //------------------ if (m_FlattenCurves.Checked) { m_ras.add_path(m_shape); } else { m_ras.add_path(m_path); } scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, new RGBA_Floats(0.6, 0.9, 0.7, 0.8).GetAsRGBA_Bytes()); graphics2D.DrawString(string.Format("{0:F2} ms", tm), 140, 30); base.OnDraw(graphics2D); }
public void Draw(MatterHackers.Agg.Transform.ITransform Position, Graphics2D renderer) { double TextHeight = m_Position.y - 20; double Range = (m_DataViewMaxY - m_DataViewMinY); VertexSourceApplyTransform TransformedLinesToDraw; Stroke StrockedTransformedLinesToDraw; RoundedRect BackGround = new RoundedRect(m_Position.x, m_Position.y - 1, m_Position.x + m_Width, m_Position.y - 1 + m_Height + 2, 5); VertexSourceApplyTransform TransformedBackGround = new VertexSourceApplyTransform(BackGround, Position); renderer.Render(TransformedBackGround, new RGBA_Bytes(0, 0, 0, .5)); // if the 0 line is within the window than draw it. if (m_DataViewMinY < 0 && m_DataViewMaxY > 0) { m_LinesToDraw.remove_all(); m_LinesToDraw.MoveTo(m_Position.x, m_Position.y + ((0 - m_DataViewMinY) * m_Height / Range)); m_LinesToDraw.LineTo(m_Position.x + m_Width, m_Position.y + ((0 - m_DataViewMinY) * m_Height / Range)); TransformedLinesToDraw = new VertexSourceApplyTransform(m_LinesToDraw, Position); StrockedTransformedLinesToDraw = new Stroke(TransformedLinesToDraw); renderer.Render(StrockedTransformedLinesToDraw, new RGBA_Bytes(0, 0, 0, 1)); } double MaxMax = -999999999; double MinMin = 999999999; double MaxAverage = 0; foreach (KeyValuePair<String, HistoryData> historyKeyValue in m_DataHistoryArray) { HistoryData history = historyKeyValue.Value; m_LinesToDraw.remove_all(); MaxMax = System.Math.Max(MaxMax, history.GetMaxValue()); MinMin = System.Math.Min(MinMin, history.GetMinValue()); MaxAverage = System.Math.Max(MaxAverage, history.GetAverageValue()); for(int i = 0; i < m_Width - 1; i++) { if(i==0) { m_LinesToDraw.MoveTo(m_Position.x + i, m_Position.y + ((history.GetItem(i) - m_DataViewMinY) * m_Height / Range)); } else { m_LinesToDraw.LineTo(m_Position.x + i, m_Position.y + ((history.GetItem(i) - m_DataViewMinY) * m_Height / Range)); } } TransformedLinesToDraw = new VertexSourceApplyTransform(m_LinesToDraw, Position); StrockedTransformedLinesToDraw = new Stroke(TransformedLinesToDraw); renderer.Render(StrockedTransformedLinesToDraw, history.m_Color); String Text = historyKeyValue.Key + ": Min:" + MinMin.ToString("0.0") + " Max:" + MaxMax.ToString("0.0"); renderer.DrawString(Text, m_Position.x, TextHeight - m_Height); TextHeight -= 20; } RoundedRect BackGround2 = new RoundedRect(m_Position.x, m_Position.y - 1, m_Position.x + m_Width, m_Position.y - 1 + m_Height + 2, 5); VertexSourceApplyTransform TransformedBackGround2 = new VertexSourceApplyTransform(BackGround2, Position); Stroke StrockedTransformedBackGround = new Stroke(TransformedBackGround2); renderer.Render(StrockedTransformedBackGround, new RGBA_Bytes(0.0, 0, 0, 1)); //renderer.Color = BoxColor; //renderer.DrawRect(m_Position.x, m_Position.y - 1, m_Width, m_Height + 2); }
public override void OnDraw(Graphics2D graphics2D) { double currentTextHeight = -20; double Range = (valueMax - valueMin); VertexSourceApplyTransform TransformedLinesToDraw; Stroke StrockedTransformedLinesToDraw; Vector2 renderOffset = new Vector2(1, Height - graphHeight - 22); RoundedRect backGround = new RoundedRect(renderOffset.x, renderOffset.y - 1, renderOffset.x + graphWidth, renderOffset.y - 1 + graphHeight + 2, 5); graphics2D.Render(backGround, new RGBA_Bytes(0, 0, 0, .5)); // if the 0 line is within the window than draw it. if (valueMin < 0 && valueMax > 0) { linesToDrawStorage.remove_all(); linesToDrawStorage.MoveTo(renderOffset.x, renderOffset.y + ((0 - valueMin) * graphHeight / Range)); linesToDrawStorage.LineTo(renderOffset.x + graphWidth, renderOffset.y + ((0 - valueMin) * graphHeight / Range)); StrockedTransformedLinesToDraw = new Stroke(linesToDrawStorage); graphics2D.Render(StrockedTransformedLinesToDraw, new RGBA_Bytes(0, 0, 0, 1)); } double MaxMax = -999999999; double MinMin = 999999999; double MaxAverage = 0; foreach (KeyValuePair<String, HistoryData> historyKeyValue in dataHistoryArray) { HistoryData history = historyKeyValue.Value; linesToDrawStorage.remove_all(); MaxMax = System.Math.Max(MaxMax, history.GetMaxValue()); MinMin = System.Math.Min(MinMin, history.GetMinValue()); MaxAverage = System.Math.Max(MaxAverage, history.GetAverageValue()); for (int i = 0; i < graphWidth - 1; i++) { if (i == 0) { linesToDrawStorage.MoveTo(renderOffset.x + i, renderOffset.y + ((history.GetItem(i) - valueMin) * graphHeight / Range)); } else { linesToDrawStorage.LineTo(renderOffset.x + i, renderOffset.y + ((history.GetItem(i) - valueMin) * graphHeight / Range)); } } StrockedTransformedLinesToDraw = new Stroke(linesToDrawStorage); graphics2D.Render(StrockedTransformedLinesToDraw, history.lineColor); String Text = historyKeyValue.Key + ": Min:" + MinMin.ToString("0.0") + " Max:" + MaxMax.ToString("0.0") + " Avg:" + MaxAverage.ToString("0.0"); graphics2D.DrawString(Text, renderOffset.x, renderOffset.y + currentTextHeight, backgroundColor: new RGBA_Bytes(RGBA_Bytes.White, 220), drawFromHintedCach: true); currentTextHeight -= 20; } RoundedRect BackGround2 = new RoundedRect(renderOffset.x, renderOffset.y - 1, renderOffset.x + graphWidth, renderOffset.y - 1 + graphHeight + 2, 5); Stroke StrockedTransformedBackGround = new Stroke(BackGround2); graphics2D.Render(StrockedTransformedBackGround, new RGBA_Bytes(0.0, 0, 0, 1)); //renderer.Color = BoxColor; //renderer.DrawRect(m_Position.x, m_Position.y - 1, m_Width, m_Height + 2); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { Matrix4X4 currentRenderMatrix = trackballTumbleWidget.ModelviewMatrix; if (lastRenderedMatrix != currentRenderMatrix) { Stopwatch traceTime = new Stopwatch(); traceTime.Start(); rayTraceScene(); traceTime.Stop(); timingStrings.Add("Time to trace BVH {0:0.0}s".FormatWith(traceTime.Elapsed.TotalSeconds)); } //allObjectsHolder.AxisToWorld = trackBallController.GetTransform4X4(); graphics2D.FillRectangle(new RectangleDouble(0, 0, 1000, 1000), RGBA_Bytes.Red); graphics2D.Render(destImage, 0, 0); //trackBallController.DrawRadius(graphics2D); totalTime.Stop(); timingStrings.Add("Total Time {0:0.0}s".FormatWith(totalTime.Elapsed.TotalSeconds)); if (!SavedTimes) { SavedTimes = true; File.WriteAllLines("timing.txt", timingStrings.ToArray()); } graphics2D.DrawString("Ray Trace: " + renderTime.ElapsedMilliseconds.ToString(), 20, 10); base.OnDraw(graphics2D); currentRenderMatrix = lastRenderedMatrix; }