12-31-2021, 08:50 PM
(This post was last modified: 12-31-2021, 09:07 PM by kyonides.
Edit Reason: More Verbose Now
)
Bitmaps and Color Inversion
On another board people were working with a stripped down version of one of LittleDrago's scripts that featured the color inversion method. I disagreed with his implementation and the minimalistic version Roninator has published so I felt the need to code it the following way:
Code:
# * Color Inversion Script
# 2021-12-31
# - Warning! - #
# Inverting a bitmap's colors is a time consuming process.
# * Script Calls * #
# - Invert a bitmap entirely!
# some_sprite.bitmap.invert_colors!
# - Invert a window's text colors!
# some_window.contents.invert_colors!
# - Invert a windowskin's colors! # Use a duplicate of the windowskin!
# windowskin.invert_colors!
# - Temporary Color Change
# some_color.invert
# - Permanent Color Change
# some_color.invert!
class Color
def invert
Color.new(255 - red, 255 - green, 255 - blue, alpha)
end
def invert!
self.red = 255 - red
self.green = 255 - green
self.blue = 255 - blue
self
end
end
class Bitmap
def invert_colors!
width.times do |x|
height.times do |y|
clr = get_pixel(x, y)
set_pixel(x, y, clr.invert)
end
end
end
end
There's also a need to make a few fixes in his draw_item related methods.
Warning! You should NOT change a bitmap's colors directly!
It's always better to work with a duplicate or dup.
Why? Because bitmaps get cached by the engine.
Thus you might need to perform a color inversion every time you draw any face, no matter if the hero is dead or alive. Even if there's a slight possibility this might happen, it's better to avoid this color inversion madness from the very beginning.
VX ACE Window_MenuStatus Modification
Code:
class Window_MenuStatus
def draw_item(index)
actor = $game_party.members[index]
enabled = $game_party.battle_members.include?(actor)
rect = item_rect(index)
draw_item_background(index)
if actor.dead?
draw_actor_face_invert(actor, rect.x + 1, rect.y + 1, enabled)
else
draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
end
draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
end
def draw_actor_face_invert(actor, x, y, enabled = true)
draw_face_invert(actor.face_name, actor.face_index, x, y, enabled)
end
def draw_face_invert(face_name, face_index, x, y, enabled = true)
bitmap = Cache.face(face_name).dup
bitmap.invert_colors!
rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
bitmap.dispose
end
end
Keep in mind RMXP never sported any faces at all.
This means you'd need to include a custom script to make it possible in XP.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE