Example #1
0
            protected override void OnPaint(Alt.GUI.PaintEventArgs e)
            {
                Debug.Log("onpaint");
                Alt.Sketch.Graphics graphics = e.Graphics;
                if (!DoubleBuffered)
                {
                    graphics.FillRectangle(Alt.Sketch.Color.FromArgb((graphics is SoftwareGraphics) ? 128 : 192, Alt.Sketch.Color.DodgerBlue), ClientRectangle);
                }
                else
                {
                    graphics.Clear(Alt.Sketch.Color.FromArgb((graphics is SoftwareGraphics) ? 128 : 192, Alt.Sketch.Color.DodgerBlue));
                }

                int w = ClientWidth;
                int h = ClientHeight;

                m_Scale   = viewZoom * System.Math.Min(w, h) / 23;
                m_CenterX = w / 2 + m_OffsetX;
                m_CenterY = h * 0.83 + m_OffsetY;
                m_DebugDraw.SetViewTransform(m_CenterX, m_CenterY, m_Scale);


                //Paint
                base.OnPaint(e);
            }
Example #2
0
    void PrintComment(Alt.Sketch.Graphics graphics, QFont font, string comment, QFontAlignment alignment, ref double yOffset)
    {
        GraphicsState state = graphics.Save();

        yOffset += 20;
        graphics.TranslateTransform(30, yOffset);

        font.Print(comment, ClientWidth - 60, alignment);

        yOffset += font.Measure(comment, ClientWidth - 60, alignment).Height;

        graphics.Restore(state);
    }
Example #3
0
    void PrintCode(Alt.Sketch.Graphics graphics, string code, ref double yOffset)
    {
        GraphicsState state = graphics.Save();

        yOffset += 20;
        graphics.TranslateTransform(50f, yOffset);

        codeText.Print(code, ClientWidth - 50, QFontAlignment.Left);

        yOffset += codeText.Measure(code, ClientWidth - 50, QFontAlignment.Left).Height;

        graphics.Restore(state);
    }
Example #4
0
    void PrintWithBounds(Alt.Sketch.Graphics graphics, QFont font, string text, Alt.Sketch.Rect bounds, QFontAlignment alignment, ref double yOffset)
    {
        double maxWidth = bounds.Width;

        double height = font.Measure(text, maxWidth, alignment).Height;

        bounds.Height = height;
        graphics.DrawRectangle(m_LinesPen, bounds - new Point(1, 0) + new Size(0, 1));

        font.Print(text, maxWidth, alignment, new Alt.Sketch.Vector2(bounds.X, bounds.Y));

        yOffset += height;
    }
            protected override void OnPaint(GUI.PaintEventArgs e)
            {
                Alt.Sketch.Graphics graphics = e.Graphics;
                if (!DoubleBuffered)
                {
                    graphics.FillRectangle(Alt.Sketch.Color.FromArgb((graphics is SoftwareGraphics) ? 128 : 192, Alt.Sketch.Color.DodgerBlue), ClientRectangle);
                }
                else
                {
                    graphics.Clear(Alt.Sketch.Color.FromArgb((graphics is SoftwareGraphics) ? 128 : 192, Alt.Sketch.Color.DodgerBlue));
                }


                //Paint
                base.OnPaint(e);
            }
Example #6
0
    void PrintCommentWithLine(Alt.Sketch.Graphics graphics, QFont font, string comment, QFontAlignment alignment, double xOffset, ref double yOffset)
    {
        GraphicsState state = graphics.Save();

        yOffset += 20;
        graphics.TranslateTransform((int)xOffset, yOffset);

        font.Print(comment, alignment);

        Size bounds = font.Measure(comment, ClientWidth - 60, alignment);

        graphics.DrawLine(m_LinesPen, 0, 0, 0, bounds.Height + 20);

        yOffset += bounds.Height;

        graphics.Restore(state);
    }
Example #7
0
    protected void Box2D_onPaint(Alt.GUI.PaintEventArgs e)
    {
        if (m_Test == null)
        {
            return;
        }

        Alt.Sketch.Graphics graphics = e.Graphics;

        graphics.SmoothingMode = SmoothingMode.AntiAlias;


        m_Test.SetTextLine(30);
        settings.hz = TPS;        // settingsHz;

        m_Test.Step(settings);

        m_Test.DrawTitle(50, 15, "Dominos");
    }
Example #8
0
    protected void FarseerPhysics_onPaint(Alt.GUI.PaintEventArgs e)
    {
        if (m_Test == null)
        {
            return;
        }

        Alt.Sketch.Graphics graphics = e.Graphics;

        graphics.SmoothingMode = SmoothingMode.AntiAlias;


        m_Test.DebugView.m_Graphics = graphics;
        m_Test.DebugView.m_Font     = m_InfoFont;


        Alt.Sketch.Size clientSize   = ClientSize;
        double          ClientWidth  = clientSize.Width;
        double          ClientHeight = clientSize.Height;

        m_Test.m_Scale   = viewZoom * System.Math.Min(ClientWidth, ClientHeight) / 39;
        m_Test.m_CenterX = ClientWidth / 2 + m_Test.m_OffsetX * m_Test.m_Scale;
        m_Test.m_CenterY = ClientHeight / 2 + m_Test.m_OffsetY * m_Test.m_Scale;


        m_TPSCounter.Tick();

        settings.Hz = m_TPSCounter.TPS;

        m_Test.TextLine = 30;
        m_Test.Update(settings);


        m_Test.m_CenterX = ClientWidth / 2 + m_Test.m_OffsetX * m_Test.m_Scale;
        m_Test.m_CenterY = ClientHeight * 3 / 5 + m_Test.m_OffsetY * m_Test.m_Scale;
        m_Test.DebugView.SetViewTransform(m_Test.m_CenterX, m_Test.m_CenterY, m_Test.m_Scale);


        m_Test.DrawTitle(30, 15, "Car");

        m_Test.DebugView.RenderDebugData();
    }
        protected override void OnPaint(Alt.GUI.PaintEventArgs e)
        {
            base.OnPaint(e);


            Alt.Sketch.Graphics graphics = e.Graphics;


            Matrix matrix = graphics.Transform;

            {
                //  correct offset
                Alt.Sketch.Rect clientRectangle = ClientRectangle;
                Alt.Sketch.Rect rect            = clientRectangle;
                double          targetX         = (m_TargetX - (clientRectangle.Width / 2)) * clientRectangle.Width / rect.Width + clientRectangle.Width / 2;
                double          targetY         = (m_TargetY - (clientRectangle.Height / 2)) * clientRectangle.Height / rect.Height + clientRectangle.Height / 2;
                graphics.TranslateTransform(targetX, targetY);

                graphics.RotateTransform(angle);

                int radialStep = 30;
                int nSteps     = 5;
                int lineDXY    = radialStep * (nSteps + 1);

                graphics.FillCircle(m_TargetBrush, 0, 0, radialStep * nSteps);

                graphics.SmoothingMode = SmoothingMode.AntiAlias;

                graphics.DrawLine(m_TargetPen, 0, -lineDXY, 0, lineDXY);
                graphics.DrawLine(m_TargetPen, -lineDXY, 0, lineDXY, 0);

                for (int i = 1; i <= nSteps; i++)
                {
                    graphics.DrawCircle(m_TargetPen, 0, 0, radialStep * i);
                }
            }
            graphics.Transform = matrix;
        }
