Additional Blend Types
written by me
written by me
This is a fun hack I've found many years back. It should work with every RGSS version so disregard that we're in the RGSS3 subforum. The used graphics library not only implements the 3 blend types (normal, add, sub) we all know and love but also 4 additional ones: multiply, screen, lighten, darken. Descriptions with examples can be found here and on many other websites. Maybe somebody out there has a use case for them.
Feel free to use the script in commercial projects or adapt the underlying concept to font sizes without having to credit me (I'd still appreciate it though).This script (written by me) circumvents the bad value check by temporarily pretending to be a “good” value. This is possible because the argument to #blend_type= is unnecessarily converted to a long (or int) two times: for the check and for the internal blend type assignment; and because the conversion function sends to_int to “unknown” objects.
Ruby:
# ★ Additional Blend Types
# ★★★★★★★★★★★★★★★★★
#
# Author/s : cremno
# RGSS ver : 1 to 3
# old: 0 = normal, 1 = addition, 2 = subtract
# new: 3 = multiply, 4 = screen, 5 = lighten, 6 = darken
class Blend_Type
def initialize(blend_type)
@blend_type = blend_type.to_i
@checked = false
end
def to_int
if @checked
@checked = false
@blend_type
else
@checked = true
@blend_type.between?(0, 6) ? 0 : @blend_type
end
end
end
[Plane, Sprite].each do |e|
e.class_eval do
alias cremno_blend_type= blend_type= unless $@
def blend_type=(blend_type)
self.cremno_blend_type = Blend_Type.new(blend_type)
rescue => e
raise e.class, e.message, e.backtrace[2..-1]
end
end
end
There isn't a demo but here's an example for XP:
Ruby:
$game_screen.pictures[id].show(filename, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
# Show Picture: 1, 'lightmap', Upper Left (0,0), (100%,100%), 192, Lighten
$game_screen.pictures[1].show('lightmap', 0, 0, 0, 100, 100, 192, 5)
For VX Ace use
screen instead of $game_screen. Check out this thread to get more information about how to use the equivalent of a specific event command in the Script... command.