Ejemplo n.º 1
0
        protected void drawConsoleText(string text, int width, Font font, Vector2 position, SolidColorData foreground, SolidColorData background)
        {
            getCurrentTransform(out Matrix3x2 tform, out float pixel);
            IntMatrix?intMtx;
            CPoint    startingPoint = transformToPhysicalPixels(position, out intMtx);

            if (!intMtx.HasValue)
            {
                throw new ApplicationException("iDrawContext.drawConsoleText doesn't currently support transforms");
            }

            eTextRendering trs = textRenderingStyle(intMtx);

            CRect rect = new CRect(startingPoint, new CSize());

            Order o = drawMeshes.addText(ref currentZ, text, font, ref rect, foreground.paletteIndex, trs, width);

            bool opaqueBackground = background.brushType == eBrushType.Opaque;

            passFlags |= eRenderPassFlags.Transparent;

            calls.add(sDrawCall.drawText(o, ref tform, foreground.paletteIndex,
                                         background.paletteIndex, opaqueBackground,
                                         pixel, trs));
        }
Ejemplo n.º 2
0
        protected void drawText(string text, Font font, ref Rect rectangle, SolidColorData foreground, SolidColorData background)
        {
            getCurrentTransform(out Matrix3x2 tform, out float pixel);
            var transformedRect = tform.transformRectangle(ref rectangle);

            if (!DrawDevice.clipSpaceRectangle.intersects(ref transformedRect) || foreground.brushType == eBrushType.Null)
            {
                return;
            }

            flushIfNeeded(1);

            IntMatrix?     intMtx;
            CPoint         startingPoint = transformToPhysicalPixels(rectangle.topLeft, out intMtx);
            CSize          size          = (rectangle.size / pixel).roundToInt().asSize;
            CRect          textRect      = new CRect(startingPoint, size);
            eTextRendering trs           = textRenderingStyle(intMtx);

            Order o = drawMeshes.addText(ref currentZ, text, font, ref textRect, foreground.paletteIndex, trs);

            bool opaqueBackground = background.brushType == eBrushType.Opaque;

            passFlags |= eRenderPassFlags.Transparent;
            calls.add(sDrawCall.drawText(o, ref tform, foreground.paletteIndex,
                                         background.paletteIndex, opaqueBackground,
                                         pixel, trs));
        }
Ejemplo n.º 3
0
        CSize iDrawContext.measureText(string text, float width, iFont fontInterface)
        {
            Matrix3x2 curr        = transform.current;
            float     pixel       = computePixelSize(ref curr);
            int       widthPIxels = (int)MathF.Round(width / pixel);

            Matrix3x2      tform      = transform.current;
            eTextRendering renderMode = textRenderingStyle(tform.snapMatrixToInt());

            var font = (Font)fontInterface;

            return(font.measureText(text, widthPIxels, renderMode));
        }
Ejemplo n.º 4
0
        public static sDrawCall drawText(Order order, ref Matrix3x2 trans, int color, int backgroundColor, bool opaqueBackground, float physicalPixelSize, eTextRendering textRendering)
        {
            eMesh  mesh  = (textRendering == eTextRendering.GrayscaleTransformed) ? eMesh.TransformedText : eMesh.GlyphRun;
            eBrush brush = opaqueBackground ? eBrush.OpaqueColor : eBrush.SolidColor;

            eClearTypeKind clearTypeKind;

            if (textRendering == eTextRendering.ClearTypeHorizontal)
            {
                clearTypeKind = eClearTypeKind.Straight;
            }
            else
            {
                clearTypeKind = eClearTypeKind.None;
            }
            DrawCallType dc = new DrawCallType(brush, mesh, clearTypeKind);

            return(new sDrawCall(dc, ref trans, physicalPixelSize, color, backgroundColor, MiscUtils.one, order));
        }
Ejemplo n.º 5
0
 public sMeshDataSize renderBlock(Span <sVertexWithId> span, uint id, ReadOnlySpan <char> str, ref CRect rect, eTextRendering how)
 {
     if (str.IsEmpty)
     {
         return(new sMeshDataSize());
     }
     ref var resourses = ref getResources(how);
Ejemplo n.º 6
0
        public Order addText(ref int z, string text, Font font, ref CRect rect, int solidColor, eTextRendering textRendering, int?consoleWidth = null)
        {
            Order result = new Order(-1 - textCommands.length, z);

            z++;

            var cmd = new sDrawTextCommand();

            cmd.rectangle     = rect;
            cmd.foreground    = solidColor;
            cmd.font          = font;
            cmd.text          = text;
            cmd.textRendering = textRendering;
            cmd.meshDataSize  = font.prepareGlyphs(text, textRendering);
            cmd.consoleWidth  = consoleWidth;
            textCommands.add(ref cmd);
            return(result);
        }
Ejemplo n.º 7
0
 public sMeshDataSize renderConsole(Span <sVertexWithId> span, uint id, ReadOnlySpan <char> str, CPoint where, eTextRendering how, int width = 80)
 {
     if (str.IsEmpty)
     {
         return(new sMeshDataSize());
     }
     ref var resourses = ref getResources(how);
Ejemplo n.º 8
0
 public static bool isGrayscale(this eTextRendering textRendering)
 {
     return((byte)textRendering < (byte)eTextRendering.ClearTypeHorizontal);
 }