Example #10
0
    protected void Paint_onPaint(Alt.GUI.PaintEventArgs e)
    {
#if UNITY_5 && USE_ExtBrush
        if (e.Graphics is SoftwareGraphics)
        {
            return;
        }

        Alt.Sketch.Color colorMultiplier;
#endif

        int opacity = 128;

        if (m_MaterialBrush1 == null)
        {
#if UNITY_5 && USE_ExtBrush
            Bitmap image = Bitmap.FromFile("AltData/About.gif");

            ExtBrush brush;
            brush = new ExtBrush(); brush.MaterialName = "Material1"; brush.SetExtParameter("Image", image); m_MaterialBrush1 = brush;
            brush = new ExtBrush(); brush.MaterialName = "Material2"; brush.SetExtParameter("Image", image); m_MaterialBrush2 = brush;
            brush = new ExtBrush(); brush.MaterialName = "Material3"; brush.SetExtParameter("Image", image); m_MaterialBrush3 = brush;
            brush = new ExtBrush(); brush.MaterialName = "Material4"; brush.SetExtParameter("Image", image); m_MaterialBrush4 = brush;
#else
            SolidColorBrush brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.Red)); m_MaterialBrush1 = brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.Green)); m_MaterialBrush2 = brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.DodgerBlue)); m_MaterialBrush3 = brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.Yellow)); m_MaterialBrush4 = brush;
#endif
        }


        Brush currentBrush;

        switch (m_CurrentBrush)
        {
        case 0:
            currentBrush = m_MaterialBrush1;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.LightCoral;
#endif
            break;

        case 1:
            currentBrush = m_MaterialBrush2;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.Green;
#endif
            break;

        case 2:
            currentBrush = m_MaterialBrush3;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.Red;
#endif
            break;

        case 3:
            currentBrush = m_MaterialBrush4;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.Cyan;
#endif
            break;

        default:
            return;
        }

        Alt.Sketch.Graphics graphics = e.Graphics;
        graphics.SmoothingMode = SmoothingMode.None;

        Alt.Sketch.Rect rect = e.ClipRectangle;
        rect.Deflate(50 + offset, 50 + offset);

        graphics.FillRoundedRectangle(currentBrush, rect, 20
#if UNITY_5 && USE_ExtBrush
                                      , colorMultiplier
#else
                                      , UseHardwareRender ? Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.White) : Alt.Sketch.Color.White
#endif
                                      );

        graphics.SmoothingMode = SmoothingMode.AntiAlias;
        graphics.DrawRoundedRectangle(m_ContourPen, rect, 20);
    }
Example #11
0
        internal bool DoRenderIfNeed(Camera camera, Renderer renderer)
        {
            SizeI size;

            if (!NeedsUpdate ||
                Unity_RenderManager.Instance == null ||
                (size = Size).IsEmpty)
            {
                return(false);
            }


            NeedsUpdate = false;

            m_LastRenderTime = Alt.IntervalTimer.Ticks;

            m_FPSCounter.Tick();


            if (RenderType == Alt.Sketch.Rendering.RenderType.Software)
            {
                if (!(m_Texture is Texture2D))
                {
                    KillTextures();
                }

                if (m_Texture != null &&
                    (m_Texture.width != size.Width ||
                     m_Texture.height != size.Height))
                {
                    m_Texture = null;
                }

                if (m_Texture == null)
                {
                    m_Texture = new Texture2D(
                        size.Width, size.Height,
                        Unity_RenderManager.ToTextureFormat(PixelFormat.Format32bppArgb),
                        false);
                    m_Texture.filterMode = FilterMode.Point;

                    RefreshMaterial();
                }

                Bitmap backBuffer            = SoftwareBackBuffer;
                Alt.Sketch.Graphics graphics = Alt.Sketch.Graphics.FromImage(backBuffer);

                //graphics.Clear(Alt.Sketch.Color.FromArgb(0, 128, 128, 128));
                graphics.Clear(Alt.Sketch.Color.FromArgb(0, 0, 0, 0));

                DoPaintInternal(new Alt.GUI.PaintEventArgs(graphics, new Alt.Sketch.Rect(0, 0, size)));

                Unity_RenderManager.SetTextureData(m_Texture as Texture2D, backBuffer, backBuffer.PixelRectangle, true);
            }
            else
            {
                if (m_RenderTexture != null &&
                    (m_RenderTexture.width != size.Width ||
                     m_RenderTexture.height != size.Height))
                {
                    KillTextures();
                }

                if (m_RenderTexture == null)
                {
                    m_RenderTexture = new RenderTexture(
                        size.Width, size.Height,
                        0,
                        Unity_RenderManager.ToRenderTextureFormat(PixelFormat.Format32bppArgb));
                    m_RenderTexture.filterMode = FilterMode.Point;

                    m_Texture = m_RenderTexture;

                    RefreshMaterial();
                }

                if (m_RenderTexture != null)
                {
                    RenderTexture oldRenderTexture = RenderTexture.active;
                    RenderTexture.active = m_RenderTexture;
                    try
                    {
                        GL.Clear(true, true, Unity_RenderManager.ToColor(Alt.Sketch.Color.Empty));

                        if (m_Renderer == null)
                        {
                            m_Renderer = new Unity_Renderer(Unity_RenderManager.Instance);
                            m_Renderer.DefaultSmoothingMode = Alt.Sketch.SmoothingMode.None;
                        }

                        m_Renderer.BeginRender(camera, renderer, size.Width, size.Height, true);
                        {
                            Alt.Sketch.Graphics graphics = Alt.Sketch.Graphics.FromRenderer(m_Renderer);
                            if (graphics != null)
                            {
                                DoPaintInternal(new Alt.GUI.PaintEventArgs(graphics, new Alt.Sketch.Rect(0, 0, size)));
                            }
                        }
                        m_Renderer.EndRender();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                    finally
                    {
                        RenderTexture.active = oldRenderTexture;
                    }
                }
            }

            return(true);
        }
Example #12
0
    protected void QuickFont_onPaint(Alt.GUI.PaintEventArgs e)
    {
        Alt.Sketch.Graphics graphics = e.Graphics;
        GraphicsState       state;

        switch (currentDemoPage)
        {
        case 1:
        {
            double yOffset = 0;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(ClientWidth * 0.5f, yOffset + 10);
            heading1.Print("AltGUI QuickFont", QFontAlignment.Centre);
            yOffset += heading1.Measure("QuickFont").Height;
            graphics.Restore(state);


            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Introduction", QFontAlignment.Left);
            yOffset += heading2.Measure("Introduction").Height;
            graphics.Restore(state);


            state = graphics.Save();
            graphics.TranslateTransform(30f, yOffset + 20);
            mainText.Print(introduction, ClientWidth - 60, QFontAlignment.Justify);
            graphics.Restore(state);

            QFont.End();
        }
        break;

        case 2:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Easy as ABC!", QFontAlignment.Left);
            yOffset += heading2.Measure("Easy as ABC!").Height;
            graphics.Restore(state);


            PrintComment(graphics, usingQuickFontIsSuperEasy, ref yOffset);
            PrintCode(graphics, loadingAFont1, ref yOffset);

            PrintComment(graphics, andPrintWithIt, ref yOffset);
            PrintCode(graphics, printWithFont1, ref yOffset);

            PrintComment(graphics, itIsAlsoEasyToMeasure, ref yOffset);
            PrintCode(graphics, measureText1, ref yOffset);

            PrintComment(graphics, oneOfTheFirstGotchas, ref yOffset);
            PrintCode(graphics, loadingAFont2, ref yOffset);

            QFont.End();
        }
        break;

        case 3:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Alignment", QFontAlignment.Left);
            yOffset += heading2.Measure("Easy as ABC!").Height;
            graphics.Restore(state);

            PrintCommentWithLine(graphics, whenPrintingText, QFontAlignment.Left, ClientWidth * 0.5f, ref yOffset);
            PrintCode(graphics, printWithFont2, ref yOffset);


            PrintCommentWithLine(graphics, righAlignedText, QFontAlignment.Right, ClientWidth * 0.5f, ref yOffset);
            yOffset += 10f;

            PrintCommentWithLine(graphics, centredTextAsYou, QFontAlignment.Centre, ClientWidth * 0.5f, ref yOffset);

            QFont.End();
        }
        break;

        case 4:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Bounds and Justify", QFontAlignment.Left);
            yOffset += heading2.Measure("Easy as ABC!").Height;
            graphics.Restore(state);

            state    = graphics.Save();
            yOffset += 20;
            graphics.TranslateTransform((int)(ClientWidth * 0.5), yOffset);
            controlsText.Options.Colour = Alt.Sketch.Color.Yellow;
            controlsText.Print("Press [Up], [Down] or [Enter]!", QFontAlignment.Centre);
            yOffset += controlsText.Measure("[]").Height;
            graphics.Restore(state);

            double boundShrink = (int)(350 * (1 - Math.Cos(boundsAnimationCnt * Math.PI * 2)));

            yOffset += 15;
            PrintWithBounds(graphics, mainText, ofCourseItsNot, new Alt.Sketch.Rect(30f + boundShrink * 0.5f, yOffset, ClientWidth - 60 - boundShrink, 350f), cycleAlignment, ref yOffset);

            string printWithBounds = "myFont.Print(text, 400f, QFontAlignment." + cycleAlignment + ");";
            yOffset += 15f;
            PrintCode(graphics, printWithBounds, ref yOffset);

            QFont.End();
        }
        break;

        case 5:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            PrintComment(graphics, anotherCoolFeature, ref yOffset);
            PrintCode(graphics, textureFontCode1, ref yOffset);
            PrintComment(graphics, thisWillHaveCreated, ref yOffset);

            QFont.End();
        }
        break;

        case 6:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            PrintComment(graphics, ifYouDoIntend, ref yOffset);
            PrintCode(graphics, textureFontCode2, ref yOffset);
            PrintComment(graphics, actuallyTexturing, ref yOffset);
            PrintCode(graphics, textureFontCode3, ref yOffset);

            QFont.End();
        }
        break;

        case 7:
        {
            double yOffset = 20;

            QFont.Begin();

            heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Drop Shadows", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.16f, 0.16f);             //back to default

            mainText.Options.DropShadowActive  = true;
            mainText.Options.DropShadowOpacity = 0.7f;
            mainText.Options.DropShadowOffset  = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

            PrintComment(graphics, asIhaveleant, ref yOffset);
            PrintCode(graphics, dropShadowCode1, ref yOffset);
            PrintComment(graphics, thisWorksFine, ref yOffset);
            PrintCode(graphics, dropShadowCode2, ref yOffset);
            PrintComment(graphics, onceAFont, ref yOffset);

            mainText.Options.DropShadowActive = false;

            QFont.End();
        }
        break;

        case 8:
        {
            double yOffset = 20;

            QFont.Begin();

            monoSpaced.Options.CharacterSpacing = 0.05f;

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Monospaced Fonts", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);


            PrintComment(graphics, monoSpaced, hereIsSomeMono, QFontAlignment.Left, ref yOffset);
            PrintCode(graphics, monoCode1, ref yOffset);
            PrintComment(graphics, monoSpaced, theDefaultMono, QFontAlignment.Left, ref yOffset);

            PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Left, ClientWidth * 0.5f, ref yOffset);
            yOffset += 2f;
            PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Right, ClientWidth * 0.5f, ref yOffset);
            yOffset += 2f;
            PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Centre, ClientWidth * 0.5f, ref yOffset);
            yOffset += 2f;

            monoSpaced.Options.CharacterSpacing = 0.5f;
            PrintComment(graphics, monoSpaced, "As usual, you can adjust character spacing with myFont.Options.CharacterSpacing.", QFontAlignment.Left, ref yOffset);

            QFont.End();
        }
        break;

        case 9:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("In Conclusion", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            PrintComment(graphics, thereAreActually, ref yOffset);

            QFont.End();
        }
        break;
        }


        QFont.Begin();

        Alt.Sketch.Color pressColor = new ColorR(0.8, 0.2, 0.2);        // new ColorR(0.8, 0.1, 0.1);

        if (currentDemoPage != lastPage)
        {
            state = graphics.Save();
            graphics.TranslateTransform(ClientWidth - 15 - 16 * (float)(1 + Math.Sin(cnt * 4)), ClientHeight - controlsText.Measure("P").Height - 17);
            controlsText.Options.Colour = pressColor;
            controlsText.Print("Press [Right] ->", QFontAlignment.Right);
            graphics.Restore(state);
        }

        if (currentDemoPage != 1)
        {
            state = graphics.Save();
            graphics.TranslateTransform(15 + 16 * (float)(1 + Math.Sin(cnt * 4)), ClientHeight - controlsText.Measure("P").Height - 17);
            controlsText.Options.Colour = pressColor;
            controlsText.Print("<- Press [Left]", QFontAlignment.Left);
            graphics.Restore(state);
        }

        QFont.End();
    }
