summaryrefslogtreecommitdiff
path: root/imagefont/imagefont.bmx
diff options
context:
space:
mode:
Diffstat (limited to 'imagefont/imagefont.bmx')
-rw-r--r--imagefont/imagefont.bmx108
1 files changed, 0 insertions, 108 deletions
diff --git a/imagefont/imagefont.bmx b/imagefont/imagefont.bmx
deleted file mode 100644
index 28d4595..0000000
--- a/imagefont/imagefont.bmx
+++ /dev/null
@@ -1,108 +0,0 @@
-'Module noddybox.imagefont
-
-'ModuleInfo "Framework: Simple Bitmap Font Routines"
-'ModuleInfo "Copyright: Public Domain"
-'ModuleInfo "Author: Ian Cowburn"
-'ModuleInfo "Version: $Revision$"
-
-' $Id$
-
-Type ImageFont
-
- Const NOCHR=96
-
- Field img:TImage[NOCHR]
- Field height:Int[NOCHR]
- Field width:Int[NOCHR]
- Field is_fixed:Int
-
- Function Load:ImageFont(path:String)
- Local fnt:ImageFont
- Local str:TStream
- Local f,x,y
- Local r,g,b
-
- str=ReadStream(path)
-
- If (Not str) Then Return Null
-
- fnt=New ImageFont
-
- fnt.is_fixed=Readint(str)
-
- GetMaskColor(r,g,b)
- SetMaskColor(0,0,0)
-
- For f=0 Until NOCHR
- fnt.width[f]=Readint(str)
- fnt.height[f]=Readint(str)
-
- DebugLog("CHR " + f + " " + fnt.width[f] + "x" + fnt.height[f])
-
- fnt.img[f]=CreateImage(fnt.width[f],fnt.height[f],1,MASKEDIMAGE)'FILTEREDIMAGE|MASKEDIMAGE)
-
- Local pm:TPixmap=LockImage(fnt.img[f])
-
- For x=0 Until fnt.width[f]
- For y=0 Until fnt.height[f]
- WritePixel(pm,x,y,Readint(str))
- Next
- Next
-
- UnlockImage(fnt.img[f])
- Next
-
- SetMaskColor(r,g,b)
-
- CloseStream(str)
-
- Return fnt
- End Function
-
- Method DrawColoured(txt:String, x:Int, y:Int, red:Int, green:Int, blue:Int)
- Local f,r,g,b,c
- Local xs#,ys#
-
- GetScale(xs,ys)
-
- GetColor(r,g,b)
- SetColor(red,green,blue)
-
- For f=1 To Len(txt)
- c=Asc(Mid$(txt,f,1))-32
- DrawImage(img[c],x,y)
- x:+width[c]*xs
- Next
-
- SetColor(r,g,b)
- End Method
-
- Method Draw(txt:String, x:Int, y:Int)
- DrawColoured(txt,x,y,255,255,255)
- End Method
-
- Method CentreColoured(txt:String, y:Int, red:Int, green:Int, blue:Int)
- If is_fixed
- DrawColoured(txt,GraphicsWidth()/2-Len(txt)*width[0]/2,y,red,green,blue)
- Else
- DrawColoured(txt,GraphicsWidth()/2-TextWidth(txt)/2,y,red,green,blue)
- EndIf
- End Method
-
- Method Centre(txt:String, y:Int)
- If is_fixed
- DrawColoured(txt,GraphicsWidth()/2-Len(txt)*width[0]/2,y,255,255,255)
- Else
- DrawColoured(txt,GraphicsWidth()/2-TextWidth(txt)/2,y,255,255,255)
- EndIf
- End Method
-
- Method TextWidth:Int(txt:String)
- Local w
- For Local f=1 To Len(txt)
- w:+width[Asc(Mid$(txt,f,1))]
- Next
- Return w
- End Method
-
-End Type