[XP] Backshadow Text

Started by Zexion, May 17, 2014, 08:54:29 pm

Previous topic - Next topic

Zexion

May 17, 2014, 08:54:29 pm Last Edit: May 17, 2014, 08:58:52 pm by Zexion
Backshadow Text
Authors: Zexion
Version: 1.0
Type: For Windows & Bitmaps
Key Term: Scripting Tool



Introduction

I made this for use in most of my projects. It produces a nice effect of backshadow without having to do several lines of code. Such as:
Save color
New color = black
Draw text x+1 y+1
new color = save color
draw text x y

Which comes up often enough in rmx-os.


Features


  • Easily add any amount of colors

  • Easy to replace draw_text with (only uses one more optional parameter)

  • Makes text pop




Screenshots





Demo

N/A


Script

Spoiler: ShowHide
#==============================================================================#
# Txt - Backshadow Text Method for Bitmaps & Windows
#------------------------------------------------------------------------------#
# Description:
# Draws text with color and a black back shadow.
# Colors can be defined here by strings & integers.
#------------------------------------------------------------------------------#
# Directions:
# 1.  Add your custom colors.
# 2.  use txt(x, y, width, height, text, center, color)
#     in place of draw_text(x, y, width, height, text, center, color)
#     color is optional :P
#------------------------------------------------------------------------------#
# Credit:
# Zexion of Chaos-Project
#==============================================================================#

module BST
  COLORS = { 1 => Color.new(255,255,255,255),     # White
             2 => Color.new(255,255,0,255),       # Yellow
             3 => Color.new(50, 50, 50, 255),     # Grey
             4 => Color.new(255,102,0,255),       # Orange
             5 => Color.new(156,156,215,255),     # Light Blue
             6 => Color.new(255,0,0,255),         # Red
             7 => Color.new(0,255,0,255)}         # Green
end
         
class Window_Base < Window
 #---------------------------------------------------------------------------
 # * txt
 #     x     : draw spot x
 #     y     : draw spot y
 #     width : width of the string
 #     height: height of the string
 #     text  : the text to draw
 #     center: 0 left align 1 center align 2 right align
 #     color : color of font
 #---------------------------------------------------------------------------
 def txt(x, y, width, height, text, center, color=0)
   self.contents.font.color = Color.new(0,0,0,255)
   self.contents.draw_text(x+1, y+1, width, height, text, center)
   if color > 0
     self.contents.font.color = BST::COLORS[color]
   else
     # White
     self.contents.font.color = Color.new(255,255,255,255)
   end
   self.contents.draw_text(x, y, width, height, text, center)
 end
end

class Bitmap
 #---------------------------------------------------------------------------
 # * txt
 #     x     : draw spot x
 #     y     : draw spot y
 #     width : width of the string
 #     height: height of the string
 #     text  : the text to draw
 #     center: 0 left align 1 center align 2 right align
 #     color : color of font
 #---------------------------------------------------------------------------
 def txt(x, y, width, height, text, center, color=0)
   font.color = Color.new(0,0,0,255)
   draw_text(x+1, y+1, width, height, text, center)
   if color > 0
     font.color = BST::COLORS[color]
   else
     # White
     font.color = Color.new(255,255,255,255)
   end
   draw_text(x, y, width, height, text, center)
 end
end



Instructions

Place above main.


Compatibility

No issues o.o


Credits and Thanks


  • Zexion




Author's Notes

Careful with syntax when adding colors, Lol!

G_G

*coughs* Look at Shaded Text in Tons of Add-ons *coughs*

Yours actually adds a couple of neat features, awesome job Zexion. :)