Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=====================#
- # Text to Image v1.04 #
- #=====================#
- module Z_Systems
- module ImgText
- DEFAULT = "charset"
- TABLE = {
- "Full" => [["A", "B", "C", "D", "E", "F", "G", "H"],
- ["I", "J", "K", "L", "M", "N", "O", "P"],
- ["Q", "R", "S", "T", "U", "V", "W", "X"],
- ["Y", "Z", "1", "2", "3", "4", "5", "6"],
- ["7", "8", "9", "0", "+", "-", "$", "/"]],
- "Numbers" => [["0", "1", "2", "3", "4"],
- ["5", "6", "7", "8", "9"]]
- }
- DEFAULT_FONT = "Default"
- FONTS = {
- #Font Name => [TABLE layout, IMG Name(-.png)],
- "Default" => ["Full", "charset"],
- "Numbers" => ["Numbers", "numset"]
- }
- end
- end
- #==============================================================================#
- # Imput: draw_img_text(string, x, y, spacing, allign, font) #
- # string = Contents to Convert #
- # x, y = Coordinates to place Image #
- # spacing(Def:0) = Space between characters in string image #
- # allign(Def:0) = 0 => Left, 1 => Right, 2 => Center #
- # font(Def:Default) = Font to use (Includes Image and Table Layout) #
- #==============================================================================#
- class Window_Base
- include Z_Systems::ImgText
- def draw_img_text(string, x, y, spacing = 0, allign = 0, font = DEFAULT_FONT)
- string = string.to_s
- return if string.length == 0
- tablename, filename = FONTS[font]
- move = (Cache.picture(filename).width / TABLE[tablename][0].size) + spacing
- fsx = move*string.length - spacing
- case allign
- when 0 #Left Allign
- tx = x
- when 1 #Right Allign
- tx = x - fsx
- when 2 #Center Allign
- tx = x - fsx/2
- end
- for char in string.upcase.split(//)
- next if char == " "
- for row in TABLE[tablename]
- if row.include?(char)
- row = TABLE[tablename].index(row)
- break
- end
- end
- col = TABLE[tablename][row].index(char)
- draw_char(tx, y, row, col, font)
- tx += move
- end
- end
- def draw_char(x, y, row, col, font)
- tablename, filename = FONTS[font]
- bitmap = Cache.picture(filename)
- size_x = bitmap.width / TABLE[tablename][0].size
- size_y = bitmap.height / TABLE[tablename].size
- rect = Rect.new(0, 0, 0, 0)
- rect.x = size_x*col
- rect.y = size_y*row
- rect.width = size_x
- rect.height = size_y
- self.contents.blt(x, y, bitmap, rect)
- bitmap.dispose
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement