VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Re: Using stars to draw rectangle Posted by seancampbell on 7 Jun 2007 at 11:27 AM
Ok. This function returns a Bitmap which you can then do a GraphicsObj.DrawImage with:

    Function TextRect(ByVal CharToDraw As Char, ByVal CharSpace As Integer, ByVal Rect As Rectangle) As Bitmap
        'This function returns a bitmap image
        'of the rectangle. Since it is transparent there shouldn't
        'be a problem with pasting this on to of graphics
        Dim BMP As New Bitmap(Rect.Width + CharSpace, Rect.Height + CharSpace)
        Dim G As Graphics = Graphics.FromImage(BMP)

        Dim X As Integer
        Dim Y As Integer

        Dim xRatio As Double = Rect.Width / CharSpace
        Dim yRatio As Double = Rect.Height / CharSpace

        Dim i As Integer
        For i = 1 To CInt(xRatio) - 1
            G.DrawString(CharToDraw, New Font(Font.FontFamily.GenericSansSerif, 12, FontStyle.Regular, GraphicsUnit.Point), New SolidBrush(Color.Black), X, Y)
            X = X + CharSpace
        Next
        For i = 1 To CInt(yRatio) - 1
            G.DrawString(CharToDraw, New Font(Font.FontFamily.GenericSansSerif, 12, FontStyle.Regular, GraphicsUnit.Point), New SolidBrush(Color.Black), X, Y)
            Y = Y + CharSpace
        Next
        For i = 1 To CInt(xRatio) - 1
            G.DrawString(CharToDraw, New Font(Font.FontFamily.GenericSansSerif, 12, FontStyle.Regular, GraphicsUnit.Point), New SolidBrush(Color.Black), X, Y)
            X = X - CharSpace
        Next
        For i = 1 To CInt(yRatio) - 1
            G.DrawString(CharToDraw, New Font(Font.FontFamily.GenericSansSerif, 12, FontStyle.Regular, GraphicsUnit.Point), New SolidBrush(Color.Black), X, Y)
            Y = Y - CharSpace
        Next

        Return BMP

    End Function
Thread Tree
GODDY Using stars to draw rectangle on 6 Jun 2007 at 3:59 AM
seancampbell Re: Using stars to draw rectangle on 6 Jun 2007 at 8:46 AM
seancampbell Re: Using stars to draw rectangle on 7 Jun 2007 at 9:53 AM
seancampbell Re: Using stars to draw rectangle on 7 Jun 2007 at 11:27 AM
seancampbell Re: Using stars to draw rectangle on 7 Jun 2007 at 11:58 AM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.