public GuiElementDrawCommandHandle createDrawText(string text, SpatialVectorDouble signScale, Color color) { ulong id; GuiElementDrawCommand guiElementDrawCommand = guiElementDrawCommands.createNewGuiElementDrawCommandAndIncrementId(GuiElementDrawCommand.EnumType.LINES, out id); // create lineCommandInterpreter which fills the lines into the GuiElementDrawCommand // lineRendererDriver which receives Hershey commands and translates it into line commands // hersheyInterpreter which interprets hershey commands of the signs var lineCommandInterpreter = new SoftwareGuiTextRendererLineCommandInterpreter(); LineRendererDriver lineRendererDriver = new LineRendererDriver(lineCommandInterpreter); // OPTIMIZATION EXTREMELY LOW< we could cache this object > HersheyTextRenderer textRenderer = new HersheyTextRenderer(); textRenderer.lineRendererDriver = lineRendererDriver; lineCommandInterpreter.reset(); lineRendererDriver.scale = signScale; textRenderer.loadHersheyCommands(@"D:\win10host\files\github\WhiteSphereEngine\resources\engine\graphics\font\hershey"); textRenderer.renderString(text, signScale, new SpatialVectorDouble(new double[] { 0, 0 })); guiElementDrawCommand.lines = lineCommandInterpreter.lines; // transfer the line command return(new GuiElementDrawCommandHandle(id)); }
public static GuiElementDrawCommand makeLines(IList <Line> lines) { GuiElementDrawCommand created = new GuiElementDrawCommand(EnumType.LINES); created.lines = lines; return(created); }
public static GuiElementDrawCommand makeClosedLoopGeometry(IList <SpatialVectorDouble> closedLoopGeometry) { GuiElementDrawCommand created = new GuiElementDrawCommand(EnumType.CLOSEDLOOPGEOMETRY); created.closedLoopGeometry = closedLoopGeometry; return(created); }
public GuiElementDrawCommand createNewGuiElementDrawCommandAndIncrementId(GuiElementDrawCommand.EnumType type, out ulong id) { GuiElementDrawCommand created = new GuiElementDrawCommand(type); drawCommandsById[idCounter] = created; id = idCounter; idCounter++; return(created); }
public GuiElementDrawCommandHandle createFillClosedLines(ClosedLoop outline, Color color, float Transparency, uint StartIndex) { ulong id; GuiElementDrawCommand guiElementDrawCommand = guiElementDrawCommands.createNewGuiElementDrawCommandAndIncrementId(GuiElementDrawCommand.EnumType.CLOSEDLOOPGEOMETRY, out id); guiElementDrawCommand.closedLoopGeometry = outline.points; return(new GuiElementDrawCommandHandle(id)); }
public void draw(GuiElementDrawCommandHandle handle, SpatialVectorDouble position) { if (graphics == null) { return; } if (handle.id == 0xdeadf00d) // pseudo special handle to ignore rendering { return; } GuiElementDrawCommand drawCommand = guiElementDrawCommands.drawCommandsById[handle.id]; if (drawCommand.type == GuiElementDrawCommand.EnumType.CLOSEDLOOPGEOMETRY) { Point[] points = new Point[drawCommand.closedLoopGeometry.Count + 1]; for (int i = 0; i < drawCommand.closedLoopGeometry.Count; i++) { // TODO< pull size of screen from context > points[i] = new Point((int)((drawCommand.closedLoopGeometry[i].x + position.x) * 150.0f), (int)((drawCommand.closedLoopGeometry[i].y + position.y) * 150.0f)); } points[points.Length - 1] = new Point((int)((drawCommand.closedLoopGeometry[0].x + position.x) * 150.0f), (int)((drawCommand.closedLoopGeometry[0].y + position.y) * 150.0f)); graphics.DrawLines(new Pen(Brushes.Black), points); } else if (drawCommand.type == GuiElementDrawCommand.EnumType.LINES) { foreach (var iLine in drawCommand.lines) { graphics.DrawLine( new Pen(Brushes.Black), (int)((iLine.a.x + position.x) * 150.0f), (int)((iLine.a.y + position.y) * 150.0f), (int)((iLine.b.x + position.x) * 150.0f), (int)((iLine.b.y + position.y) * 150.0f) ); } } }