コード例 #1
0
        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));
        }
コード例 #2
0
        public static GuiElementDrawCommand makeLines(IList <Line> lines)
        {
            GuiElementDrawCommand created = new GuiElementDrawCommand(EnumType.LINES);

            created.lines = lines;
            return(created);
        }
コード例 #3
0
        public static GuiElementDrawCommand makeClosedLoopGeometry(IList <SpatialVectorDouble> closedLoopGeometry)
        {
            GuiElementDrawCommand created = new GuiElementDrawCommand(EnumType.CLOSEDLOOPGEOMETRY);

            created.closedLoopGeometry = closedLoopGeometry;
            return(created);
        }
コード例 #4
0
        public GuiElementDrawCommand createNewGuiElementDrawCommandAndIncrementId(GuiElementDrawCommand.EnumType type, out ulong id)
        {
            GuiElementDrawCommand created = new GuiElementDrawCommand(type);

            drawCommandsById[idCounter] = created;
            id = idCounter;
            idCounter++;
            return(created);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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)
                        );
                }
            }
        }