112 lines
3.3 KiB
ActionScript
112 lines
3.3 KiB
ActionScript
package org.flixel
|
|
{
|
|
import flash.display.BitmapData;
|
|
import flash.geom.Rectangle;
|
|
|
|
public class FlxBitmapFont
|
|
{
|
|
|
|
private var imgDefaultFont:Class = FlxBitmapFont_imgDefaultFont;
|
|
|
|
public var rects:Array;
|
|
|
|
public var horizontalPadding:int;
|
|
|
|
public var verticalPadding:int;
|
|
|
|
public var pixels:BitmapData;
|
|
|
|
public var height:uint;
|
|
|
|
private var _alphabet:String;
|
|
|
|
public function FlxBitmapFont(param1:Class = null, param2:uint = 0, param3:uint = 5, param4:int = 1, param5:int = 5, param6:String = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~")
|
|
{
|
|
var _loc8_:uint = 0;
|
|
var _loc11_:uint = 0;
|
|
var _loc12_:uint = 0;
|
|
super();
|
|
if(param1 == null)
|
|
{
|
|
param1 = this.imgDefaultFont;
|
|
}
|
|
this.pixels = FlxG.addBitmap(param1);
|
|
this.height = param3;
|
|
this.verticalPadding = param5;
|
|
this.horizontalPadding = param4;
|
|
this._alphabet = param6;
|
|
this.rects = new Array();
|
|
var _loc7_:uint = this.pixels.getPixel(0,0);
|
|
if(param2 == 0)
|
|
{
|
|
_loc8_ = 1;
|
|
}
|
|
else
|
|
{
|
|
_loc8_ = 0;
|
|
}
|
|
var _loc9_:uint = 0;
|
|
var _loc10_:Number = 0;
|
|
if(param2 == 0)
|
|
{
|
|
_loc12_ = 0;
|
|
loop1:
|
|
while(_loc12_ < int(this.pixels.height / this.height))
|
|
{
|
|
_loc11_ = 0;
|
|
while(true)
|
|
{
|
|
if(_loc11_ >= this.pixels.width)
|
|
{
|
|
_loc8_ += this.height + 1;
|
|
_loc9_ = 0;
|
|
_loc12_++;
|
|
continue loop1;
|
|
}
|
|
if(this.pixels.getPixel(_loc11_,_loc8_ - 1) == _loc7_)
|
|
{
|
|
this.rects[this._alphabet.charCodeAt(_loc10_ - 1)] = new Rectangle(_loc9_,_loc8_,_loc11_ - _loc9_,this.height);
|
|
_loc10_++;
|
|
_loc9_ = _loc11_ + 1;
|
|
}
|
|
if(_loc10_ > this._alphabet.length)
|
|
{
|
|
break;
|
|
}
|
|
_loc11_++;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_loc12_ = 0;
|
|
loop0:
|
|
while(_loc12_ < int(this.pixels.height / this.height))
|
|
{
|
|
_loc11_ = 0;
|
|
while(true)
|
|
{
|
|
if(_loc11_ >= this.pixels.width / param2)
|
|
{
|
|
_loc8_ += this.height;
|
|
_loc9_ = 0;
|
|
_loc12_++;
|
|
continue loop0;
|
|
}
|
|
this.rects[this._alphabet.charCodeAt(_loc10_ - 1)] = new Rectangle(_loc9_,_loc8_,param2,this.height);
|
|
_loc9_ = _loc11_ * param2;
|
|
if(++_loc10_ > this._alphabet.length)
|
|
{
|
|
break;
|
|
}
|
|
_loc11_++;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|