じ☆ve冰风 发表于 2026-8-2 20:47:01

Additional Blend Types

Additional Blend Types
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 hereand on many other websites. Maybe somebody out there has a use case for them.
data/attachments/smilies/sharm/slime/LZSsmile.png 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.

Spoiler: Script                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

.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
    end
end
end


There isn't a demo but here's an example for XP:
                Ruby:       
$game_screen.pictures.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.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.


本贴来自国际rpgmaker官方论坛作者:cremnophobia处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/additional-blend-types.122566/
页: [1]
查看完整版本: Additional Blend Types