Nom héros en couleurs
RPG Maker universe :: RPG Maker VX :: Scripts :: Menu
Page 1 sur 1
Nom héros en couleurs
élégant non ?
Ce script de Ramiro permet de mettre les noms héros en couleurs, mais je ne sais pas si ça le fait autre part, je crois pas juste ...
- Code:
#===========================================================================
# ** Bitmap and Font expansion [RMVX/RMXP]
#---------------------------------------------------------------------------
# by Ramiro
# V 1.0
#--------------------------------------------------------------------------
# Notes:
# Don't use it with big letters or it may lag
#--------------------------------------------------------------------------
#
# New Methods:
#
# Font
# Font#outline=(boolean), choose if the font is outline.
# Font#outline_color1=(Color) Internal outline color
# Font#outline_color2=(Color) External outline color
#
# Bitmap
#
# Bitmap#gradient_fill_rect(*arguments) #[New for XP]
# Bitmap#gradient_draw_text(*arguments) Look for instructions on the script
#
#===========================================================================
class Font
attr_accessor :outline
attr_accessor :outline_color1
attr_accessor :outline_color2
alias fond_expand_initialize initialize
def initialize
fond_expand_initialize
@outline = true
@outline_color1 = Color.new(0,0,0)
@outline_color2 = Color.new(0,0,0,0)
end
end
class Bitmap
#--------------------------------------------------------------------------
# Bitmap#draw_text
# Adds to the Outline font
#--------------------------------------------------------------------------
alias org_draw_text draw_text if !method_defined?('org_draw_text')
def draw_text(*args)
if args[0].is_a?(Rect)
x = args[0].x
y = args[0].y
w = args[0].width
h = args[0].height
text = args[1]
aling = args[2] if args[2]
else
x = args[0]
y = args[1]
w = args[2]
h = args[3]
text = args[4]
aling = args[5] if args[5]
end
aling = 0 if !aling
if font.outline
if font.respond_to?("shadow")
shval = font.shadow
font.shadow = false
end
color = font.color.clone
font.color = font.outline_color2
org_draw_text(x-2,y-2,w,h,text,aling)
org_draw_text(x,y-2,w,h,text,aling)
org_draw_text(x-2,y,w,h,text,aling)
org_draw_text(x+2,y+2,w,h,text,aling)
org_draw_text(x-2,y+2,w,h,text,aling)
org_draw_text(x+2,y-2,w,h,text,aling)
org_draw_text(x+2,y,w,h,text,aling)
org_draw_text(x,y+2,w,h,text,aling)
font.color = font.outline_color1
org_draw_text(x-1,y-1,w,h,text,aling)
org_draw_text(x,y-1,w,h,text,aling)
org_draw_text(x-1,y,w,h,text,aling)
org_draw_text(x+1,y+1,w,h,text,aling)
org_draw_text(x-1,y+1,w,h,text,aling)
org_draw_text(x+1,y-1,w,h,text,aling)
org_draw_text(x+1,y,w,h,text,aling)
org_draw_text(x,y+1,w,h,text,aling)
font.color = color.clone
font.shadow = shval if shval
end
org_draw_text(*args)
end
#--------------------------------------------------------------------------
# Bitmap#Gradient Fill Rect
# Patched the "vertical bug"
#--------------------------------------------------------------------------
def gradient_fill_rect(*args)
if args[0].is_a?(Rect)
x = args[0].x
y = args[0].y
w = args[0].width
h = args[0].height
c1 = args[1]
c2 = args[2]
v = args[3]
else
x = args[0]
y = args[1]
w = args[2]
h = args[3]
c1 = args[4]
c2 = args[5]
v = args[6]
end
v = false if !v
color_tones = []
if v
for i in 0...h
r = c1.red * (h - i) / h + c2.red * i / h
g = c1.green * (h - i) / h + c2.green * i / h
b = c1.blue * (h - i) / h + c2.blue * i / h
a = c1.alpha * (h - i) / h + c2.alpha * i / h
fill_rect(Rect.new(x,y+i,w,1),Color.new(r,g,b,a))
end
else
for i in 0...w
r = c1.red * (w - i) / w + c2.red * i / w
g = c1.green * (w - i) / w + c2.green * i / w
b = c1.blue * (w - i) / w + c2.blue * i / w
a = c1.alpha * (w - i) / w + c2.alpha * i / w
fill_rect(Rect.new(x+i,y,1,h),Color.new(r,g,b,a))
end
end
end
#--------------------------------------------------------------------------
# Bitmap#gradient_draw_text
#
# Arguments:
#
# Rect,name,color1,color2,aling,vertical
# x,y,width.height,text,color1,color2,aling,vertical
# Rect, x, y, width,height, text y aling are the same as the
# 'draw_text' method
#
# New argments:
# color1 = Initial font color
# color2 = Ending font color
# vertical: if true the gradient is vertical, false is horizontal
#
# - Default parameters:
#
# aling = 0
# vertical = false
#
#--------------------------------------------------------------------------
# ¡WARNING!
#
# You need some knowledge to use this!!!
#--------------------------------------------------------------------------
def gradient_draw_text(*args)
if args[0].is_a?(Rect)
x = args[0].x
y = args[0].y
w = args[0].width
h = args[0].height
text = args[1]
color1 = args[2]
color2 = args[3]
aling = args[4] if args[4]
vertical = args[5] if args[5]
else
x = args[0]
y = args[1]
w = args[2]
h = args[3]
text = args[4]
color1 = args[5]
color2 = args[6]
aling = args[7] if args[7]
vertical = args[8] if args[8]
end
aling = 0 if !aling
vertical = false if !vertical
text_bmp = Bitmap.new(w,h)
text_bmp.font.name = font.name
text_bmp.font.size = font.size
text_bmp.font.shadow = false if text_bmp.font.respond_to?("shadow")
text_bmp.font.outline = false if text_bmp.font.respond_to?("outline")
text_bmp.font.border = false if text_bmp.font.respond_to?("border")
text_bmp.font.bold = font.bold
text_bmp.font.italic = font.italic
text_bmp.draw_text(0,0,w,h,text,aling)
gradient_bmp = Bitmap.new(w,h)
gradient_bmp.gradient_fill_rect(0, 0, w, h, color1, color2, vertical)
for x2 in 0...w
for y2 in 0...h
alpha_txt = text_bmp.get_pixel(x2,y2).alpha
if alpha_txt > 0
c = gradient_bmp.get_pixel(x2,y2)
c.alpha = alpha_txt
text_bmp.set_pixel(x2,y2,c)
end
end
end
draw_text(x,y,w,h,text,aling)
blt(x,y,text_bmp,Rect.new(0,0,w,h))
end
end
</pre>
== Example ==
If You want to see somethig like the image use this code:
<pre>
class Window_Base
#--------------------------------------------------------------------------
# * Draw Name
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y)
contents.gradient_draw_text(x,y,108,WLH,actor.name,Color.new(255,0,0),Color.new(0,255,0),0,false)
end
end
RPG Maker universe :: RPG Maker VX :: Scripts :: Menu
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|