Früher hat man sowas vielleicht händisch nach Augenmaß eingetipperlt, etwa so:
Code: Alles auswählen
#### #### #### # #
# # # # # #
#### #### # # #
# # # # # #
# # #### #### # #
Also entsteht die ganz einfache Theorie: ich wandle Vektorschriftzüge in Pixel um und rechne Pixel in Ascii-Zeichen um.
Dazu folgende Frage: Soetwas nutzt man ja ganz gern mal in einer CLI-Anwendung. Ist es eigentlich sicher, die dafür notwendigen Funktionen aus der Image-Bibliothek und der Fonts-Bilbiothek anzurufen oder könnte dies auf manchen Systemen Fehler hervorrufen? Image und Font dürften ja technologisch weit über der Console liegen, darum die Frage.
Gibt es vielleicht hier schon eine Implementierung, die nicht nur weiße Rauten setzt sondern mit aller Raffiness solche Ascii-Art Bilder generiert?
Hier meine eigene (primitivere) Implementierung, die die Herangehensweise zeigt:
Code: Alles auswählen
procedure drawBanner ( text$ )
;{
;{
protected *img
protected *fnt
protected *grb
protected txSpanX
protected txSpanY
;}
*img = createImage ( #pb_any,
1024,
1024 )
createImage ( #null,
1,
1 )
*fnt = loadFont ( #pb_any,
"FixedSys",
9 )
if ( startDrawing ( imageOutput ( *img ) ) )
;{
if ( ( *fnt ) and ( isFont ( *fnt ) ) )
;{
if ( fontId ( *fnt ) )
;{
drawingFont ( fontId ( *fnt ) )
drawText ( 0,
0,
text$,
#white,
#black )
txSpanX = textWidth ( text$ )
txSpanY = textHeight ( text$ )
;}
endIf
;}
endIf
stopDrawing ( )
grabImage ( *img,
#null,
0,
0,
txSpanX,
txSpanY )
;}
endIf
if ( startDrawing ( imageOutput ( #null ) ) )
;{
enableGraphicalConsole ( #true )
for y = 1 to imageHeight ( #null ) - 1
;{
for x = 1 to imageWidth ( #null ) - 1
;{
consoleLocate ( x, y )
if ( point ( x, y ) = #white )
;{
print ( "#" )
;}
endIf
;}
next
;}
next
;}
endIf
;}
endProcedure
if ( openConsole ( ) )
;{
drawBanner ( "PureBasic v6" )
input ( )
closeConsole ( )
;}
endIf