Main Menu
  • Welcome to The RPG Maker Resource Kit.

Bitmap Gradient for Bars

Started by Tsunokiette, April 06, 2006, 12:43:39 AM

0 Members and 1 Guest are viewing this topic.

Tsunokiette

Using a method I found on Dubealex to create a gradient, I created a method that allows you to create a gradient bar using 1 or more colors.

If using 1 color, it will obviously be a solid color.

But if you use 2 or more, it will automaticly calculate the width and gradient for each section creating a gradient using all the colors you supplied in order.

class Bitmap
def grade(x,y,width,height,start,finish)
for i in 0..width
r = start.red * (width - i) / width + finish.red * i / width
g = start.green * (width - i) / width + finish.green * i / width
b = start.blue * (width - i) / width + finish.blue * i / width
a = start.alpha * (width - i) / width + finish.alpha * i / width
fill_rect(x + i,y,1,height,Color.new(r, g, b, a))
end
end
def draw_gradient(x,y,width,height,colors)
gradient_width = ((width * 1.0) / (colors.size - 1))
    if colors.size == 1
      grade(x,y,width,height,colors[0],colors[0])
      return
    end
for i in 0..(colors.size - 2)
x_var = (x + (i * gradient_width))
grade(x_var,y,gradient_width,height,colors[i],colors[i + 1])
end
end
end


I created a simple hp bar using the above script as an example -

[code]class Window_Base < Window
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They're bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I'm the only one, I'm the only one."

Blizzard

Lol, remembers me of the scripts in my game.
:mrgreen: Shaft: "Of course it does. The gradient addition in your game IS Dubealex
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Tsunokiette

lol, to tell you the truth, it's taking me so long to work on the other scripts I'm working on, (I keep changing them), that I felt like I wasn't really producing anything.

Plus I wanted to feel special again lol, even if it was me simply updating a formula somebody else created.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They're bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I'm the only one, I'm the only one."

Blizzard

Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.



Get DropBox, the best free file syncing service there is!

Tyhan

According to your siggy you're an SDK user, right?  So is this SDK or non-SDK?

Zeriab


Tyhan

Oh, okay.  Awesome job, Tsunokiette.

haloOfTheSun

Moved to database to make Tsuno feel special.  :-D
:tinysmile:

Arrow

This is exactly what I need for an event I am making. Where does it get inserted into the script database?

itotetalakom

Severely una.rymh.rmrk.net.gqt.um anyone retransfusion kamagra jelly brahmi vardenafil 20 mg online finpecia finpecia for sale cialis vs viagra imuran generic rumalaya forte for sale price of lioresal callipers adenoma <a href="http://vintagepowderpuff.com/kamagra-jelly/">cheap kamagra</a> <a href="http://disasterlesskerala.org/brahmi/">brahmi without dr prescription</a> <a href="http://gaiaenergysystems.com/generic-levitra-20mg/">generic vardenafil 20mg</a> <a href="http://sbmitsu.com/finpecia/">finpecia without dr prescription</a> <a href="http://robots2doss.org/tadalafil-20mg-lowest-price/">tadalafil 20mg lowest price</a> <a href="http://myonlineslambook.com/imuran/">imuran without dr prescription</a> <a href="http://telugustoday.com/rumalaya/">generic rumalaya forte</a> rumalaya forte generic <a href="http://dallasmarketingservices.com/lioresal/">lioresal for sale</a> susceptibility coarser http://vintagepowderpuff.com/kamagra-jelly/ kamagra for sale kamagra oral jelly canada http://disasterlesskerala.org/brahmi/ brahmi http://gaiaenergysystems.com/generic-levitra-20mg/ levitra http://sbmitsu.com/finpecia/ finpecia http://robots2doss.org/tadalafil-20mg-lowest-price/ generic cialis http://myonlineslambook.com/imuran/ cheapest imuran http://telugustoday.com/rumalaya/ cheapest rumalaya liniment http://dallasmarketingservices.com/lioresal/ cheapest lioresal projected certification deposition.

afijukaqwr

City-dwellers kmy.jpxz.rmrk.net.dsk.ka progresses, occupancy buy prednisone online cipro naltrexone for sale naltrexone no prescription cialis prednisone loyalty narrower <a href="http://wellnowuc.com/buy-prednisone-online/">prednisone</a> <a href="http://ralstoncommunity.org/cipro/">cipro</a> <a href="http://dallasmarketingservices.com/naltrexone/">naltrexone no prescription</a> <a href="http://casatheodoro.com/cialis-5-mg/">cialis 10mg</a> <a href="http://wellnowuc.com/buying-prednisone-on-the-interent/">buying prednisone on the interent</a> socially http://wellnowuc.com/buy-prednisone-online/ prednisone http://ralstoncommunity.org/cipro/ ciprofloxacin hcl 500 mg antibiotics http://dallasmarketingservices.com/naltrexone/ naltrexone http://casatheodoro.com/cialis-5-mg/ cialis online http://wellnowuc.com/buying-prednisone-on-the-interent/ prednisone conduct remediable airway, hurts.