Example #13
0
 void PrintCommentWithLine(Alt.Sketch.Graphics graphics, string comment, QFontAlignment alignment, double xOffset, ref double yOffset)
 {
     PrintCommentWithLine(graphics, mainText, comment, alignment, xOffset, ref yOffset);
 }
Example #14
0
    //some helpers


    void PrintComment(Alt.Sketch.Graphics graphics, string comment, ref double yOffset)
    {
        PrintComment(graphics, mainText, comment, QFontAlignment.Justify, ref yOffset);
    }
Example #15
0
        /*
         * Render the given  string using the given font.   Transfer the image
         * to a  surface of  power-of-2 size large  enough to fit  the string.
         * Return an OpenGL texture object.
         */
        //  Image
        public static int make_image_from_font(
            ref int w, ref int h,
            string text, Alt.Sketch.Font font)
        {
            int o = 0;

            /* Render the text. */

            if (!string.IsNullOrEmpty(text))
            {
                Alt.Sketch.SizeI size = gui.gui_measure(text, font);

                Alt.Sketch.Bitmap bitmap = new Alt.Sketch.Bitmap(size, Alt.Sketch.PixelFormat.Format32bppArgb);
                using (Alt.Sketch.Graphics graphics = Alt.Sketch.Graphics.FromImage(bitmap))
                {
                    graphics.Clear(Alt.Sketch.Color.Empty);
                    graphics.DrawString(text, font, Alt.Sketch.Brushes.White, Alt.Sketch.Point.Zero);
                }
                {
                    w = bitmap.PixelWidth;
                    h = bitmap.PixelHeight;

                    int  trw = 0;
                    bool f   = false;
                    //  left
                    for (int x = 0; x < w; x++)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            if (bitmap.GetPixel(x, y).A != 0)
                            {
                                f = true;
                                break;
                            }
                        }

                        if (f)
                        {
                            break;
                        }

                        trw++;
                    }

                    //  right
                    f = false;
                    for (int x = w - 1; x >= 0; x--)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            if (bitmap.GetPixel(x, y).A != 0)
                            {
                                f = true;
                                break;
                            }
                        }

                        if (f)
                        {
                            break;
                        }

                        trw++;
                    }

                    //  Pad the text to power-of-two

                    Alt.Sketch.BitmapData bdata = bitmap.LockBits(Alt.Sketch.ImageLockMode.ReadOnly);

                    int    w2 = 0;
                    int    h2 = 0;
                    byte[] p  = image_next2(bdata.Scan0, bdata.PixelWidth, bdata.PixelHeight, bdata.ByteDepth, trw, ref w2, ref h2);

                    bitmap.UnlockBits(bdata);


                    /* Saturate the color channels.  Modulate ONLY in alpha. */

                    Image.image_white(p, w2, h2, bitmap.ByteDepth);

                    /* Create the OpenGL texture object. */

                    o = Image.make_texture(p, w2, h2, bitmap.ByteDepth);
                }
            }
            else
            {
                /* Empty string. */

                //if (w) *
                w = 0;
                //if (h) *
                h = 0;
                //if (W) *W = 0;
                //if (H) *H = 0;
            }

            return(o);
        }