TI(i) = TextToImage("Here's some text for you.", 16, &HFFFF0000, 0, i)
'print forward, backward, up to down, down to up
DisplayImage TI(1), 100, 100, 0, 1
DisplayImage TI(2), 100, 510, 0, 1
DisplayImage TI(3), 100, 110, 0, 1
DisplayImage TI(4), 300, 110, 0, 1
'And now to scale these fonts
Scaled1 = ScaleImage(TI(1), 2, 2) 'double width, double height
DisplayImage Scaled1, 100, 100, 0, 1
Scaled2 = ScaleImage(TI(1), 2, 1) 'double width, normal height
DisplayImage Scaled2, 100, 150, 0, 1
Scaled3 = ScaleImage(TI(1), 1, 2) 'normal width, double height
DisplayImage Scaled3, 100, 200, 0, 1
Scaled4 = ScaleImage(TI(1), 1.5, 1.5) '1.5 times as wide, 1.5 times as high
DisplayImage Scaled4, 100, 250, -45, 1 'rotated at -45 degrees
DisplayImage Scaled4, 400, 300, angle, 0 'and just to show how we can rotate with the displayimage routine
angle = angle - 3
'Image is the image handle which we use to reference our image.
'x,y is the X/Y coordinates where we want the image to be at on the screen.
'angle is the angle which we wish to rotate the image.
'mode determines HOW we place the image at point X,Y.
'Mode 0 we center the image at point X,Y
'Mode 1 we place the Top Left corner of oour image at point X,Y
'Mode 2 is Bottom Left
'Mode 3 is Top Right
'Mode 4 is Bottom Right
px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
px(1) = 0: py(1) = h: px(2) = w: py(2) = h
px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
sinr
= SIN(angle
/ 57.2957795131): cosr
= COS(angle
/ 57.2957795131) x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
px(i) = x2: py(i) = y2
_MAPTRIANGLE (0, 0)-(0, h
- 1)-(w
- 1, h
- 1), Image
TO(px
(0), py
(0))-(px
(1), py
(1))-(px
(2), py
(2)) _MAPTRIANGLE (0, 0)-(w
- 1, 0)-(w
- 1, h
- 1), Image
TO(px
(0), py
(0))-(px
(3), py
(3))-(px
(2), py
(2))
'text$ is the text that we wish to transform into an image.
'font& is the handle of the font we want to use.
'fc& is the color of the font we want to use.
'bfc& is the background color of the font.
'Mode 1 is print forwards
'Mode 2 is print backwards
'Mode 3 is print from top to bottom
'Mode 4 is print from bottom up
'Mode 0 got lost somewhere, but it's OK. We check to see if our mode is < 1 or > 4 and compensate automatically if it is to make it one (default).
'print the text lengthwise
'print the text vertically
'Print text forward
'Print text backwards
temp$ = ""
temp$
= temp$
+ MID$(text$
, LEN(text$
) - i
, 1) 'Print text upwards
'first lets reverse the text, so it's easy to place
temp$ = ""
temp$
= temp$
+ MID$(text$
, LEN(text$
) - i
, 1) 'then put it where it belongs
fx
= (w&
- _PRINTWIDTH(MID$(temp$
, i
, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better 'Print text downwards
fx
= (w&
- _PRINTWIDTH(MID$(text$
, i
, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
'text is the text array that we wish to transform into an image.
'text(0) tells us how many lines of text we wish to use.
'font& is the handle of the font we want to use.
'fc& is the color of the font we want to use.
'bfc& is the background color of the font.
'Mode 1 is print forwards
'Mode 2 is print backwards
'Mode 3 is print from top to bottom
'Mode 4 is print from bottom up
'Mode 0 got lost somewhere, but it's OK. We check to see if our mode is < 1 or > 4 and compensate automatically if it is to make it one (default).
NumberOfLines
= VAL(text
(0))
'print the text lengthwise
FOR i
= 1 TO NumberOfLines
TextArrayToImage&
= _NEWIMAGE(w&
, h&
* NumberOfLines
, 32) 'print the text vertically
FOR j
= 1 TO NumberOfLines
IF LEN(text
(j
)) > longestline
THEN longestline
= LEN(text
(j
)) TextArrayToImage&
= _NEWIMAGE(w&
* NumberOfLines
, h&
* longestline
, 32)
FOR i
= 0 TO NumberOfLines
- 1 'Print text forward
'Print text backwards
temp$ = ""
temp$
= temp$
+ MID$(text
(i
+ 1), LEN(text
(i
+ 1)) - j
, 1) 'Print text upwards
'first lets reverse the text, so it's easy to place
temp$ = ""
temp$
= temp$
+ MID$(text
(i
+ 1), LEN(text
(i
+ 1)) - j
, 1) 'then put it where it belongs
fx
= (w&
- _PRINTWIDTH(MID$(temp$
, j
, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better 'Print text downwards
fx
= (w&
- _PRINTWIDTH(MID$(text
(i
+ 1), j
, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
w2 = w * xscale: h2 = h * yscale
ScaleImage& = NewImage&