QB Times Issue #6
Transforming text
By Maxx
Do you want to transform your text? Here are a few tips to modify your text to any kind of form !
The screen mode I used is screen 9. It is a 640 x 350 screen mode.
The first you should have to do is to save the text in a matrix, like the following example :
' text$ is the text to save
DIM txtmatrix(LEN(textin$) * 9, 13)
' we must dim the matrix to keep it in memory
LOCATE 1, 1: PRINT text$
' the text is printed on the screen so that it can be saved. If the text you want to save
' is already there, you can remove this line !
FOR i = 0 TO LEN(textin$) * 8
' in screen 9, the characters width is 8
FOR j = 1 TO 13
' in screen 9, the characters height is a little less than 13,
' but if the text is
' already modified (with underlining, for example), the best thing to do is to reserve
' more memory for the matrix
txtmatrix(i, j) = POINT(i, j)
' here is the way to save each dot of the text in the matrix.
NEXT j, i
Now that your text is saved, you can modify it !
For example, to flip the text horizontaly, add this code after saving the text matrix :
FOR i = 630 TO 630 - (LEN(textin$) * 8) STEP -1
' we must start from the right of the screen (640*350 in screen 9)
FOR j = 1 TO 13
IF txtmatrix((630 - i), j) <> 0 THEN PSET (i, j), txtmatrix((630 - i), j)
' I add the test because on slow computers, the program printed the black dots too and it
' was a waste of time !
NEXT j, i
To flip the text vertically, you can draw a separation line using this line of code :
LINE (0, 14)-(LEN(textin$) * 8, 14)
To flip the text, that's the same sub as previously but now J is reversed, not I.
So you must use that sub :
FOR i = 1 TO LEN(textin$) * 8
FOR j = 14 TO 1 STEP -1
IF txtmatrix(i, 14 - j) <> 0 THEN PSET (i, j + 14), txtmatrix(i, 14 - j)
NEXT j, i
And if you want to create a nice effect on the vertical flipping, transform the third line of code to the following :
IF txtmatrix(i, 14 - j) <> 0 THEN PSET (i + j, j + 14), txtmatrix(i, 14 - j)
so that the text is inclined.
Using it, you can make an italic font, but without reversing.
There are many different ways to transform a text : you can apply a font, you can do anything.
If you want more examples, check out my site at Maxx Software or download EFFECTS.BAS from the GFX section on Future Software Website.
Thanx for reading this article and I hope I explained it correctly ! (if you didn't, feel free to email me!
© Copyright 2000, Marinus Israel & Jorden Chamid