public override void Render(Graphics2D graphics2D, Affine transform, double layerScale, RenderType renderType) { if ((renderType & RenderType.Extrusions) == RenderType.Extrusions) { double extrusionLineWidths = 0.2 * layerScale; RGBA_Bytes extrusionColor = RGBA_Bytes.Black; //extrusionColor = color; PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, transform); Stroke stroke = new Stroke(transformedPathStorage, extrusionLineWidths); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); graphics2D.Render(stroke, 0, extrusionColor); } }
public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if ((renderInfo.CurrentRenderType & RenderType.Moves) == RenderType.Moves) { double movementLineWidth = 0.35 * renderInfo.LayerScale; RGBA_Bytes movementColor = new RGBA_Bytes(10, 190, 15); PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, movementLineWidth); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); if (end.x != start.x || end.y != start.y) { pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } else { pathStorage.Add(end.x + .01, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } graphics2D.Render(stroke, 0, movementColor); } }
public override void Render(Graphics2D graphics2D, Affine transform, double layerScale, RenderType renderType) { if ((renderType & RenderType.Moves) == RenderType.Moves) { double movementLineWidth = 0.35 * layerScale; RGBA_Bytes movementColor = new RGBA_Bytes(10, 190, 15); PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, transform); Stroke stroke = new Stroke(transformedPathStorage, movementLineWidth); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); if (end.x != start.x || end.y != start.y) { pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } else { pathStorage.Add(end.x + .01, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } graphics2D.Render(stroke, 0, movementColor); } }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); IImageByte backBuffer = widgetsSubImage; IImageByte destImage = backBuffer; ImageClippingProxy clippingProxy = new ImageClippingProxy(destImage); clippingProxy.clear(new RGBA_Floats(0, 0, 0)); ScanlineRasterizer ras = new ScanlineRasterizer(); scanline_unpacked_8 sl = new scanline_unpacked_8(); scanline_bin sl_bin = new scanline_bin(); rasterizer_compound_aa rasc = new rasterizer_compound_aa(); span_allocator alloc = new span_allocator(); int i; styles_gouraud styles = new styles_gouraud(m_mesh, m_gamma); stopwatch.Restart(); rasc.reset(); //rasc.clip_box(40, 40, width() - 40, height() - 40); for (i = 0; i < m_mesh.num_edges(); i++) { mesh_edge e = m_mesh.edge(i); mesh_point p1 = m_mesh.vertex(e.p1); mesh_point p2 = m_mesh.vertex(e.p2); rasc.styles(e.tl, e.tr); rasc.move_to_d(p1.x, p1.y); rasc.line_to_d(p2.x, p2.y); } ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderCompound(rasc, sl, sl_bin, clippingProxy, alloc, styles); double tm = stopwatch.ElapsedMilliseconds; gsv_text t = new gsv_text(); t.SetFontSize(10.0); Stroke pt = new Stroke(t); pt.width(1.5); pt.line_cap(LineCap.Round); pt.line_join(LineJoin.Round); string buf = string.Format("{0:F2} ms, {1} triangles, {2:F0} tri/sec", tm, m_mesh.num_triangles(), m_mesh.num_triangles() / tm * 1000.0); t.start_point(10.0, 10.0); t.text(buf); ras.add_path(pt); scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(255, 255, 255)); if (m_gamma.GetGamma() != 1.0) { ((ImageBuffer)destImage).apply_gamma_inv(m_gamma); } base.OnDraw(graphics2D); }
public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if (renderInfo.CurrentRenderType.HasFlag(RenderType.Extrusions)) { double extrusionLineWidths = GetExtrusionWidth(renderInfo.CurrentRenderType) * 2 * renderInfo.LayerScale; RGBA_Bytes extrusionColor = RGBA_Bytes.Black; if (extruderIndex > 0) { extrusionColor = MeshViewerWidget.GetMaterialColor(extruderIndex + 1); } if (renderInfo.CurrentRenderType.HasFlag(RenderType.SpeedColors)) { extrusionColor = color; } if (renderInfo.CurrentRenderType.HasFlag(RenderType.TransparentExtrusion)) { extrusionColor = new RGBA_Bytes(extrusionColor, 200); } // render the part using opengl Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL; if (graphics2DGl != null) { Vector3Float startF = this.GetStart(renderInfo); Vector3Float endF = this.GetEnd(renderInfo); Vector2 start = new Vector2(startF.x, startF.y); renderInfo.Transform.transform(ref start); Vector2 end = new Vector2(endF.x, endF.y); renderInfo.Transform.transform(ref end); graphics2DGl.DrawAALineRounded(start, end, extrusionLineWidths/2, extrusionColor); } else { PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, extrusionLineWidths/2); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); graphics2D.Render(stroke, 0, extrusionColor); } } }
public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if ((renderInfo.CurrentRenderType & RenderType.Extrusions) == RenderType.Extrusions) { double extrusionLineWidths = GetRadius(renderInfo.CurrentRenderType) * 2 * renderInfo.LayerScale; RGBA_Bytes extrusionColor = RGBA_Bytes.Black; if (extruderIndex > 0) { extrusionColor = MeshViewerWidget.GetMaterialColor(extruderIndex + 1); } if ((renderInfo.CurrentRenderType & RenderType.SpeedColors) == RenderType.SpeedColors) { extrusionColor = color; } PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, extrusionLineWidths); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); graphics2D.Render(stroke, 0, extrusionColor); } }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); int width = (int)widgetsSubImage.Width; int height = (int)widgetsSubImage.Height; ImageBuffer clippedSubImage = new ImageBuffer(); clippedSubImage.Attach(widgetsSubImage, new BlenderBGRA()); ImageClippingProxy imageClippingProxy = new ImageClippingProxy(clippedSubImage); imageClippingProxy.clear(new RGBA_Floats(1, 1, 1)); 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); if (renderAsScanlineCheckBox.Checked) { rasterizer.SetVectorClipBox(0, 0, width, height); Stroke stroke = new Stroke(lionShape.Path); stroke.width(widthSlider.Value); stroke.line_join(LineJoin.Round); VertexSourceApplyTransform trans = new VertexSourceApplyTransform(stroke, transform); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolidAllPaths(imageClippingProxy, rasterizer, scanlineCache, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths); } else { double w = widthSlider.Value * transform.GetScale(); LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(w, new gamma_none()); OutlineRenderer outlineRenderer = new OutlineRenderer(imageClippingProxy, lineProfile); rasterizer_outline_aa rasterizer = new rasterizer_outline_aa(outlineRenderer); rasterizer.line_join(renderAccurateJoinsCheckBox.Checked ? rasterizer_outline_aa.outline_aa_join_e.outline_miter_accurate_join : rasterizer_outline_aa.outline_aa_join_e.outline_round_join); rasterizer.round_cap(true); VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform); rasterizer.RenderAllPaths(trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths); } base.OnDraw(graphics2D); }
public override void Render(Graphics2D graphics2D, GCodeRenderInfo renderInfo) { if ((renderInfo.CurrentRenderType & RenderType.Moves) == RenderType.Moves) { double movementLineWidth = 0.35 * renderInfo.LayerScale; RGBA_Bytes movementColor = new RGBA_Bytes(10, 190, 15); // render the part using opengl Graphics2DOpenGL graphics2DGl = graphics2D as Graphics2DOpenGL; if (graphics2DGl != null) { Vector3Float startF = this.GetStart(renderInfo); Vector3Float endF = this.GetEnd(renderInfo); Vector2 start = new Vector2(startF.x, startF.y); renderInfo.Transform.transform(ref start); Vector2 end = new Vector2(endF.x, endF.y); renderInfo.Transform.transform(ref end); graphics2DGl.DrawAALineRounded(start, end, movementLineWidth, movementColor); } else { PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, renderInfo.Transform); Stroke stroke = new Stroke(transformedPathStorage, movementLineWidth); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); Vector3Float start = this.GetStart(renderInfo); Vector3Float end = this.GetEnd(renderInfo); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); if (end.x != start.x || end.y != start.y) { pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } else { pathStorage.Add(end.x + .01, end.y, ShapePath.FlagsAndCommand.CommandLineTo); } graphics2D.Render(stroke, 0, movementColor); } } }