Joshy
Code: Select all
type Font
w as long
h as long
d as any ptr
end type
enum
FB_FONT_8 = 0,
FB_FONT_14
FB_FONT_16
end enum
extern Fonts(2) alias "__fb_font" as Font
sub PrintXY3(byref f as Font, _
byval xpos as integer, _
byval ypos as integer, _
byref text as string, _
byval fgcol as long=&HFFFFFF, _
byval bgcol as long=-1, _
byval Size as integer=1, _
byval Filled as integer=1, _
byval Round as integer=0 )
dim as integer i,y,yend,l,code,x,bits,sx
dim row as ubyte ptr
l=len(text)-1:if l<0 then exit sub
yend=f.h-1:if Size<1 then exit sub
screeninfo sx
screenlock
for i = 0 to l
code=text[i]:code*=f.h:row=f.d+code
if Size>1 then
if Filled=0 then
for y = 0 to yend
bits=*row
for x=0 to 7
if (bits and 1) then
if Round=0 then
line (xpos+x*size,ypos+y*size)-step(size,size),fgcol,b
else
circle (xpos+x*size+size*0.5,ypos+y*size+size*0.5),size*0.5,fgcol
end if
elseif bgcol<>-1 then
if Round=0 then
line (xpos+x*size,ypos+y*size)-step(size,size),bgcol,b
else
circle (xpos+x*size+size*0.5,ypos+y*size+size*0.5),size*0.5,bgcol
end if
end if
bits=bits shr 1
next
row+=1
next
xpos+=f.w*Size::if (xpos-f.w*Size)>sx then screenunlock:exit sub
else ' filled
for y = 0 to yend
bits=*row
for x=0 to 7
if (bits and 1) then
if Round=0 then
line (xpos+x*size,ypos+y*size)-step(size,size),fgcol,bf
else
circle (xpos+x*size+size*0.5,ypos+y*size+size*0.5),size*0.5,fgcol,,,,f
end if
elseif bgcol<>-1 then
if Round=0 then
line (xpos+x*size,ypos+y*size)-step(size,size),bgcol,bf
else
circle (xpos+x*size+size*0.5,ypos+y*size+size*0.5),size*0.5,bgcol,,,,f
end if
end if
bits=bits shr 1
next
row+=1
next
xpos+=f.w*Size:if (xpos-f.w*Size)>sx then screenunlock:exit sub
end if
else 'no Size
for y = 0 to yend
bits=*row
for x=0 to 7
if (bits and 1) then
pset (xpos+x,ypos+y),fgcol
elseif bgcol<>-1 then
pset (xpos+x,ypos+y),bgcol
endif
bits=bits shr 1
next
row+=1
next
xpos+=f.w:if (xpos-f.w)>sx then screenunlock:exit sub
end if
next
screenunlock
end sub
dim as integer Size,y,x,filled,round,c
dim as long fgcol,bgcol
dim as double w
'screen 19
screenres 640,480,,2
screenset 1,0
y=0:cls
for Size=1 to 8
x=0 :printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",1 ,,Size
x+=Size*8*4:printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",2 ,,Size,0
x+=Size*8*4:printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",3 ,,Size,1,1
x+=Size*8*4:printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",4 ,,Size,0,1
y+=Size*14
next
flip:sleep 2000,1
y=0:cls
for Size=1 to 8
x=0 :printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",4 ,5,Size
x+=Size*8*4:printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",3 ,6,Size,0
x+=Size*8*4:printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",2 ,7,Size,1,1
x+=Size*8*4:printxy3 Fonts(FB_FONT_14) ,x,y,"8x14 ",1 ,8,Size,0,1
y+=Size*14
next
flip:sleep 2000,1
do
fgcol = 1+rnd*254
bgcol = rnd*2 :if bgcol>1 then bgcol=1 +rnd *254 else bgcol=-1
while fgcol=bgcol:fgcol= 1+rnd*254:wend
for filled=1 to 0 step -1
for round=0 to 1
for w=-3.14 to 3.14 step 6.28/80
size=cos(w)*32+33
cls
printxy3 Fonts(FB_FONT_8) ,0,0,"Play with font.",fgcol,bgcol,Size,filled,round
printxy3 Fonts(FB_FONT_16),400,400,"Size=" & str(Size),7,,4,0
flip : sleep 50 : if len(inkey) then exit do
next
next
next
loop