RE: Fonts from String Patterns - bplus - 08-29-2023
Fixed for sharper image. I had to use -1's in the step when drawing the pixelated square according to scale:
This line in FPrint sub:
Line (x% + ((l - 1) * (sq + spacing%) + c) * scale%, y% + r * scale%)-Step(scale% - 1, scale% - 1), colr~&, BF
Check out the tiny b+ next to BPLUS between the Original Post and this code:
Code: (Select All) _Title "Font From String Patterns" ' b+ 2023-08-27
' Inspired by grymmjack post here https://staging.qb64phoenix.com/showthread.php?tid=1937&pid=18990#pid18990
' I used his font patterns to get my version started
' 2023-08-29 fixed with -1's in steps
Screen _NewImage(800, 600, 32)
_ScreenMove 200, 60
Dim spattern$(0 To 255)
Dim pattern5$(0 To 255)
LoadPatterns9x9 spattern$()
LoadPatterns5x5 pattern5$()
FPrint "TESTING", spattern$(), 323, 50, 2, 3, &HFF0000FF
FPrint "STARFIGHTER", spattern$(), 218, 180, 3, 3, &HFFFF0000
FPrint "STARFISHING", spattern$(), 70, 300, 5, 3, &HFFFFFF00
FPrint "BPLUS", spattern$(), 376, 550, 1, 2, &HFF008800
FPrint "b+", pattern5$(), 435, 547, 1, 1, &HFFFFFFFF
Sleep
Sub FPrint (s$, PA$(), x%, y%, scale%, spacing%, colr~&)
' s$ is string to "print" out
' PA$() is the array of string holding the font THE SQUARE pattern (must be NxN pattern)
' x, y top, left corner of print just like _PrintString
' scale is multiplier of pixeled font at NxN so now is Scale * N x Scale * N
' spacing is amount of pixels * scale between letters
' color~& type allows up to _RGB32() colors
Dim As Integer ls, a, sq, r, c, i
ls = Len(s$)
For l = 1 To ls
a = Asc(s$, l)
If Len(PA$(a)) Then ' do we have a pattern
sq = Sqr(Len(PA$(a)))
'Print Chr$(a), sq 'debug
For r = 0 To sq - 1 ' row and col of letter block
For c = 0 To sq - 1
i = r * sq + c + 1
If Asc(PA$(a), i) <> Asc(".") Then
Line (x% + ((l - 1) * (sq + spacing%) + c) * scale%, y% + r * scale%)-Step(scale% - 1, scale% - 1), colr~&, BF
End If
Next
Next
End If
Next
End Sub
Sub LoadPatterns9x9 (SPattern() As String)
Dim As Integer a
a = Asc("S")
SPattern(a) = "..XXXXXX."
SPattern(a) = SPattern(a) + ".X......."
SPattern(a) = SPattern(a) + ".X......."
SPattern(a) = SPattern(a) + "..S......"
SPattern(a) = SPattern(a) + "...SXS..."
SPattern(a) = SPattern(a) + "......S.."
SPattern(a) = SPattern(a) + ".......S."
SPattern(a) = SPattern(a) + ".......S."
SPattern(a) = SPattern(a) + "SXXXXXX.."
a = Asc("T")
SPattern(a) = "XXXXXXXXX"
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
a = Asc("A")
SPattern(a) = "...aXA..."
SPattern(a) = SPattern(a) + "..X...X.."
SPattern(a) = SPattern(a) + "..X...X.."
SPattern(a) = SPattern(a) + ".X.....X."
SPattern(a) = SPattern(a) + ".XXXXXXX."
SPattern(a) = SPattern(a) + ".X.....X."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
a = Asc("F")
SPattern(a) = "XXXXXXXXX"
SPattern(a) = SPattern(a) + "F........"
SPattern(a) = SPattern(a) + "F........"
SPattern(a) = SPattern(a) + "F........"
SPattern(a) = SPattern(a) + "FFFXXXX.."
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
a = Asc("I")
SPattern(a) = ".XXXXXXX."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + ".XXXXXXX."
a = Asc("G")
SPattern(a) = ".XXXXXXXX"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X....GGGX"
SPattern(a) = SPattern(a) + "X.......G"
SPattern(a) = SPattern(a) + "X......gG"
SPattern(a) = SPattern(a) + "X.....G.X"
SPattern(a) = SPattern(a) + ".XXXXX..G"
a = Asc("H")
SPattern(a) = "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "XXXXXXXXX"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
a = Asc("E")
SPattern(a) = "XXXXXXXXX"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "XXXXXXX.."
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "XXXXXXXXX"
a = Asc("N")
SPattern(a) = "X.......N"
SPattern(a) = SPattern(a) + "XX......N"
SPattern(a) = SPattern(a) + "X.X.....N"
SPattern(a) = SPattern(a) + "N..X....N"
SPattern(a) = SPattern(a) + "N...X...N"
SPattern(a) = SPattern(a) + "N....X..N"
SPattern(a) = SPattern(a) + "N.....X.N"
SPattern(a) = SPattern(a) + "N......XN"
SPattern(a) = SPattern(a) + "N.......N"
a = Asc("B")
SPattern(a) = "BBBBBBB.."
SPattern(a) = SPattern(a) + "X......B."
SPattern(a) = SPattern(a) + "X.......N"
SPattern(a) = SPattern(a) + "N......N."
SPattern(a) = SPattern(a) + "NBBBBBN.."
SPattern(a) = SPattern(a) + "N......b."
SPattern(a) = SPattern(a) + "N.......B"
SPattern(a) = SPattern(a) + "N......X."
SPattern(a) = SPattern(a) + "NBBBBBB.."
a = Asc("L")
SPattern(a) = "B........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "NBBBBBBLL"
a = Asc("U")
SPattern(a) = "B.......U"
SPattern(a) = SPattern(a) + "X.......U"
SPattern(a) = SPattern(a) + "X.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + ".BBBBBBL."
a = Asc("P")
SPattern(a) = "XPPPPPP.."
SPattern(a) = SPattern(a) + "X......X."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X......P."
SPattern(a) = SPattern(a) + "XXXXXXP.."
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
a = Asc("R")
SPattern(a) = "XPPPPPP.."
SPattern(a) = SPattern(a) + "X......X."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X......P."
SPattern(a) = SPattern(a) + "XXXXXXR.."
SPattern(a) = SPattern(a) + "X.....R.."
SPattern(a) = SPattern(a) + "X......R."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
End Sub
Sub LoadPatterns5x5 (SPattern() As String)
Dim As Integer a
a = Asc("b")
SPattern(a) = "b...."
SPattern(a) = SPattern(a) + "b...."
SPattern(a) = SPattern(a) + "b.bb."
SPattern(a) = SPattern(a) + "bb..b"
SPattern(a) = SPattern(a) + "b.bb."
a = Asc("+")
SPattern(a) = "....."
SPattern(a) = SPattern(a) + "..+.."
SPattern(a) = SPattern(a) + ".+++."
SPattern(a) = SPattern(a) + "..+.."
SPattern(a) = SPattern(a) + "....."
End Sub
I also found a missing dot in the P and fixed with this sharper image:
Compare to blurry b+ in first post image, yes you can see big difference even in screen shots!
RE: Fonts from String Patterns - grymmjack - 08-29-2023
Nice work!
This is much better and takes only 1 pixel vs the original.
RE: Fonts from String Patterns - grymmjack - 08-29-2023
@bplus I made it so the characters line up.
Code: (Select All)
_Title "Font From String Patterns" ' b+ 2023-08-27
' Inspired by grymmjack post here https://staging.qb64phoenix.com/showthread.php?tid=1937&pid=18990#pid18990
' I used his font patterns to get my version started
' 2023-08-29 fixed with -1's in steps
Screen _NewImage(800, 600, 32)
_ScreenMove 200, 60
Dim spattern$(0 To 255)
Dim pattern5$(0 To 255)
LoadPatterns9x9 spattern$()
LoadPatterns5x5 pattern5$()
FPrint "TESTING", spattern$(), 323, 50, 2, 3, &HFF0000FF
FPrint "STARFIGHTER", spattern$(), 218, 180, 3, 3, &HFFFF0000
FPrint "STARFISHING", spattern$(), 70, 300, 5, 3, &HFFFFFF00
FPrint "BPLUS", spattern$(), 376, 550, 1, 2, &HFF008800
FPrint "b+", pattern5$(), 435, 547, 1, 1, &HFFFFFFFF
Sleep
Sub FPrint (s$, PA$(), x%, y%, scale%, spacing%, colr~&)
' s$ is string to "print" out
' PA$() is the array of string holding the font THE SQUARE pattern (must be NxN pattern)
' x, y top, left corner of print just like _PrintString
' scale is multiplier of pixeled font at NxN so now is Scale * N x Scale * N
' spacing is amount of pixels * scale between letters
' color~& type allows up to _RGB32() colors
Dim As Integer ls, a, sq, r, c, i
ls = Len(s$)
For l = 1 To ls
a = Asc(s$, l)
If Len(PA$(a)) Then ' do we have a pattern
sq = Sqr(Len(PA$(a)))
'Print Chr$(a), sq 'debug
For r = 0 To sq - 1 ' row and col of letter block
For c = 0 To sq - 1
i = r * sq + c + 1
If Asc(PA$(a), i) <> Asc(".") Then
Line (x% + ((l - 1) * (sq + spacing%) + c) * scale%, y% + r * scale%)-Step(scale% - 1, scale% - 1), colr~&, BF
End If
Next
Next
End If
Next
End Sub
Sub LoadPatterns9x9 (SPattern() As String)
Dim As Integer a
a = Asc("S")
SPattern(a) = SPattern(a) + "..XXXXXX."
SPattern(a) = SPattern(a) + ".X......."
SPattern(a) = SPattern(a) + ".X......."
SPattern(a) = SPattern(a) + "..S......"
SPattern(a) = SPattern(a) + "...SXS..."
SPattern(a) = SPattern(a) + "......S.."
SPattern(a) = SPattern(a) + ".......S."
SPattern(a) = SPattern(a) + ".......S."
SPattern(a) = SPattern(a) + "SXXXXXX.."
a = Asc("T")
SPattern(a) = SPattern(a) + "XXXXXXXXX"
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
a = Asc("A")
SPattern(a) = SPattern(a) + "...aXA..."
SPattern(a) = SPattern(a) + "..X...X.."
SPattern(a) = SPattern(a) + "..X...X.."
SPattern(a) = SPattern(a) + ".X.....X."
SPattern(a) = SPattern(a) + ".XXXXXXX."
SPattern(a) = SPattern(a) + ".X.....X."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
a = Asc("F")
SPattern(a) = SPattern(a) + "XXXXXXXXX"
SPattern(a) = SPattern(a) + "F........"
SPattern(a) = SPattern(a) + "F........"
SPattern(a) = SPattern(a) + "F........"
SPattern(a) = SPattern(a) + "FFFXXXX.."
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
a = Asc("I")
SPattern(a) = SPattern(a) + ".XXXXXXX."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + "....X...."
SPattern(a) = SPattern(a) + ".XXXXXXX."
a = Asc("G")
SPattern(a) = SPattern(a) + ".XXXXXXXX"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X....GGGX"
SPattern(a) = SPattern(a) + "X.......G"
SPattern(a) = SPattern(a) + "X......gG"
SPattern(a) = SPattern(a) + "X.....G.X"
SPattern(a) = SPattern(a) + ".XXXXX..G"
a = Asc("H")
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "XXXXXXXXX"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
a = Asc("E")
SPattern(a) = SPattern(a) + "XXXXXXXXX"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "XXXXXXX.."
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "XXXXXXXXX"
a = Asc("N")
SPattern(a) = SPattern(a) + "X.......N"
SPattern(a) = SPattern(a) + "XX......N"
SPattern(a) = SPattern(a) + "X.X.....N"
SPattern(a) = SPattern(a) + "N..X....N"
SPattern(a) = SPattern(a) + "N...X...N"
SPattern(a) = SPattern(a) + "N....X..N"
SPattern(a) = SPattern(a) + "N.....X.N"
SPattern(a) = SPattern(a) + "N......XN"
SPattern(a) = SPattern(a) + "N.......N"
a = Asc("B")
SPattern(a) = SPattern(a) + "BBBBBBB.."
SPattern(a) = SPattern(a) + "X......B."
SPattern(a) = SPattern(a) + "X.......N"
SPattern(a) = SPattern(a) + "N......N."
SPattern(a) = SPattern(a) + "NBBBBBN.."
SPattern(a) = SPattern(a) + "N......b."
SPattern(a) = SPattern(a) + "N.......B"
SPattern(a) = SPattern(a) + "N......X."
SPattern(a) = SPattern(a) + "NBBBBBB.."
a = Asc("L")
SPattern(a) = SPattern(a) + "B........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "N........"
SPattern(a) = SPattern(a) + "NBBBBBBLL"
a = Asc("U")
SPattern(a) = SPattern(a) + "B.......U"
SPattern(a) = SPattern(a) + "X.......U"
SPattern(a) = SPattern(a) + "X.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + "N.......U"
SPattern(a) = SPattern(a) + ".BBBBBBL."
a = Asc("P")
SPattern(a) = SPattern(a) + "XPPPPPP.."
SPattern(a) = SPattern(a) + "X......X."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X......P."
SPattern(a) = SPattern(a) + "XXXXXXP.."
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
SPattern(a) = SPattern(a) + "X........"
a = Asc("R")
SPattern(a) = SPattern(a) + "XPPPPPP.."
SPattern(a) = SPattern(a) + "X......X."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X......P."
SPattern(a) = SPattern(a) + "XXXXXXR.."
SPattern(a) = SPattern(a) + "X.....R.."
SPattern(a) = SPattern(a) + "X......R."
SPattern(a) = SPattern(a) + "X.......X"
SPattern(a) = SPattern(a) + "X.......X"
End Sub
Sub LoadPatterns5x5 (SPattern() As String)
Dim As Integer a
a = Asc("b")
SPattern(a) = SPattern(a) + "b...."
SPattern(a) = SPattern(a) + "b...."
SPattern(a) = SPattern(a) + "b.bb."
SPattern(a) = SPattern(a) + "bb..b"
SPattern(a) = SPattern(a) + "b.bb."
a = Asc("+")
SPattern(a) = SPattern(a) + "....."
SPattern(a) = SPattern(a) + "..+.."
SPattern(a) = SPattern(a) + ".+++."
SPattern(a) = SPattern(a) + "..+.."
SPattern(a) = SPattern(a) + "....."
End Sub
You can see these a LOT easier for design purposes this way.
RE: Fonts from String Patterns - grymmjack - 08-29-2023
@bplus also a challenge if you want it (don't feel obligated).
Make the letters draw as if they are written. Using the numbers draw strokes from lowest to highest for each glyph. 1 first stroke, 2 second stroke, etc.
Put a delay in between each stroke.
I was playing with your code and added a SLEEP under the LINE so I could see what it was doing, and it looked cool while I just held down space.
Code: (Select All)
Sub LoadPatterns9x9 (SPattern() As String)
Dim As Integer a
a = Asc("S")
SPattern(a) = SPattern(a) + "..111111."
SPattern(a) = SPattern(a) + ".2......."
SPattern(a) = SPattern(a) + ".2......."
SPattern(a) = SPattern(a) + "..3......"
SPattern(a) = SPattern(a) + "...333..."
SPattern(a) = SPattern(a) + "......4.."
SPattern(a) = SPattern(a) + ".......4."
SPattern(a) = SPattern(a) + ".......4."
SPattern(a) = SPattern(a) + "5555555.."
a = Asc("T")
SPattern(a) = SPattern(a) + "111111111"
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
a = Asc("A")
SPattern(a) = SPattern(a) + "...122..."
SPattern(a) = SPattern(a) + "..1...2.."
SPattern(a) = SPattern(a) + "..1...2.."
SPattern(a) = SPattern(a) + ".1.....2."
SPattern(a) = SPattern(a) + ".1333332."
SPattern(a) = SPattern(a) + ".1.....2."
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
a = Asc("F")
SPattern(a) = SPattern(a) + "111111111"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2333333.."
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
a = Asc("I")
SPattern(a) = SPattern(a) + ".1111111."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + ".3333333."
a = Asc("G")
SPattern(a) = SPattern(a) + ".11111111"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2....4444"
SPattern(a) = SPattern(a) + "2.......5"
SPattern(a) = SPattern(a) + "2......35"
SPattern(a) = SPattern(a) + "2.....3.5"
SPattern(a) = SPattern(a) + ".33333..5"
a = Asc("H")
SPattern(a) = SPattern(a) + "1.......1"
SPattern(a) = SPattern(a) + "1.......1"
SPattern(a) = SPattern(a) + "1.......1"
SPattern(a) = SPattern(a) + "1.......1"
SPattern(a) = SPattern(a) + "122222221"
SPattern(a) = SPattern(a) + "1.......1"
SPattern(a) = SPattern(a) + "1.......1"
SPattern(a) = SPattern(a) + "1.......1"
SPattern(a) = SPattern(a) + "1.......1"
a = Asc("E")
SPattern(a) = SPattern(a) + "111111111"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2444444.."
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "233333333"
a = Asc("N")
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "12......3"
SPattern(a) = SPattern(a) + "1.2.....3"
SPattern(a) = SPattern(a) + "1..2....3"
SPattern(a) = SPattern(a) + "1...2...3"
SPattern(a) = SPattern(a) + "1....2..3"
SPattern(a) = SPattern(a) + "1.....2.3"
SPattern(a) = SPattern(a) + "1......23"
SPattern(a) = SPattern(a) + "1.......3"
a = Asc("B")
SPattern(a) = SPattern(a) + "1111111.."
SPattern(a) = SPattern(a) + "2......1."
SPattern(a) = SPattern(a) + "2.......1"
SPattern(a) = SPattern(a) + "2......1."
SPattern(a) = SPattern(a) + "2111111.."
SPattern(a) = SPattern(a) + "2......3."
SPattern(a) = SPattern(a) + "2.......3"
SPattern(a) = SPattern(a) + "2......3."
SPattern(a) = SPattern(a) + "2333333.."
a = Asc("L")
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "122222222"
a = Asc("U")
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + ".2222222."
a = Asc("P")
SPattern(a) = SPattern(a) + "1222222.."
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1333332.."
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
a = Asc("R")
SPattern(a) = SPattern(a) + "1222222.."
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1333332.."
SPattern(a) = SPattern(a) + "1.....4.."
SPattern(a) = SPattern(a) + "1......4."
SPattern(a) = SPattern(a) + "1.......4"
SPattern(a) = SPattern(a) + "1.......4"
End Sub
Sub LoadPatterns5x5 (SPattern() As String)
Dim As Integer a
a = Asc("b")
SPattern(a) = SPattern(a) + "1...."
SPattern(a) = SPattern(a) + "1...."
SPattern(a) = SPattern(a) + "1.22."
SPattern(a) = SPattern(a) + "12..2"
SPattern(a) = SPattern(a) + "1.22."
a = Asc("+")
SPattern(a) = SPattern(a) + "....."
SPattern(a) = SPattern(a) + "..1.."
SPattern(a) = SPattern(a) + ".212."
SPattern(a) = SPattern(a) + "..1.."
SPattern(a) = SPattern(a) + "....."
End Sub
RE: Fonts from String Patterns - bplus - 08-30-2023
@grymmjack I like what you've done with the letters
Here is the stroke of genius you requested
Code: (Select All)
_Title "Font From String Patterns Strokes" ' b+ 2023-08-27
' Inspired by grymmjack post here https://staging.qb64phoenix.com/showthread...0#pid18990
' I used his font patterns to get my version started
' 2023-08-29 fixed with -1's in steps
' 2023-08-29 Now with numbered strokes for drawing
' and grymmjack's fix for character design
Screen _NewImage(800, 600, 32)
_ScreenMove 200, 60
Dim spattern$(0 To 255)
Dim pattern5$(0 To 255)
LoadPatterns9x9 spattern$()
LoadPatterns5x5 pattern5$()
FPrint "TESTING", spattern$(), 323, 50, 2, 3, &HFF0000FF
FPrint "STARFIGHTER", spattern$(), 218, 180, 3, 3, &HFFFF0000
FPrint "STARFISHING", spattern$(), 70, 300, 5, 3, &HFFFFFF00
FPrint "BPLUS", spattern$(), 376, 550, 1, 2, &HFF008800
FPrint "b+", pattern5$(), 435, 547, 1, 1, &HFFFFFFFF
Sleep
Sub FPrint (s$, PA$(), x%, y%, scale%, spacing%, colr~&)
' s$ is string to "print" out
' PA$() is the array of string holding the font THE SQUARE pattern (must be NxN pattern)
' x, y top, left corner of print just like _PrintString
' scale is multiplier of pixeled font at NxN so now is Scale * N x Scale * N
' spacing is amount of pixels * scale between letters
' color~& type allows up to _RGB32() colors
Dim As Integer ls, a, sq, r, c, i, digi
Dim d$
ls = Len(s$)
For l = 1 To ls
a = Asc(s$, l)
If Len(PA$(a)) Then ' do we have a pattern
sq = Sqr(Len(PA$(a)))
'Print Chr$(a), sq 'debug
For digi = 1 To 9
d$ = _Trim$(Str$(digi))
For r = 0 To sq - 1 ' row and col of letter block
For c = 0 To sq - 1
i = r * sq + c + 1
If Mid$(PA$(a), i, 1) = d$ Then
Line (x% + ((l - 1) * (sq + spacing%) + c) * scale%, y% + r * scale%)-Step(scale% - 1, scale% - 1), colr~&, BF
_Delay .04
End If
Next
Next
Next
End If
Next
End Sub
Sub LoadPatterns9x9 (SPattern() As String)
Dim As Integer a
a = Asc("S")
SPattern(a) = SPattern(a) + "..111111."
SPattern(a) = SPattern(a) + ".2......."
SPattern(a) = SPattern(a) + ".2......."
SPattern(a) = SPattern(a) + "..3......"
SPattern(a) = SPattern(a) + "...333..."
SPattern(a) = SPattern(a) + "......4.."
SPattern(a) = SPattern(a) + ".......4."
SPattern(a) = SPattern(a) + ".......4."
SPattern(a) = SPattern(a) + "5555555.."
a = Asc("T")
SPattern(a) = SPattern(a) + "111111111"
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
SPattern(a) = SPattern(a) + "....2...."
a = Asc("A")
SPattern(a) = SPattern(a) + "...122..."
SPattern(a) = SPattern(a) + "..1...2.."
SPattern(a) = SPattern(a) + "..1...2.."
SPattern(a) = SPattern(a) + ".1.....2."
SPattern(a) = SPattern(a) + ".1333332."
SPattern(a) = SPattern(a) + ".1.....2."
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
a = Asc("F")
SPattern(a) = SPattern(a) + "122222222"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1333333.."
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
a = Asc("I")
SPattern(a) = SPattern(a) + ".2222222."
SPattern(a) = SPattern(a) + "....1...."
SPattern(a) = SPattern(a) + "....1...."
SPattern(a) = SPattern(a) + "....1...."
SPattern(a) = SPattern(a) + "....1...."
SPattern(a) = SPattern(a) + "....1...."
SPattern(a) = SPattern(a) + "....1...."
SPattern(a) = SPattern(a) + "....1...."
SPattern(a) = SPattern(a) + ".3333333."
a = Asc("G")
SPattern(a) = SPattern(a) + ".11111111"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2....4444"
SPattern(a) = SPattern(a) + "2.......5"
SPattern(a) = SPattern(a) + "2......35"
SPattern(a) = SPattern(a) + "2.....3.5"
SPattern(a) = SPattern(a) + ".33333..5"
a = Asc("H")
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "133333332"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1.......2"
a = Asc("E")
SPattern(a) = SPattern(a) + "111111111"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2444444.."
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "2........"
SPattern(a) = SPattern(a) + "233333333"
a = Asc("N")
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "12......3"
SPattern(a) = SPattern(a) + "1.2.....3"
SPattern(a) = SPattern(a) + "1..2....3"
SPattern(a) = SPattern(a) + "1...2...3"
SPattern(a) = SPattern(a) + "1....2..3"
SPattern(a) = SPattern(a) + "1.....2.3"
SPattern(a) = SPattern(a) + "1......23"
SPattern(a) = SPattern(a) + "1.......3"
a = Asc("B")
SPattern(a) = SPattern(a) + "1222222.."
SPattern(a) = SPattern(a) + "1......3."
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1......3."
SPattern(a) = SPattern(a) + "1333333.."
SPattern(a) = SPattern(a) + "1......4."
SPattern(a) = SPattern(a) + "1.......4"
SPattern(a) = SPattern(a) + "1......4."
SPattern(a) = SPattern(a) + "1444444.."
a = Asc("L")
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "122222222"
a = Asc("U")
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + "1.......3"
SPattern(a) = SPattern(a) + ".2222222."
a = Asc("P")
SPattern(a) = SPattern(a) + "1222222.."
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1333332.."
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
SPattern(a) = SPattern(a) + "1........"
a = Asc("R")
SPattern(a) = SPattern(a) + "1222222.."
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1.......2"
SPattern(a) = SPattern(a) + "1......2."
SPattern(a) = SPattern(a) + "1333332.."
SPattern(a) = SPattern(a) + "1.....4.."
SPattern(a) = SPattern(a) + "1......4."
SPattern(a) = SPattern(a) + "1.......4"
SPattern(a) = SPattern(a) + "1.......4"
End Sub
Sub LoadPatterns5x5 (SPattern() As String)
Dim As Integer a
a = Asc("b")
SPattern(a) = SPattern(a) + "1...."
SPattern(a) = SPattern(a) + "1...."
SPattern(a) = SPattern(a) + "1.22."
SPattern(a) = SPattern(a) + "12..2"
SPattern(a) = SPattern(a) + "1.22."
a = Asc("+")
SPattern(a) = SPattern(a) + "....."
SPattern(a) = SPattern(a) + "..1.."
SPattern(a) = SPattern(a) + ".212."
SPattern(a) = SPattern(a) + "..1.."
SPattern(a) = SPattern(a) + "....."
End Sub
RE: Fonts from String Patterns - grymmjack - 08-30-2023
(08-30-2023, 12:36 AM)bplus Wrote: @grymmjack I like what you've done with the letters
Here is the stroke of genius you requested
... HAHAH dude you rock.
So simply achieved. Wow!
|