This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
This script lets you draw text in different ways.
Draw Text like this-
Code:
self.contents.draw_text(x,y,w,h,text,align,type)
or like this using the Rect.new function (wasn't supported in version 1)
Code:
self.contents.draw_text(rect,text,align,type)
type = how text should be shown. automaticly set to 0
0 = Normal
1 = Outlined
2 = Shadowed
3 = Outlined + Shadowed
4 = 3d
5 = 3d + Shadowed
6 = Blue Outline
Version 4 tests a new method I saw to define the original color, now you don't have to.
Here is the script-
Text Variations V.4
Code:
#============================================================================
# * Text Variations
#-------------------------------------------------------------------------------------
# Draw Text in various formats: Normal, Outlined, Shadowed,
# Outlined + Shadowed, 3d, 3d + Shadowed, Blue Outlined
#-------------------------------------------------------------------------------------
# Tsunokiette
# Version 4
# 11.23.05
#============================================================================
#********************
# Begin Bitmap Changes
#********************
class Bitmap
#-------------------------
# Color - Black Outline
#-------------------------
def black_outline
return Color.new(0,0,0,255)
end
#-------------------
# Color - Shadow
#-------------------
def shadow
return Color.new(0,0,0,150)
end
#-------------
# Color - 3d
#-------------
def three_dimensional
return Color.new(40,40,40,255)
end
#------------------------
# Color - Blue Outline
#------------------------
def blue_outline
return Color.new(0,0,255,255)
end
#--------------------
# Alias Draw_Text
#--------------------
alias :text :draw_text
#--------------
# Draw_Text
#--------------
def draw_text(x,y=nil,w=0,h=0,text=nil,align=0,type=0)
if x.is_a?(Rect)
@x = x.x
@y = x.y
@w = x.width
@h = x.height
@text = y
@align = w
@type = h
else
@x = x
@y = y
@w = w
@h = h
@text = text
@align = align
@type = type
end
r = self.font.color.red
g = self.font.color.green
b = self.font.color.blue
a = self.font.color.alpha
@original = Color.new(r,g,b,a)
case @type
#normal
when 0
text(@x,@y,@w,@h,@text,@align)
#outlined
when 1
self.font.color = black_outline
text(@x+1,@y,@w,@h,@text,@align)
text(@x-1,@y,@w,@h,@text,@align)
text(@x,@y+1,@w,@h,@text,@align)
text(@x,@y-1,@w,@h,@text,@align)
self.font.color = @original
text(@x,@y,@w,@h,@text,@align)
#shadowed
when 2
self.font.color = shadow
text(@x+4,@y+4,@w,@h,@text,@align)
self.font.color = @original
text(@x,@y,@w,@h,@text,@align)
#outlined + shadowed
when 3
self.font.color = shadow
text(@x+4,@y+4,@w,@h,@text,@align)
self.font.color = black_outline
text(@x+1,@y,@w,@h,@text,@align)
text(@x-1,@y,@w,@h,@text,@align)
text(@x,@y+1,@w,@h,@text,@align)
text(@x,@y-1,@w,@h,@text,@align)
self.font.color = @original
text(@x,@y,@w,@h,@text,@align)
#3d
when 4
self.font.color = three_dimensional
text(@x+2,@y+2,@w,@h,@text,@align)
text(@x+1,@y+1,@w,@h,@text,@align)
self.font.color = @original
text(@x,@y,@w,@h,@text,@align)
#3d + shadowed
when 5
self.font.color = shadow
text(@x+4,@y+4,@w,@h,@text,@align)
self.font.color = three_dimensional
text(@x+2,@y+2,@w,@h,@text,@align)
text(@x+1,@y+1,@w,@h,@text,@align)
self.font.color = @original
text(@x,@y,@w,@h,@text,@align)
#blue outlined
when 6
self.font.color = blue_outline
text(@x+1,@y,@w,@h,@text,@align)
text(@x-1,@y,@w,@h,@text,@align)
text(@x,@y+1,@w,@h,@text,@align)
text(@x,@y-1,@w,@h,@text,@align)
self.font.color = @original
text(@x,@y,@w,@h,@text,@align)
end
end
end
#*******************
# End Bitmap Changes
#*******************