summaryrefslogtreecommitdiff
path: root/bitmapfont.mod
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-09-18 19:19:36 +0000
committerIan C <ianc@noddybox.co.uk>2005-09-18 19:19:36 +0000
commitf8de91ae41929286b1cf43c72093e5c996b1f949 (patch)
treef9ccb2fa8461c2941e6d60187ae8952e9ee30f12 /bitmapfont.mod
parentf79195715c66530b0bda50242380812c5e670c00 (diff)
Added documentation
Diffstat (limited to 'bitmapfont.mod')
-rw-r--r--bitmapfont.mod/bitmapfont.bmx49
-rw-r--r--bitmapfont.mod/doc/commands.html43
2 files changed, 92 insertions, 0 deletions
diff --git a/bitmapfont.mod/bitmapfont.bmx b/bitmapfont.mod/bitmapfont.bmx
index 35feb10..fd70671 100644
--- a/bitmapfont.mod/bitmapfont.bmx
+++ b/bitmapfont.mod/bitmapfont.bmx
@@ -1,3 +1,6 @@
+Rem
+bbdoc: noddybox.bitmapfont
+EndRem
Module noddybox.bitmapfont
ModuleInfo "Framework: Simple Bitmap Font Routines"
@@ -13,6 +16,13 @@ Import brl.Basic
Strict
+Rem
+bbdoc: Defines a bitmap font
+about: The @TBitmapFont object works from BMF Files, which are created using a tool called BitmapFontEd available at
+about: <a href="http://www.noddybox.demon.co.uk/free/index-csharp.html">http://www.noddybox.demon.co.uk/free/index-csharp.html</a><br>
+about: Note that when colours are referenced they simply modify the colours in the font images as @SetColor() would do on a norml image.<br>
+about: When drawing characters the current scale, alpha and rotation settings are applied.
+EndRem
Type TBitmapFont
Const NOCHR=95
@@ -24,6 +34,11 @@ Type TBitmapFont
Field max_width:Int
Field max_height:Int
+ Rem
+ bbdoc: Loads a font from the supplied BMF file.
+ returns: The created font, or null if the BMF file couldn't be loaded.
+ about: The @image_flags are passed onto @CreateImage() when the images for the font are being created.
+ EndRem
Function Load:TBitmapFont(path:String, image_flags:Int)
Local fnt:TBitmapFont
Local str:TStream
@@ -73,6 +88,10 @@ Type TBitmapFont
Return fnt
End Function
+ Rem
+ bbdoc: Draws coloured text.
+ about: Draws @txt at the supplied @x,@y co-ordinates. @red,@green and @blue control the colour.
+ EndRem
Method DrawColoured(txt:String, x:Int, y:Int, red:Int, green:Int, blue:Int)
Local f,r,g,b,c
Local xs#,ys#
@@ -91,10 +110,18 @@ Type TBitmapFont
SetColor(r,g,b)
End Method
+ Rem
+ bbdoc: Draws white text.
+ about: Draws @txt at the supplied @x,@y co-ordinates in white.
+ EndRem
Method Draw(txt:String, x:Int, y:Int)
DrawColoured(txt,x,y,255,255,255)
End Method
+ Rem
+ bbdoc: Draws centred, coloured text.
+ about: Draws @txt centred at the supplied @y co-ordinate. @red,@green and @blue control the colour.
+ EndRem
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)
@@ -103,6 +130,10 @@ Type TBitmapFont
EndIf
End Method
+ Rem
+ bbdoc: Draws centred, white text.
+ about: Draws @txt centred at the supplied @y co-ordinate in white.
+ EndRem
Method Centre(txt:String, y:Int)
If is_fixed
DrawColoured(txt,GraphicsWidth()/2-Len(txt)*width[0]/2,y,255,255,255)
@@ -111,6 +142,11 @@ Type TBitmapFont
EndIf
End Method
+ Rem
+ bbdoc: Width of the supplied string.
+ returns: The length of the string @txt in pixels.
+ about: The current scale settings are taken into account.
+ EndRem
Method TextWidth:Int(txt:String)
Local w
Local xs#,ys#
@@ -123,6 +159,11 @@ Type TBitmapFont
Return w
End Method
+ Rem
+ bbdoc: Height of the supplied string.
+ returns: The height of the string @txt in pixels.
+ about: The current scale settings are taken into account.
+ EndRem
Method TextHeight:Int(txt:String)
Local h:Int=0
Local xs#,ys#
@@ -136,10 +177,18 @@ Type TBitmapFont
Return h
End Method
+ Rem
+ bbdoc: Width of the largest character.
+ returns: The width in pixels of the largest character in the font.
+ EndRem
Method MaxWidth:Int()
Return max_width
End Method
+ Rem
+ bbdoc: Height of the largest character.
+ returns: The height in pixels of the largest character in the font.
+ EndRem
Method MaxHeight:Int()
Return max_height
End Method
diff --git a/bitmapfont.mod/doc/commands.html b/bitmapfont.mod/doc/commands.html
new file mode 100644
index 0000000..d196db5
--- /dev/null
+++ b/bitmapfont.mod/doc/commands.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+<title>BlitzMax Module Reference</title>
+<link rel="stylesheet" type="text/css" href="../../../../doc/bmxstyle.css">
+</head>
+<body>
+<h1>Type Reference</h1>
+<p><div id=TBitmapFont class=ref>
+<div class=rootdoc><font class=token>Type TBitmapFont</font> Defines a bitmap font</div><div class=indent><p>The <b>TBitmapFont</b> object works from BMF Files, which are created using a tool called BitmapFontEd available at
+<a href="http://www.noddybox.demon.co.uk/free/index-csharp.html">http://www.noddybox.demon.co.uk/free/index-csharp.html</a><br>
+Note that when colours are referenced they simply modify the colours in the font images as <b>SetColor</b>() would do on a norml image.<br>
+When drawing characters the current scale, alpha and rotation settings are applied.</div><br><p><div id=DrawColoured>
+<div class=rootdoc><font class=token>Method DrawColoured( txt:String, x:Int, y:Int, red:Int, green:Int, blue:Int )</font> Draws coloured text.</div><div class=indent><p>Draws <b>txt</b> at the supplied <b>x</b>,<b>y</b> co-ordinates. <b>red</b>,<b>green</b> and <b>blue</b> control the colour.</div><br></div><br>
+<p><div id=Draw>
+<div class=rootdoc><font class=token>Method Draw( txt:String, x:Int, y:Int )</font> Draws white text.</div><div class=indent><p>Draws <b>txt</b> at the supplied <b>x</b>,<b>y</b> co-ordinates in white.</div><br></div><br>
+<p><div id=CentreColoured>
+<div class=rootdoc><font class=token>Method CentreColoured( txt:String, y:Int, red:Int, green:Int, blue:Int )</font> Draws centred, coloured text.</div><div class=indent><p>Draws <b>txt</b> centred at the supplied <b>y</b> co-ordinate. <b>red</b>,<b>green</b> and <b>blue</b> control the colour.</div><br></div><br>
+<p><div id=Centre>
+<div class=rootdoc><font class=token>Method Centre( txt:String, y:Int )</font> Draws centred, white text.</div><div class=indent><p>Draws <b>txt</b> centred at the supplied <b>y</b> co-ordinate in white.</div><br></div><br>
+<p><div id=TextWidth>
+<div class=rootdoc><font class=token>Method TextWidth:Int( txt:String )</font> Width of the supplied string.</div><div class=indent><p><b>Returns:</b> The length of the string <b>txt</b> in pixels.<p>The current scale settings are taken into account.</div><br></div><br>
+<p><div id=TextHeight>
+<div class=rootdoc><font class=token>Method TextHeight:Int( txt:String )</font> Height of the supplied string.</div><div class=indent><p><b>Returns:</b> The height of the string <b>txt</b> in pixels.<p>The current scale settings are taken into account.</div><br></div><br>
+<p><div id=MaxWidth>
+<div class=rootdoc><font class=token>Method MaxWidth:Int()</font> Width of the largest character.</div><div class=indent><p><b>Returns:</b> The width in pixels of the largest character in the font.</div><br></div><br>
+<p><div id=MaxHeight>
+<div class=rootdoc><font class=token>Method MaxHeight:Int()</font> Height of the largest character.</div><div class=indent><p><b>Returns:</b> The height in pixels of the largest character in the font.</div><br></div><br>
+<p><div id=Load>
+<div class=rootdoc><font class=token>Function Load:TBitmapFont( path:String, image_flags:Int )</font> Loads a font from the supplied BMF file.</div><div class=indent><p><b>Returns:</b> The created font, or null if the BMF file couldn't be loaded.<p>The <b>image_flags</b> are passed onto <b>CreateImage</b>() when the images for the font are being created.</div><br></div><br>
+</div><br>
+<h1>Module Information</h1>
+<table>
+<tr><td><b>Framework</b></td>
+<td> Simple Bitmap Font Routines</td></tr>
+<tr><td><b>Copyright</b></td>
+<td> Public Domain</td></tr>
+<tr><td><b>Author</b></td>
+<td> Ian Cowburn</td></tr>
+<tr><td><b>Version</b></td>
+<td> $Revision$</td></tr>
+</table>
+</body>
+</html>