Bitmap
Update
Version 2.0
by Linkin_T, from RMXP.net
Here is the manual of how to use the Bitmap
Update Script Version 2. Note that each method is made INSIDE Bitmap, that I
haven’t changed any previous method, and that to make the effects you can only
call them once, and then they will be there until you discard the bitmap
object. And note that some functions are time-consuming. For that functions i
suggest to use them one on each frame, or your game graphics will not be
updated correctly and get the risk of closing. Read the Graphics.update
description to understand it better. On further versions I hope to let the
script more dynamic and fast.
In this manual I’ll grant each method with some
stars. This will represent the risk that they cause to your game’s graphics
update, and that way you can use them without problems. Below is the Star Rank:
(none) –
Don’t worry, use it without moderation ^_^
(*) – One
star. You can call more than one on a frame, but it will slow a little (very
little) your script.
(**) – Two stars.
Take care... Don’t use them so much on a frame. They will slow your script.
(***) –
Three stars. Don’t use more than one method on a frame, or your game will stop.
This function will slow considerably your script.
Maybe my computer is a little bit slow, and
some of you may test it and sense no latency or slow on the code itself… To
speak the truth, my computer is shameless… ¬¬
Now the list of Methods, separated into groups:
Text Group, Image Group, Geometry Group,
Utility Group and Bitmap Group. A brief explanation of them:
Text
Group – Holds
effects and utilities made for improve the text drawing in the game.
·
Draw
Blur Text (from * to **)
·
Draw
Shining Text (from * to **)
·
Draw
Light Text (from * to **)
·
Draw
Dark Text (from * to **)
·
Draw
Outline Text (none)
·
Draw
Shadow Text (none)
Bitmap
Group – Functions
that have its scope on the whole bitmap, making changes not only in a part of
it.
·
Tone
(from * to **)
·
Tint
(from none to **)
·
Invert
(from * to **)
·
Opacity
(from * to **)
·
Force
Opacity (from * to **)
Geometry
Group – Functions
that results on geometry images inside the bitmap.
·
Draw
Circle (from * to **, depending on the size of the radius)
·
Draw
Gradient Rect (from none to *)
Image
Group – Supposed to
improve the way that another pictures are included on bitmap with effects and
more.
·
·
Tone
(from * to ***)
·
Tint
(from * to ***)
·
Light
Blur (from * to ***, depending (A LOT) on the size of the image taken)
·
Dark
Blur (from * to ***, depending (A LOT) on the size of the image taken)
·
Invert
Colors (from * to ***)
Utility
Group – Functions
that can help the scripter on some way, not only on pictures or texts.
·
Get
Average Pixel (none)
·
Horizontal
Progress Bar (from none to *)
·
Vertical
Progress Bar (from none to *)
Text Group
The text group was made to look like the
draw_text method of the Bitmap class. Arguments inside [] are not necessary and
can be disconsidered. For the examples above, the font used was Tahoma 22, bold,
color (red 200, green 150, blue 120, alpha 255). The screenshots were resized
to 200% of its original sizes. All the examples of the Text Group can be seen
if you create a new event on map and paste this code inside it. Then execute
the event.
Draw
Blur Text
One method, text
scope. This method draws
a coloured blur behind a text, based on the color of the text itself. This
method will not alter the font color on the bitmap. Similar to draw_text.
USE:
draw_blur_text(x, y, width, height,
text, [blur_size ,[text_align]])
draw_blur_text(rect, text, [blur_size
,[text_align]])
DESCRIPTION:
x, y, width, height – Defines the
position of the text inside the bitmap. Integers.
rect – Similar to the item above.
Rect.
text – Text to be drawn on the
bitmap. String.
blur_size – Size of the blur, in
pixels. Higher values slows more a script that calls this method. The default
is 4. Integer.
text_align – Text aligning.
Horizontal text is left-aligned by default; set text_align to 1 to center the text
and to 2 to right-align it. Vertical text is always centered. Integer.
SCREEN:
CODE: bitmap.draw_blur_text(rect,"Blur
Effect",6,1)
Draw
Shining Text
One method, text
scope. This method
draws a coloured blur behind a text, based on the color of the text itself. This
method will not alter the font color on the bitmap. The inverse of
draw_blur_text.
USE:
draw_shining_text(x, y, width,
height, text, [blur_size ,[text_align]])
draw_shining_text(rect, text, [blur_size
,[text_align]])
DESCRIPTION:
x, y, width, height – Defines the
position of the text inside the bitmap. Integers.
rect – Similar to the item above.
Rect.
text – Text to be drawn on the
bitmap. String.
blur_size – Size of the blur, in
pixels. Higher values slows more a script that calls this method. The default
is 4. Integer.
text_align – Text aligning.
Horizontal text is left-aligned by default; set text_align to 1 to center the text
and to 2 to right-align it. Vertical text is always centered.
SCREEN:
CODE:
bitmap.draw_shining_text(rect,"Shining Effect",6,1)
Draw Light
Text
One method, text
scope. This method
draws a coloured blur behind a text, and the blur color is given by the user.
This color will be lightened. This method will not alter the font color on the
bitmap.
USE:
draw_light_text(x, y, width, height,
text, [blur_size , [color, [text_align]]])
draw_light_text(rect, text, [blur_size
, [color, [text_align]]])
DESCRIPTION:
x, y, width, height – Defines the
position of the text inside the bitmap. Integers.
rect – Similar to the item above.
Rect.
text – Text to be drawn on the
bitmap. String.
blur_size – Size of the blur, in
pixels. Higher values slows more a script that calls this method. The default
is 4. Integer.
color – Color to be used on the
blur. Color.
text_align – Text aligning.
Horizontal text is left-aligned by default; set text_align to 1 to center the text
and to 2 to right-align it. Vertical text is always centered. Integer.
SCREEN:
The color used was the inverse of
the font color (red 55, green 105, blue 135, alpha 255).
CODE: bitmap.draw_light_text(rect,"Custom
Light Blur",6,Color.new(55,105,135),1)
Draw Dark
Text
One method, text
scope. This method
draws a coloured blur behind a text, and the blur color is given by the user.
This color will be darkened. This method will not alter the font color on the
bitmap.
USE:
draw_dark_text(x, y, width, height,
text, [blur_size , [color, [text_align]]])
draw_dark_text(rect, text, [blur_size
, [color, [text_align]]])
DESCRIPTION:
x, y, width, height – Defines the
position of the text inside the bitmap. Integers.
rect – Similar to the item above.
Rect.
text – Text to be drawn on the
bitmap. String.
blur_size – Size of the blur, in
pixels. Higher values slows more a script that calls this method. The default
is 4. Integer.
color – Color to be used on the
blur. Color.
text_align – Text aligning.
Horizontal text is left-aligned by default; set text_align to 1 to center the text
and to 2 to right-align it. Vertical text is always centered. Integer.
SCREEN:
The color used was the inverse of
the font color (red 55, green 105, blue 135, alpha 255).
CODE: bitmap.draw_dark_text(rect,"Custom
Dark Blur",6,Color.new(55,105,135),1)
Draw Outline
Text
One method, text
scope. This method outlines
a text, and the line color is given by the user. This method will not alter the
font color on the bitmap.
USE:
draw_outline_text(x, y, width,
height, text, [line_color, [text_align]]])
draw_outline_text(rect, text, [line_color,
[text_align]]])
DESCRIPTION:
x, y, width, height – Defines the
position of the text inside the bitmap. Integers.
rect – Similar to the item above.
Rect.
text – Text to be drawn on the
bitmap. String.
color – Color to be used on the line.
Color.
text_align – Text aligning.
Horizontal text is left-aligned by default; set text_align to 1 to center the text
and to 2 to right-align it. Vertical text is always centered.
SCREEN:
CODE: bitmap.draw_outline_text(rect,"Outline
Effect",Color.new(0,0,0),1)
Draw Shadow
Text
One method, text
scope. Will create
a shadow behind a text. The user can give the direction of the shadow, and the
color used on it is based on the font color. This method will not alter the
font color on the bitmap.
USE:
draw_shadow_text(x, y, width,
height, text, [direction, [text_align]]])
draw_shadow_text(rect, text, [direction,
[text_align]]])
DESCRIPTION:
x, y, width, height – Defines the
position of the text inside the bitmap. Integers.
rect – Similar to the item above.
Rect.
text – Text to be drawn on the
bitmap. String.
direction – Direction of the shadow.
Based on the character movement and, for easy reference, the user can see the
direction of the shadow on the numpad. 5 is where the text is and the numbers
from 1 to 9 indicates the direction of the shadow. Integer.
text_align – Text aligning. Horizontal
text is left-aligned by default; set text_align to 1 to center the text and to 2 to right-align it.
Vertical text is always centered. Integer.
SCREEN:
CODE:
bitmap.draw_shadow_text(rect,"Shadow on: #{pos}",pos,1)
Geometry Group
The text group was made to hold some functions
that Enterbrain should release with Bitmap class as default, as drawing
gradient-coloured rects and circles ^^. Arguments inside [] are not necessary
and can be disconsidered. All the examples of the Text Group can be seen if you
create a new event on map and paste the code on each method description inside
it. Then execute the event.
Draw Circle
Two methods, drawing
scope. This method
will draw a circle on the bitmap, starting on the given position and with the
given radius and line color and size. The user can even create a circle that is
filled with a color. This function still needs a little improvement, despite
that it works as expected. On further versions, the user may be capable of
drawing semi-circles or elipses.
USE:
draw_circle (ox, oy, radius, [color, [size, [fill_color]]])
DESCRIPTION:
ox and oy – Defines the position of
the circle, from where the radius will take its origin. Integers.
radius – Radius of the circle, in
pixels. This value cannot be less than 1, and greater values can slow the
script from where this method have been called. Integer.
color – Color that will be used to
draw the circle´s line. If fill_color is true, this color will be used to fill
the circle too. Color.
size – Size of the circle´s size, in
pixels. Integer.
fill_color – Flag that indicates if
the color used to draw the line will be used to fill the circle. True/False.
SCREEN:
CODE:
Fill
Gradient Rect
One method, drawing
scope. This method
will draw a rectangle on the bitmap, and it will be filled with two mixed
colors, in gradient. Note that this method is not from my authory. This piece
of code was taken here,
I just made some alterations to make it look more like the fill_rect. I think
the name of the author is Cogwheel. So confusing… Give credits to the site
then... ^^
USE:
fill_gradient_rect(x, y, width, height, [color1,
[color2, [align]]])
fill_gradient_rect(rect, [color1, [color2, [align]]])
DESCRIPTION:
x, y, width, height – Defines the
position of the rectangle. Integers.
rect – Makes the same of the item
above. Rect.
color1 – Starting color of the
rectangle. Color.
color2 – Ending color of the
rectangle. Color.
align – Direction of the gradient
effect. When 0 and 1 gives this method no stars, but 2 and 3 gives one star. 0
and 1 makes a horizontal gradient, and 2 and 3 a diagonal effect. Look at the
screen, you´ll have an idea. Integer
SCREEN:
CODE:
Bitmap Group
Some characteristics of a bitmap can be altered
only if you mess up with Sprites, like tone and opacity. With this update the
user can alter that witout needing to make all that process. That way you can
pass a (fully ^^) complete bitmap. All the alterations made with this group are
definitive inside the bitmap. Some of the scripters will find this group a
little bit futile, or needless…
This group was initially made to support some
functions used on the Image Group, but the user can use them too if needed. On
this group the size of the bitmap is decisive for the star’s game’s latency
reference, where the latency is bigger as long as the bitmap’s size is big too.
Arguments inside [] are not necessary and can be disconsidered. All the
examples of the Text Group can be seen if you create a new event on map and
paste the code on each method description inside it. Then execute the event.
Tone
One method, bitmap
scope. This method
will alter the bitmap color based on the color given. Basically it makes an
average between all the pixel colors and the color given, and after it defines
the new color of the pixel. The method ignores transparent pixels (alpha equal
to 0). Evaluates each pixel and works with all the channels.
USE:
tone([color])
DESCRIPTION:
color – Defines the color used to
make the tone effect. Color.
SCREEN:
CODE:
Tint
One method, bitmap
scope. This method
will alter the bitmap color based on the color given. It simply substitute
every pixelp that’s not invisible (alpha equal to 0) by the color given.
Evaluates each pixel and works with all the channels.
USE:
tint([color])
DESCRIPTION:
color – Defines the color used to
make the tint effect. Color.
SCREEN:
CODE:
Invert
Colors
One method, bitmap
scope. This method
will invert all the channels of the pixels inside the bitmap. Evaluates each
pixel and can invert alpha channel too if the user wants to.
USE:
invert([invert_alpha])
DESCRIPTION:
invert_alpha – Flag indicating if
the alpha channel will be changed. True/False.
SCREEN:
CODE:
Opacity
One method, bitmap
scope. This method
will alter the bitmap opacity based on the value given. It makes an average
between the alpha value of each pixel and redefine it. This method ignores
invisible pixels (alpha equal to 0) by the color given. Works only with the
alpha channels.
USE:
opacity([value])
DESCRIPTION:
value – The opacity alteration,
given in a range from -255 to 255. Values out of range are corrected. Remember
that the calculation is pixel alpha + value / 2. Integer.
SCREEN:
CODE:
Force
Opacity
One method, bitmap
scope. This method
will alter the bitmap opacity based on the value given. Simply equals the alpha
value of each pixel to the value passed, and that way forcing a opacity effect
independent from the pixels’ alpha values. Take special care on using this
method, because it can destroy any effect on the bitmap that’s based on alpha
values someway. Works only with the alpha channels.
USE:
opacity([value])
DESCRIPTION:
value – The opacity alteration,
given in a range from 0 to 255. Values out of range are corrected. Integer.
SCREEN:
CODE:
Looks the same as Opacity but this battler seems to use little of alpha channels.
Picture Group
After the Text group and the Utility group, I
think that this is the most useful group. This group holds functions similars
to the default bitmap´s block transfer methods (blt and stretch_blt). The
difference is that you can make a block transfers with effects, stretching or
not the image passed. There are a lot of effects here, and I hope to include
more ^_^
Pay much attention when using this group. This
is the most critical group when talking about the lag. Bigger pictures brings
bigger lags to your game and even bigger possibilities of occure the graphics’
“run-out”.
Arguments inside [] are not necessary and can
be disconsidered. All the examples of the Text Group can be seen if you create
a new event on map and paste the code on each method description inside it.
Then execute the event. Note that between each command you MUST put a 1-frame
wait, to avoid the Graphics.update “run-out”. Below is a picture comparing all
the effects. All of them were made with the same color (red 255, green 0, blue
0, alpha 0), with opacity in 200. I put a background on map and after I put
inside the sprite´s bitmap the battlers, as you can see. From the left to the
right: hue_blt, tone_blt, tint_blt, light_blt and dark_blt.
And below is all the code, and don’t forget about the 1-frame wait command:
WAIT 1 FRAME
WAIT 1 FRAME
WAIT 1 FRAME
WAIT 1 FRAME
WAIT 1 FRAME
Two methods, picture
scope. This method
will put a new picture inside the bitmap, and before that it change its hue to
the degree passed.
USE:
non-stretching method:
hue_blt(x, y, src_bitmap, src_rect,
[hue, [opacity]])
stretching method:
hue_stretch_blt(dest_rect,
src_bitmap, src_rect, [hue, [opacity]])
DESCRIPTION:
x, y – Position inside the bitmap
that the new bitmap will be placed. Integers
dest_rect – Refers to the position
and the size that the picture taken from src_bitmap will occupy inside the
bitmap. If the dest_rect’s size (width and height) is different from the
src_rect’s size, the picture will be resized (in the stretching mode). Rect.
src_bitmap – Picture to be placed
inside the bitmap. It can be cutted or resized, depending on the method and on
the size of src_rect and dest_rect. Bitmap.
src_rect – Part of the src_bitmap to
be taken, and after placed inside the bitmap. If the src_rect’s size is less
than src_bitmap´s size, src_bitmap will be cutted. Rect.
hue – Value, in degrees, to the
src_bitmap’s hue change. Integer.
opacity – Value of the opacity to be
considered when taking the src_bitmap to the bitmap. Can be set from 0 to 255.
Integer.
SCREEN:
CODE:
WAIT 1 FRAME
WAIT 1 FRAME
Tone
Two methods, picture
scope. This method
will put a new picture inside the bitmap, and before that it makes a tone
change based on a passed color.
USE:
non-stretching method:
tone_blt(x, y, src_bitmap, src_rect,
[color, [opacity]])
stretching method:
tone_stretch_blt(dest_rect,
src_bitmap, src_rect, [color, [opacity]])
DESCRIPTION:
x, y – Position inside the bitmap
that the new bitmap will be placed. Integers
dest_rect – Refers to the position
and the size that the picture taken from src_bitmap will occupy inside the
bitmap. If the dest_rect’s size (width and height) is different from the
src_rect’s size, the picture will be resized (in the stretching mode). Rect.
src_bitmap – Picture to be placed
inside the bitmap. It can be cutted or resized, depending on the method and on
the size of src_rect and dest_rect. Bitmap.
src_rect – Part of the src_bitmap to
be taken, and after placed inside the bitmap. If the src_rect’s size is less
than src_bitmap´s size, src_bitmap will be cutted. Rect.
color – Defines the color used to
make the tone effect. Color.
opacity – Value of the opacity to be
considered when taking the src_bitmap to the bitmap. Can be set from 0 to 255. Integer.
SCREEN:
CODE:
WAIT 1 FRAME
WAIT 1 FRAME
Tint
Two methods, picture
scope. This method
will put a new picture inside the bitmap, and before that it substitute any
non-invisible pixel with the color passed (same as the effect Tint on Bitmap
Group).
USE:
non-stretching method:
tint_blt(x, y, src_bitmap, src_rect,
[color, [opacity]])
stretching method:
tint_stretch_blt(dest_rect,
src_bitmap, src_rect, [color, [opacity]])
DESCRIPTION:
x, y – Position inside the bitmap
that the new bitmap will be placed. Integers
dest_rect – Refers to the position
and the size that the picture taken from src_bitmap will occupy inside the
bitmap. If the dest_rect’s size (width and height) is different from the
src_rect’s size, the picture will be resized (in the stretching mode). Rect.
src_bitmap – Picture to be placed
inside the bitmap. It can be cutted or resized, depending on the method and on
the size of src_rect and dest_rect. Bitmap.
src_rect – Part of the src_bitmap to
be taken, and after placed inside the bitmap. If the src_rect’s size is less
than src_bitmap´s size, src_bitmap will be cutted. Rect.
color – Defines the color used to
make the tint effect. Color.
opacity – Value of the opacity to be
considered when taking the src_bitmap to the bitmap. Can be set from 0 to 255.
Integer.
SCREEN:
CODE:
WAIT 1 FRAME
WAIT 1 FRAME
Invert
Colors
Two methods, picture
scope. This method
will put a new picture inside the bitmap, and before that it will invert all
the colors of the new picture (same as the effect Invert on Bitmap Group).
USE:
non-stretching method:
invert_blt(x, y, src_bitmap,
src_rect, [alpha, [opacity]])
stretching method:
invert_stretch_blt(dest_rect,
src_bitmap, src_rect, [alpha, [opacity]])
DESCRIPTION:
x, y – Position inside the bitmap
that the new bitmap will be placed. Integers
dest_rect – Refers to the position and
the size that the picture taken from src_bitmap will occupy inside the bitmap.
If the dest_rect’s size (width and height) is different from the src_rect’s
size, the picture will be resized (in the stretching mode). Rect.
src_bitmap – Picture to be placed
inside the bitmap. It can be cutted or resized, depending on the method and on
the size of src_rect and dest_rect. Bitmap.
src_rect – Part of the src_bitmap to
be taken, and after placed inside the bitmap. If the src_rect’s size is less
than src_bitmap´s size, src_bitmap will be cutted. Rect.
alpha – Flag indicating if the alpha
channel will be changed. True/False.
opacity – Value of the opacity to be
considered when taking the src_bitmap to the bitmap. Can be set from 0 to 255.
Integer.
SCREEN:
CODE:
WAIT 1 FRAME
WAIT 1 FRAME
Try to select this image and you’ll
see that the battlers are really inverse, it’s an awesome effect ^^
ATTENTION: The two methods above are the most
critical methods inside the Picture Group, so use them with care. They’re
time-consuming. Try to use them with small and medium sized bitmaps, and try to
avoid using them on screen-sized images, like fog, battlebacks or else… If you
resolve to use then, use a lower value for blur_size, this may reduce a little
the lag (this helps a lot, on any case). Using them on some cases that the
script redraws its bitmap on every frame will give a monster-lag ^^ So I
recommend you to make a special bitmap containing the picture with the effect
and make the old blt or stretch_blt to put it inside your bitmap. The size of
the bitmap must be that:
New Width = bitmap width + (blur size * 2)
New Height = bitmap height + (blur size * 2)
Then make a new bitmap containing your image.
Then call the blt’s special effect you want passing this position and all the
image.
Position X = blur_size / 2
Position Y = blur_size / 2
After that you may have all your image with an
effect inside another bitmap. All you must do now is to call the simple blt or
stretch_blt to put this image inside your bitmap. To make the screens below I
had to give a Graphics.update on each blur evaluation. I’ve said that before
and I’ll say again, my computer is shameless… ¬¬
Light
Blur
Two methods, picture
scope. This method
will put a new picture inside the bitmap, and before that it will make a blur
effect behind the picture (looks like the Light Blur effect on Text Group).
USE:
non-stretching method:
light_blt(x, y, src_bitmap,
src_rect, [blur_size, [color, [opacity]]])
stretching method:
light_stretch_blt(dest_rect,
src_bitmap, src_rect, [blur_size, [color, [opacity]]])
DESCRIPTION:
x, y – Position inside the bitmap
that the new bitmap will be placed. Integers
dest_rect – Refers to the position
and the size that the picture taken from src_bitmap will occupy inside the
bitmap. If the dest_rect’s size (width and height) is different from the
src_rect’s size, the picture will be resized (in the stretching mode). Rect.
src_bitmap – Picture to be placed
inside the bitmap. It can be cutted or resized, depending on the method and on
the size of src_rect and dest_rect. Bitmap.
src_rect – Part of the src_bitmap to
be taken, and after placed inside the bitmap. If the src_rect’s size is less
than src_bitmap´s size, src_bitmap will be cutted. Rect.
blur_size – Size of the effect, in
pixels. Try using values less than 10 to avoid lag. Integer.
color – Color to be used on the
effect. Color.
opacity – Value of the opacity to be
considered when taking the src_bitmap to the bitmap. Can be set from 0 to 255.
Integer.
SCREEN:
CODE:
WAIT 1 FRAME
WAIT 1 FRAME
Dark
Blur
Two methods, picture
scope. This method
will put a new picture inside the bitmap, and before that it will make a blur
effect behind the picture (looks like the Dark Blur effect on Text Group).
USE:
non-stretching method:
light_blt(x, y, src_bitmap,
src_rect, [blur_size, [color, [opacity]]])
stretching method:
light_stretch_blt(dest_rect,
src_bitmap, src_rect, [blur_size, [color, [opacity]]])
DESCRIPTION:
x, y – Position inside the bitmap
that the new bitmap will be placed. Integers
dest_rect – Refers to the position
and the size that the picture taken from src_bitmap will occupy inside the
bitmap. If the dest_rect’s size (width and height) is different from the
src_rect’s size, the picture will be resized (in the stretching mode). Rect.
src_bitmap – Picture to be placed
inside the bitmap. It can be cutted or resized, depending on the method and on
the size of src_rect and dest_rect. Bitmap.
src_rect – Part of the src_bitmap to
be taken, and after placed inside the bitmap. If the src_rect’s size is less
than src_bitmap´s size, src_bitmap will be cutted. Rect.
blur_size – Size of the effect, in
pixels. Try using values less than 10 to avoid lag. Integer.
color – Color to be used on the
effect. Color.
opacity – Value of the opacity to be
considered when taking the src_bitmap to the bitmap. Can be set from 0 to 255.
Integer.
SCREEN:
CODE:
WAIT 1 FRAME
WAIT 1 FRAME
Utility Group
This group is the one with methods that doesn’t
fit any other. At the same time, this group is one of the most useful groups
because of its utilities, like progress bar and averaged pixel colors.
Arguments inside [] are not necessary and can
be disconsidered. All the examples of the Utility Group can be seen if you
create a new event on map and paste the code on each method description inside
it. Then execute the event.
Average
Pixel Color
One method, pixel
scope. This method
will get an average color between the selected pixel and the surrounding
pixels.
USE:
get_average_pixel(x, y [, area])
DESCRIPTION:
x, y – Coordinates of the pixel
inside the bitmap. Integers.
area – Size of the surrounding area
that will be taken from the bitmap to make that color average. The area is a
perfect square, since you can only pass odd values to this argument. If you
pass an value less than or equal to 1, it will simply take the selected pixel
color, and if you pass an even number, the method will try to transform it in a
odd number, but if it stays less than 3 it will take only that pizel color too.
Integer.
SCREEN:
No need for screens here…
Progress
Bar
Four methods, utility
scope. One of the
most useful methods. This creates a progress bar in the position and with the
size passed. The bar can be taken out from the bitmap when needed, and it will
not alter the bitmap itself. Altering it will not need to erase the bitmap and
redraw it (i.e. modifying the progress, changing the bar’s color, flashing the
bar, etc). Just make sure to change the bar’s status periodically if you want
to make some effect on it. The changes are instant.
The progress bar utility is split into two
distinct parts: the horizontal and the vertical bars. Have this in mind when
working with this utility. So, explaining one of them is sufficient, since the
methods used for both are simply equal.
The thing that identifies the bar is its
position and size. In truth this identification is a sum of all the values of
its position and size (x position + y position + width + height). Just avoid
creating two bars with the same position and size, because the second will
overlap the first.
Also, the brightness of the bar’s contents
changes according to the actual progress value. The more greater it is, more
bright the content will have.
USE:
Horizontal Bar:
Method used to create the Bar:
horz_progress_bar(x, y, width,
height, progress, i_color, f_color, b_color[, opacity[, flash[, hue]]])
horz_progress_bar(rect, progress[, i_color[,
f_color[, b_color[, opacity[, flash[, hue]]]]]])
Method used to update minor things
of the Bar:
update_horz_progress_bar(x, y,
width, height[, size[, opacity[, flash[, hue]]]])
update_horz_progress_bar(rect[,
size[, opacity[, flash[, hue]]]])
Method used to heavily modify the
Bar:
modify_horz_progress_bar(x, y, width, height[,
progress[, i_color[, f_color[, b_color[, opacity[, flash[, hue]]]]]]])
modify_horz_progress_bar(rect[, progress[,
i_color[, f_color[, b_color[, opacity[, flash[, hue]]]]]]])
Method used to delete the Bar from
the bitmap:
delete_horz_progress_bar(x, y,
width, height)
delete_horz_progress_bar(rect)
Vertical Bar:
Method used to create the Bar:
vert_progress_bar(x, y, width,
height, progress, i_color, f_color, b_color[, opacity[, flash[, hue]]])
vert_progress_bar(rect, progress[, i_color[,
f_color[, b_color[, opacity[, flash[, hue]]]]]])
Method used to update/modify minor
things of the Bar:
update_vert_progress_bar(x, y,
width, height[, size[, opacity[, flash[, hue]]]])
update_vert_progress_bar(rect[,
size[, opacity[, flash[, hue]]]])
Method used to heavily modify the
Bar:
modify_vert_progress_bar(x, y, width, height[,
progress[, i_color[, f_color[, b_color[, opacity[, flash[, hue]]]]]]])
modify_vert_progress_bar(rect[, progress[,
i_color[, f_color[, b_color[, opacity[, flash[, hue]]]]]]])
Method used to delete the Bar from
the bitmap:
delete_vert_progress_bar(x, y,
width, height)
delete_vert_progress_bar(rect)
DESCRIPTION:
x, y, width, height – Position and
size of the bar inside the bitmap. Also, the identifier of the bar. Integers.
rect – Same as the item above. Rect.
>>>
The arguments above can be skipped on the modifier methods if you pass a nil
value. That way, if you pass nil the
method will recognize that you don’t
want to change that property of the bar. For example, you want to
change the progress but don´t want to change the opacity… That way you pass the
new progress value and pass nil as the opacity value, and the method will alter
just the progress. Hope you’ve understood then…
progress – The progress status, from
0 to 100%. Float or Integer.
i_color – Starting color of the
progress bar’s contents, used on the gradient color effect. Color.
f_color – Finishing color of the
progress bar’s contents, used on the gradient color effect. Color.
b_color – Color to be used on the
bar’s lines. Also, it’s combinated with i_color and f_color to give the bar’s
background color. Color.
opacity – Opacity of the bar. Pass a
value between 0 and 255. Integer.
flash – Color to be used on a flash
effect. Applies only in the bar’s contents. Passing false will take off the flash effect. Color or False.
hue – The hue change of the bar. Pas
a value between 0 and 360. Integer.
SCREEN:
CODE:
WAIT 3 FRAMES
WAIT 3 FRAMES
WAIT 20 FRAMES
WAIT 3 FRAMES
WAIT 3 FRAMES
WAIT 3 FRAMES
WAIT 3 FRAMES
WAIT 3 FRAMES
WAIT 20 FRAMES
WAIT 3 FRAMES
WAIT 40 FRAMES
WAIT 50 FRAMES
No need for screens here… Recommend to test
this code and see yourself. The code given can be done for horizontal bar too,
just substitute all the vert with horz.
Code
Above is the complete code. Just create a new
script on top of all scripts and put it there. HERE YOU GO!
#------------------------------------------------------------------
# § Bitmap Update Version 2 § by Linkin_T
#------------------------------------------------------------------
# This update includes more font effects, like blur,
shading,
# lightnings and some picture utilities.
#
#------------------------------------------------------------------
class Bitmap
#================================================================
# BEGINNING OF
TEXT GROUP
#================================================================
#----------------------------------------------------------------
# > Draw
Blur Text
#----------------------------------------------------------------
def
draw_blur_text(pos_x,pos_y,w=4,h=0,str="",size=4,text_align=0)
if
pos_x.is_a?(Rect)
x =
pos_x.x
y =
pos_x.y
width = pos_x.width
height =
pos_x.height
text =
pos_y
blur_size
= w
align = h
else
x = pos_x
y = pos_y
width = w
height = h
text = str
blur_size
= size
align =
text_align
end
if blur_size
< 0
blur_size
= 0
end
if blur_size
== 0
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
else
previous_color = self.font.color.clone
color =
self.font.color.clone
for i in
1..blur_size
mod =
1.5*(i.to_f/(blur_size.to_f+1))
r =
color.red * mod
g =
color.green * mod
b =
color.blue * mod
a =
color.alpha * mod
color.set((color.red+r)/2,(color.green+g)/2,(color.blue+b)/2,((color.alpha/1.5).to_i+a)/2)
self.font.color = color
for
mod_x in 1..i
mod_x
= (x-(blur_size/2))+mod_x
mod_w
= width
for
mod_y in 1..i
mod_y = (y-(blur_size/2))+mod_y
mod_h = height
if
align == 0
draw_text(mod_x,mod_y,mod_w,mod_h,text)
else
draw_text(mod_x,mod_y,mod_w,mod_h,text,align)
end
end
end
end
self.font.color = previous_color.clone
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
end
end
#----------------------------------------------------------------
# > Draw
Shining Text
#----------------------------------------------------------------
def
draw_shining_text(pos_x,pos_y,w=4,h=0,str="",size=4,text_align=0)
if
pos_x.is_a?(Rect)
x =
pos_x.x
y =
pos_x.y
width =
pos_x.width
height = pos_x.height
text =
pos_y
blur_size
= w
align = h
else
x = pos_x
y = pos_y
width = w
height = h
text = str
blur_size
= size
align =
text_align
end
if blur_size
< 0
blur_size = 0
end
if blur_size
== 0
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
else
previous_color = self.font.color.clone
color =
self.font.color.clone
for i in
1..blur_size
mod =
(i.to_f/(blur_size.to_f+1))
r =
color.red * (mod * 2.5)
g =
color.green * (mod * 2.5)
b =
color.blue * (mod * 2.5)
a =
color.alpha * (mod * 1.5)
color.set((color.red+r)/2,(color.green+g)/2,(color.blue+b)/2,((color.alpha/1.5).to_i+a)/2)
self.font.color = Color.new(r.to_i,g.to_i,b.to_i,a.to_i)
for
mod_x in 1..i
mod_x
= (x-(blur_size/2))+mod_x
mod_w
= width
for
mod_y in 1..i
mod_y = (y-(blur_size/2))+mod_y
mod_h = height
if
align == 0
draw_text(mod_x,mod_y,mod_w,mod_h,text)
else
draw_text(mod_x,mod_y,mod_w,mod_h,text,align)
end
end
end
end
self.font.color = previous_color.clone
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
end
end
#----------------------------------------------------------------
# > Draw
Light Text
#----------------------------------------------------------------
def
draw_light_text(pos_x,pos_y,w=4,h=Color.new(0,0,0),str=0,size=4,blur_color=Color.new(0,0,0),text_align=0)
if
pos_x.is_a?(Rect)
x =
pos_x.x
y =
pos_x.y
width =
pos_x.width
height =
pos_x.height
text =
pos_y
blur_size
= w
color = h
align =
str
else
x = pos_x
y = pos_y
width = w
height = h
text = str
blur_size
= size
color =
blur_color
align =
text_align
end
if blur_size
< 0
blur_size
= 0
end
if blur_size
== 0
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
else
previous_color = self.font.color.clone
for i in
1..blur_size
mod =
(i.to_f/(blur_size.to_f+1))
r =
color.red * (mod * 2.5)
g =
color.green * (mod * 2.5)
b =
color.blue * (mod * 2.5)
a =
color.alpha * (mod * 1.5)
color.set(color.red,color.green,color.blue,((color.alpha/1.5).to_i+a)/2)
self.font.color = Color.new(r.to_i,g.to_i,b.to_i,a.to_i)
for
mod_x in 1..i
mod_x
= (x-(blur_size/2))+mod_x
mod_w
= width
for
mod_y in 1..i
mod_y = (y-(blur_size/2))+mod_y
mod_h = height
if
align == 0
draw_text(mod_x,mod_y,mod_w,mod_h,text)
else
draw_text(mod_x,mod_y,mod_w,mod_h,text,align)
end
end
end
end
self.font.color = previous_color.clone
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
end
end
#----------------------------------------------------------------
# > Draw
Dark Text
#----------------------------------------------------------------
def
draw_dark_text(pos_x,pos_y,w=4,h=Color.new(255,255,255),str=0,size=4,blur_color=Color.new(255,255,255),text_align=0)
if
pos_x.is_a?(Rect)
x =
pos_x.x
y =
pos_x.y
width =
pos_x.width
height =
pos_x.height
text =
pos_y
blur_size
= w
color = h
align =
str
else
x = pos_x
y = pos_y
width = w
height = h
text = str
blur_size
= size
color =
blur_color
align =
text_align
end
if blur_size
< 0
blur_size
= 0
end
if blur_size
== 0
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
else
previous_color = self.font.color.clone
for i in
1..blur_size
mod =
1.5*(i.to_f/(blur_size.to_f+1))
r =
color.red * mod
g =
color.green * mod
b =
color.blue * mod
a =
color.alpha * mod
color.set(color.red,color.green,color.blue,((color.alpha/1.5).to_i+a)/2)
self.font.color = color
for
mod_x in 1..i
mod_x
= (x-(blur_size/2))+mod_x
mod_w
= width
for
mod_y in 1..i
mod_y = (y-(blur_size/2))+mod_y
mod_h = height
if
align == 0
draw_text(mod_x,mod_y,mod_w,mod_h,text)
else
draw_text(mod_x,mod_y,mod_w,mod_h,text,align)
end
end
end
end
self.font.color = previous_color.clone
if align
== 0
draw_text(x,y,width,height,text)
else
draw_text(x,y,width,height,text,align)
end
end
end
#----------------------------------------------------------------
# > Draw
Shadow Text
#----------------------------------------------------------------
def
draw_shadow_text(pos_x,pos_y,w=3,h=0,str="",direction=3,text_align=0)
if
pos_x.is_a?(Rect)
x =
pos_x.x
y =
pos_x.y
width =
pos_x.width
height =
pos_x.height
text =
pos_y
shadow_direction = w
align = h
else
x = pos_x
y = pos_y
width = w
height = h
text = str
shadow_direction = direction
align =
text_align
end
last_color =
self.font.color.clone
color =
self.font.color.clone
color.set(color.red/4,color.green/4,color.blue/4,(color.alpha*0.75).to_i)
self.font.color = color
case
shadow_direction
when 1
mod_m_x =
x-2
mod_m_y =
y+1
mod_p_x =
x-1
mod_p_y =
y+2
when 2
mod_m_x =
x
mod_m_y =
y+1
mod_p_x =
x
mod_p_y =
y+2
when 3
mod_m_x =
x+1
mod_m_y =
y+1
mod_p_x =
x+2
mod_p_y =
y+2
when 4
mod_m_x =
x-2
mod_m_y =
y
mod_p_x =
x-1
mod_p_y =
y
when 6
mod_m_x =
x+1
mod_m_y =
y
mod_p_x =
x+2
mod_p_y =
y
when 7
mod_m_x =
x-2
mod_m_y =
y-2
mod_p_x =
x-1
mod_p_y =
y-1
when 8
mod_m_x =
x
mod_m_y =
y-2
mod_p_x =
x
mod_p_y =
y-1
when 9
mod_m_x =
x+1
mod_m_y =
y-2
mod_p_x =
x+2
mod_p_y =
y-1
else
return
end
if align ==
0
draw_text(mod_m_x,mod_m_y,width,height,text)
draw_text(mod_p_x,mod_m_y,width,height,text)
draw_text(mod_m_x,mod_p_y,width,height,text)
draw_text(mod_p_x,mod_p_y,width,height,text)
self.font.color
= last_color.clone
draw_text(x,y,width,height,text)
else
draw_text(mod_m_x,mod_m_y,width,height,text,align)
draw_text(mod_p_x,mod_m_y,width,height,text,align)
draw_text(mod_m_x,mod_p_y,width,height,text,align)
draw_text(mod_p_x,mod_p_y,width,height,text,align)
self.font.color = last_color.clone
draw_text(x,y,width,height,text,align)
end
end
#----------------------------------------------------------------
# > Draw
Outline Text
#----------------------------------------------------------------
def
draw_outline_text(pos_x,pos_y,w=Color.new(0,0,0),h=0,str="",line_color=Color.new(0,0,0),text_align=0)
if
pos_x.is_a?(Rect)
x =
pos_x.x
y =
pos_x.y
width =
pos_x.width
height = pos_x.height
text =
pos_y
color = w
align = h
else
x = pos_x
y = pos_y
width = w
height = h
text = str
color =
line_color
align =
text_align
end
last_color =
self.font.color.clone
self.font.color = color
if align ==
0
draw_text(x-1,y-1,width,height,text)
draw_text(x-1,y+1,width,height,text)
draw_text(x+1,y-1,width,height,text)
draw_text(x+1,y+1,width,height,text)
self.font.color = last_color.clone
draw_text(x,y,width,height,text)
else
draw_text(x-1,y-1,width,height,text,align)
draw_text(x-1,y+1,width,height,text,align)
draw_text(x+1,y-1,width,height,text,align)
draw_text(x+1,y+1,width,height,text,align)
self.font.color = last_color.clone
draw_text(x,y,width,height,text,align)
end
end
#================================================================
# ENDING OF
TEXT GROUP
#================================================================
#================================================================
# BEGINNING OF
BITMAP GROUP
#================================================================
#----------------------------------------------------------------
# > Tone
#----------------------------------------------------------------
def
tone(color=nil)
if
color.is_a?(Color)
for x in
0..width
for y in
0..height
pixel
= get_pixel(x,y)
if
pixel.alpha == 0
next
end
r =
((pixel.red+color.red)/2)
g =
((pixel.green+color.green)/2)
b =
((pixel.blue+color.blue)/2)
a =
((pixel.alpha+color.alpha)/2)
new_color = Color.new(r,g,b,a)
set_pixel(x,y,new_color)
end
end
end
end
#----------------------------------------------------------------
# > Tint
#----------------------------------------------------------------
def
tint(color=Color.new(0,0,0,127))
if
color.is_a?(Color)
for x in
0..width
for y in
0..height
pixel
= get_pixel(x,y)
if
pixel.alpha == 0
next
end
set_pixel(x,y,color)
end
end
end
end
#----------------------------------------------------------------
# > Invert
Colors
#----------------------------------------------------------------
def
invert(invert_alpha=false)
for x in
0..width
for y in
0..height
pixel =
get_pixel(x,y)
if
pixel.alpha == 0
next
end
if
invert_alpha == true
a =
255-pixel.alpha
else
a =
pixel.alpha
end
pixel.set(255-pixel.red,255-pixel.green,255-pixel.blue,a)
set_pixel(x,y,pixel)
end
end
end
#----------------------------------------------------------------
# > Opacity
#----------------------------------------------------------------
def
opacity(opacity=255)
if opacity
< -255
opacity =
-255
end
if opacity
< 255
for x in
0..width
for y in
0..height
pixel
= get_pixel(x,y)
if
pixel.alpha == 0
next
end
pixel.set(pixel.red,pixel.green,pixel.blue,(pixel.alpha+opacity)/2)
set_pixel(x,y,pixel)
end
end
end
end
#----------------------------------------------------------------
# > Force
Opacity
#----------------------------------------------------------------
def
force_opacity(opacity=255)
for x in
0..width
for y in
0..height
pixel =
get_pixel(x,y)
if
pixel.alpha == 0
next
end
pixel.set(pixel.red,pixel.green,pixel.blue,opacity)
set_pixel(x,y,pixel)
end
end
end
#================================================================
# ENDING OF
BITMAP GROUP
#================================================================
#================================================================
# BEGINNING OF
PICTURE GROUP
#================================================================
#----------------------------------------------------------------
# > Hue
#----------------------------------------------------------------
def
hue_blt(x,y,src_bitmap,src_rect,hue=0,opacity=255)
if hue == 0
or hue == 360
blt(x,y,src_bitmap,src_rect,opacity)
else
bitmap =
Bitmap.new(src_rect.width,src_rect.height)
bitmap.blt(0,0,src_bitmap,src_rect)
bitmap.hue_change(hue)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
blt(x,y,bitmap,rect,opacity)
end
end
#----------------------------------------------------------------
def
hue_stretch_blt(dest_rect,src_bitmap,src_rect,hue=0,opacity=255)
bitmap =
Bitmap.new(dest_rect.width,dest_rect.height)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
bitmap.stretch_blt(rect,src_bitmap,src_rect)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
hue_blt(dest_rect.x,dest_rect.y,bitmap,rect,hue,opacity)
end
#----------------------------------------------------------------
# > Tone
#----------------------------------------------------------------
def
tone_blt(x,y,src_bitmap,src_rect,color=nil,opacity=255)
if
color.is_a?(Color)
bitmap =
Bitmap.new(src_rect.width,src_rect.height)
bitmap.blt(0,0,src_bitmap,src_rect)
bitmap.tone(color)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
blt(x,y,bitmap,rect,opacity)
else
blt(x,y,src_bitmap,src_rect,opacity)
end
end
#----------------------------------------------------------------
def
tone_stretch_blt(dest_rect,src_bitmap,src_rect,color=nil,opacity=255)
bitmap =
Bitmap.new(dest_rect.width,dest_rect.height)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
bitmap.stretch_blt(rect,src_bitmap,src_rect)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
tone_blt(dest_rect.x,dest_rect.y,bitmap,rect,color,opacity)
end
#----------------------------------------------------------------
# > Tint
#----------------------------------------------------------------
def
tint_blt(x,y,src_bitmap,src_rect,color=nil,opacity=255)
if
color.is_a?(Color)
bitmap =
Bitmap.new(src_rect.width,src_rect.height)
bitmap.blt(0,0,src_bitmap,src_rect)
bitmap.tint(color)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
blt(x,y,bitmap,rect,opacity)
else
blt(x,y,src_bitmap,src_rect,opacity)
end
end
#----------------------------------------------------------------
def
tint_stretch_blt(dest_rect,src_bitmap,src_rect,color=nil,opacity=255)
bitmap =
Bitmap.new(dest_rect.width,dest_rect.height)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
bitmap.stretch_blt(rect,src_bitmap,src_rect)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
tint_blt(dest_rect.x,dest_rect.y,bitmap,rect,color,opacity)
end
#----------------------------------------------------------------
# > Light
Blur
#----------------------------------------------------------------
def
light_blt(x,y,src_bitmap,src_rect,blur_size=4,b_color=Color.new(255,200,205),opacity=255)
color =
b_color.clone
if blur_size
< 0
blur_size
= 0
end
if blur_size
== 0
blt(x,y,src_bitmap,src_rect,opacity)
else
previous_color = color.clone
bitmap =
Bitmap.new(src_rect.width+blur_size*2,src_rect.height+blur_size*2)
bitmap.clear
bitmap.blt(blur_size,blur_size,src_bitmap,src_rect)
colors =
[]
for i in
1..blur_size
i3 =
(blur_size+1) - i
mod =
(i3.to_f/(blur_size.to_f+1))
r =
color.red / mod
g =
color.green / mod
b =
color.blue / mod
i2 =
(blur_size+1) - i
mod2 =
(i2.to_f/(blur_size.to_f+1))
a =
color.alpha * (mod2 * 1.5)
color.set((color.red+r)/2,(color.green+g)/2,(color.blue+b)/2,(color.alpha+a)/2)
colors[i] = color.clone
end
bits = []
for i in
1..blur_size
bit = []
for px
in 0...bitmap.width
for py
in 0...bitmap.height
paint = false
pixel = bitmap.get_pixel(px,py)
if
pixel.alpha > 0
next
end
for
bx in -1..1
if
bx == 0
next
end
for by in -1..1
if by == 0
next
end
new_pixel = bitmap.get_pixel(px+bx,py+by)
if new_pixel.alpha > 0
paint = true
end
end
end
if
paint == true
temp = []
temp.push(px,py)
bit.push temp
end
end
end
if
!bit.empty?
for
pos in bit
bitmap.set_pixel(pos[0],pos[1],colors[i])
end
end
end
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
blt(x-(blur_size/2),y-(blur_size/2),bitmap,rect,opacity)
end
end
#----------------------------------------------------------------
def
light_stretch_blt(dest_rect,src_bitmap,src_rect,blur_size=4,color=Color.new(255,200,205),opacity=255)
bitmap =
Bitmap.new(dest_rect.width,dest_rect.height)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
bitmap.stretch_blt(rect,src_bitmap,src_rect)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
light_blt(dest_rect.x,dest_rect.y,bitmap,rect,blur_size,color,opacity)
end
#----------------------------------------------------------------
# > Dark
Blur
#----------------------------------------------------------------
def
dark_blt(x,y,src_bitmap,src_rect,blur_size=4,b_color=Color.new(255,200,205),opacity=255)
color =
b_color.clone
if blur_size
< 0
blur_size
= 0
end
if blur_size
== 0
blt(x,y,src_bitmap,src_rect,opacity)
else
previous_color = color.clone
bitmap =
Bitmap.new(src_rect.width+blur_size*2,src_rect.height+blur_size*2)
bitmap.clear
bitmap.blt(blur_size,blur_size,src_bitmap,src_rect)
colors =
[]
for i in
1..blur_size
mod =
(i.to_f/(blur_size.to_f+1))
r = color.red
* (mod * 1.5)
g =
color.green * (mod * 1.5)
b =
color.blue * (mod * 1.5)
i2 =
(blur_size+1) - i
mod2 =
(i2.to_f/(blur_size.to_f+1))
a =
color.alpha * (mod2 * 1.5)
color.set((color.red+r)/2,(color.green+g)/2,(color.blue+b)/2,(color.alpha+a)/2)
colors[i] = color.clone
end
bits = []
for i in
1..blur_size
bit = []
for px
in 0...bitmap.width
for py
in 0...bitmap.height
paint = false
pixel
= bitmap.get_pixel(px,py)
if
pixel.alpha > 0
next
end
for
bx in -1..1
if
bx == 0
next
end
for by in -1..1
if by == 0
next
end
new_pixel = bitmap.get_pixel(px+bx,py+by)
if new_pixel.alpha > 0
paint = true
end
end
end
if
paint == true
temp = []
temp.push(px,py)
bit.push temp
end
end
end
if
!bit.empty?
for
pos in bit
bitmap.set_pixel(pos[0],pos[1],colors[i])
end
end
end
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
blt(x-(blur_size/2),y-(blur_size/2),bitmap,rect,opacity)
end
end
#----------------------------------------------------------------
def
dark_stretch_blt(dest_rect,src_bitmap,src_rect,blur_size=4,color=Color.new(255,200,205),opacity=255)
bitmap =
Bitmap.new(dest_rect.width,dest_rect.height)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
bitmap.stretch_blt(rect,src_bitmap,src_rect)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
dark_blt(dest_rect.x,dest_rect.y,bitmap,rect,blur_size,color,opacity)
end
#----------------------------------------------------------------
# > Invert
Colors
#----------------------------------------------------------------
def invert_blt(x,y,src_bitmap,src_rect,alpha=false,opacity=255)
if
alpha.is_a?(TrueClass) or alpha.is_a?(FalseClass)
bitmap =
Bitmap.new(src_rect.width,src_rect.height)
bitmap.blt(0,0,src_bitmap,src_rect)
bitmap.invert(alpha)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
blt(x,y,bitmap,rect,opacity)
else
blt(x,y,src_bitmap,src_rect,opacity)
end
end
#----------------------------------------------------------------
def
invert_stretch_blt(dest_rect,src_bitmap,src_rect,alpha=false,opacity=255)
bitmap =
Bitmap.new(dest_rect.width,dest_rect.height)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
bitmap.stretch_blt(rect,src_bitmap,src_rect)
rect =
Rect.new(0,0,bitmap.width,bitmap.height)
invert_blt(dest_rect.x,dest_rect.y,bitmap,rect,alpha,opacity)
end
#================================================================
# ENDING OF
PICTURE GROUP
#================================================================
#================================================================
# BEGINNING OF
GEOMETRY GROUP
#================================================================
#----------------------------------------------------------------
# >
Draw_Circle
#----------------------------------------------------------------
def
draw_circle(ox,oy,radius,color=Color.new(0,0,0),size=1,fill_color=false)
bitmap =
ref_circle(size,color)
bitmap_rect
= Rect.new(0,0,bitmap.width,bitmap.height)
if not
radius.integer?
radius.to_i
end
if radius
< 1
return
end
steps =
(radius * Math::PI) * radius
angle_steps
= 360 / steps
for i in
1..steps
angle =
angle_steps * i
cos =
Math.cos(angle*(Math::PI/180.0))
_x = cos *
radius
x = _x.to_i
+ ox
sin =
Math.sin(angle*(Math::PI/180.0))
_y = sin *
radius
y =
_y.to_i + oy
if
fill_color == true
angle =
angle.to_i
case
angle
when
0..89
rect_x
= ox
rect_y
= oy
rect_w
= x - ox
rect_h
= y - oy
if x
== ox
rect_w = 1
end
if y
== oy
rect_h = 1
end
when
90..179
rect_x
= x
rect_y
= oy
rect_w
= ox - x
rect_h
= y - oy
if x
== ox
rect_w = 1
end
if y
== oy
rect_h = 1
end
when
180..269
rect_x
= x
rect_y
= y
rect_w
= ox - x
rect_h
= oy - y
if x
== ox
rect_w = 1
end
if y
== oy
rect_h = 1
end
when
270..360
rect_x
= ox
rect_y
= y
rect_w
= x - ox
rect_h
= oy - y
if x
== ox
rect_w
= 1
end
if y
== oy
rect_h = 1
end
end
rect =
Rect.new(rect_x,rect_y,rect_w+(size/2).to_i,rect_h+(size/2).to_i)
fill_rect(rect,color)
else
if size
< 1
set_pixel(x,y,color)
else
blt(x-(size/2),y-(size/2),bitmap,bitmap_rect)
end
end
end
end
#----------------------------------------------------------------
def
ref_circle(size,color=Color.new(0,0,0))
bitmap =
Bitmap.new(size,size)
radius =
(size/2).to_i
ox =
(size/2).to_i
oy =
(size/2).to_i
if not
radius.integer?
radius.to_i
end
if radius
< 1
bmp =
Bitmap.new(1,1)
bmp.set_pixel(0,0,color)
return bmp
end
steps =
(radius * Math::PI) * radius
angle_steps
= 360 / steps
for i in
1..steps
angle =
angle_steps * i
_x =
(Math.cos(angle*(Math::PI/180.0))*radius)
x =
_x.to_i + ox
_y =
(Math.sin(angle*(Math::PI/180.0))*radius)
y =
_y.to_i + oy
bitmap.set_pixel(x,y,color)
fill =
false
for x in
0..bitmap.width
for y in
0..bitmap.height
pixel
= bitmap.get_pixel(x,y)
if
pixel == color
if
fill == true
bitmap.set_pixel(x,y,color)
else
fill = true
end
else
fill
= false
end
end
end
end
return
bitmap
end
#----------------------------------------------------------------
# > Fill
Gradient Rect
#----------------------------------------------------------------
def
fill_gradient_rect(rx, ry, w, h=0, c1=Color.new(0,0,0),
c2=Color.new(255,255,255), al = 0)
if
rx.is_a?(Integer)
x = rx
y = ry
width = w
height = h
color1 = c1
color2 =
c2
align = al
else
x = rx.x
y = rx.y
width =
rx.width
height =
rx.height
color1 =
ry
color2 = w
align = h
end
rect
if align ==
0
for i in
x...x + width
red
= color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green =
color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha =
color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color =
Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align
== 1
for i in
y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green =
color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) /
(height - 1)
alpha =
color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color =
Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align
== 2
for i in
x...x + width
for j in
y...y + height
red = color1.red + (color2.red -
color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green
= color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue
- color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha
= color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color
= Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align
== 3
for i in
x...x + width
for j in
y...y + height
red = color1.red + (color2.red -
color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green
= color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue
- color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha
= color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color
= Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
#================================================================
# ENDING OF
GEOMETRY GROUP
#================================================================
#================================================================
# BEGINNING OF
UTILITY GROUP
#================================================================
#----------------------------------------------------------------
# >
Horizontal Progress Bar
#----------------------------------------------------------------
def
horz_progress_bar(bx,by,bw=Color.new(20,10,30),bh=Color.new(200,230,180),progress=Color.new(0,0,0),color1=255,color2=nil,color3=nil,op=255,fl=nil,h=nil)
if
@horz_bar_data == nil
@horz_bar_data = {}
end
if
bx.is_a?(Integer)
x = bx
y = by
width = bw
height =
bh
size =
progress
i_color =
color1
f_color =
color2
b_color =
color3
opacity =
op
flash = fl
hue = h
else
x = bx.x
y = bx.y
width =
bx.width
height =
bx.height
size = by
i_color =
bw
f_color =
bh
b_color =
progress
opacity =
color1
flash =
color2
hue =
color3
end
if size <
0
size = 0
end
if size >
100
size = 100
end
bar_bmp =
Bitmap.new(width,height)
blank =
Color.new(0,0,0,0)
r =
b_color.red/2
g =
b_color.green/2
b =
b_color.blue/2
a =
b_color.alpha
color =
Color.new(r,g,b,a)
bar_bmp.fill_rect(0,0,bar_bmp.width,bar_bmp.height,color)
bar_bmp.set_pixel(0,0,blank)
bar_bmp.set_pixel(bar_bmp.width-1,0,blank)
bar_bmp.set_pixel(0,bar_bmp.height-1,blank)
bar_bmp.set_pixel(bar_bmp.width-1,bar_bmp.height-1,blank)
r =
(i_color.red + f_color.red)/2
g =
(i_color.green + f_color.green)/2
b =
(i_color.blue + f_color.blue)/2
a =
(i_color.alpha + f_color.alpha)/2
color_1 =
Color.new(r/2,g/2,b/2,a)
color_2 =
Color.new(r/3.5,g/3.5,b/3.5,a)
w = width -
2
h = height -
2
if w <= 0
w = 1
end
if h <= 0
h = 1
end
bck_bmp =
Bitmap.new(w,h)
bck_bmp.fill_gradient_rect(0,0,w,h,color_1,color_2,0)
bck_bmp.set_pixel(0,0,blank)
bck_bmp.set_pixel(w-1,0,blank)
bck_bmp.set_pixel(0,h-1,blank)
bck_bmp.set_pixel(w-1,h-1,blank)
bck_rect =
Rect.new(0,0,w,h)
bar_bmp.blt(1,1,bck_bmp,bck_rect)
r =
(((i_color.red + f_color.red)/2) + b_color.red)/4
g =
(((i_color.green + f_color.green)/2) + b_color.green)/4
b =
(((i_color.blue + f_color.blue)/2) + b_color.blue)/4
a =
(((i_color.alpha + f_color.alpha)/2) + b_color.alpha)/1.5
color_3 =
Color.new(r,g,b,a)
w = width -
6
h = height -
6
if w <= 0
w = 1
end
if h <= 0
h = 1
end
int_bmp =
Bitmap.new(w,h)
int_bmp.fill_rect(0,0,w,h,color_3)
int_bmp.set_pixel(0,0,blank)
int_bmp.set_pixel(w-1,0,blank)
int_bmp.set_pixel(0,h-1,blank)
int_bmp.set_pixel(w-1,h-1,blank)
int_bmp.fill_rect(1,1,w-2,h-2,Color.new(0,0,0,190))
int_rect =
Rect.new(0,0,w,h)
bar_bmp.blt(3,3,int_bmp,int_rect)
w = width -
8
h = height -
8
if w <= 0
w = 1
end
if h <= 0
h = 1
end
sta_bmp =
Bitmap.new(w,h)
sta_bmp.clear
new_width =
((w * size)/100).to_i
r =
i_color.red * (((100-size)+50)/(100+((100-size)/2.0)))
g =
i_color.green * (((100-size)+50)/(100+((100-size)/2.0)))
b =
i_color.blue * (((100-size)+50)/(100+((100-size)/2.0)))
a =
i_color.alpha
color_i =
Color.new(r,g,b,a)
r =
f_color.red * ((size+50)/(100+(size/2.0)))
g =
f_color.green * ((size+50)/(100+(size/2.0)))
b =
f_color.blue * ((size+50)/(100+(size/2.0)))
a =
f_color.alpha
color_f =
Color.new(r,g,b,a)
sta_bmp.fill_gradient_rect(0,0,new_width,h,color_i,color_f,1)
sta_bmp.set_pixel(0,0,blank)
sta_bmp.set_pixel(new_width-1,0,blank)
sta_bmp.set_pixel(0,h-1,blank)
sta_bmp.set_pixel(new_width-1,h-1,blank)
if
flash.is_a?(Color)
sta_bmp.tone(flash)
end
sta_rect =
Rect.new(0,0,w,h)
bar_bmp.blt(4,4,sta_bmp,sta_rect)
if
hue.is_a?(Integer)
bar_bmp.hue_change(hue)
end
bar_id =
x+y+width+height
img_rect =
Rect.new(x,y,width,height)
img_bmp =
Bitmap.new(width,height)
slf =
self.clone
img_bmp.blt(0,0,slf,img_rect)
src = Rect.new(0,0,width,height)
blt(x,y,bar_bmp,src,opacity)
data = []
data.push
(img_rect,img_bmp,size,i_color,f_color,b_color,opacity,flash,hue)
@horz_bar_data[bar_id] = data
end
#----------------------------------------------------------------
def
delete_horz_progress_bar(x=0,y=0,w=0,h=0,dt=nil)
if
x.is_a?(Integer)
id =
x+y+w+h
data2 = dt
else
id =
x.x+x.y+x.width+x.height
data2 = y
end
if
@horz_bar_data != nil
if
@horz_bar_data.include?(id)
data =
@horz_bar_data[id]
bmp =
data[1]
blt(data[0].x,data[0].y,bmp,Rect.new(0,0,bmp.width,bmp.height))
@horz_bar_data.delete(id)
if
data2.is_a?(Array)
horz_progress_bar(data2[0],data2[1],data2[2],data2[3],data2[4],data2[5],data2[6],data2[7])
end
end
end
end
#----------------------------------------------------------------
def
update_horz_progress_bar(x,y=nil,w=nil,h=nil,size=nil,op=nil,fl=nil,hue=nil)
if
x.is_a?(Integer)
id = x+y+w+h
rect =
Rect.new(x,y,w,h)
if
@horz_bar_data.include?(id)
ary =
@horz_bar_data[id]
data =
[]
data.push rect
if
size.is_a?(Integer)
data.push size
else
data.push ary[2]
end
data.push ary[3]
data.push ary[4]
data.push ary[5]
if
op.is_a?(Integer)
data.push op
else
data.push ary[6]
end
if
fl.is_a?(Color)
data.push fl
else
if fl == false
@horz_bar_data[id][7] = nil
end
data.push ary[7]
end
if
hue.is_a?(Integer)
data.push hue
else
data.push ary[8]
end
delete_horz_progress_bar(rect,data)
end
else
id =
x.x+x.y+x.width+x.height
if
@horz_bar_data.include?(id)
ary =
@horz_bar_data[id]
data =
[]
data.push x
if
y.is_a?(Integer)
data.push y
else
data.push ary[2]
end
data.push ary[3]
data.push ary[4]
data.push ary[5]
if
w.is_a?(Integer)
data.push w
else
data.push ary[6]
end
if
h.is_a?(Color)
data.push h
else
if h == false
@horz_bar_data[id][7] = nil
end
data.push ary[7]
end
if
size.is_a?(Integer)
data.push size
else
data.push ary[8]
end
delete_horz_progress_bar(x,data)
end
end
end
#----------------------------------------------------------------
def
modify_horz_progress_bar(x=0,y=nil,w=nil,h=nil,size=nil,c1=nil,c2=nil,c3=nil,op=nil,fl=nil,hue=nil)
if
x.is_a?(Integer)
id =
x+y+w+h
rect = Rect.new(x,y,w,h)
if
@horz_bar_data.include?(id)
ary =
@horz_bar_data[id]
data =
[]
data.push rect
if
size.is_a?(Integer)
data.push size
else
data.push ary[2]
end
if
c1.is_a?(Color)
data.push c1
else
data.push ary[3]
end
if
c2.is_a?(Color)
data.push c2
else
data.push ary[4]
end
if
c3.is_a?(Color)
data.push c3
else
data.push ary[5]
end
if
op.is_a?(Integer)
data.push op
else
data.push ary[6]
end
if
fl.is_a?(Color)
data.push fl
else
if fl
== false
@horz_bar_data[id][7] = nil
end
data.push ary[7]
end
if
hue.is_a?(Integer)
data.push hue
else
data.push ary[8]
end
delete_horz_progress_bar(rect,data)
end
else
id = x.x+x.y+x.width+x.height
if
@horz_bar_data.include?(id)
data =
[]
data.push x
ary =
@horz_bar_data[id]
if
y.is_a?(Integer)
data.push y
else
data.push ary[2]
end
if
w.is_a?(Color)
data.push w
else
data.push ary[3]
end
if
h.is_a?(Color)
data.push h
else
data.push ary[4]
end
if
size.is_a?(Color)
data.push size
else
data.push
ary[5]
end
if
c1.is_a?(Integer)
data.push c1
else
data.push ary[6]
end
if
c2.is_a?(Color)
data.push c2
else
if c2
== false
@horz_bar_data[id][7] = nil
end
data.push ary[7]
end
if
c3.is_a?(Integer)
data.push c3
else
data.push ary[8]
end
delete_horz_progress_bar(x,data)
end
end
end
#----------------------------------------------------------------
# >
Vertical Progress Bar
#----------------------------------------------------------------
def
vert_progress_bar(bx,by,bw=Color.new(20,10,30),bh=Color.new(200,230,180),progress=Color.new(0,0,0),color1=255,color2=nil,color3=nil,op=255,fl=nil,h=nil)
if
@vert_bar_data == nil
@vert_bar_data = {}
end
if
bx.is_a?(Integer)
x = bx
y = by
width = bw
height =
bh
size =
progress
i_color =
color1
f_color = color2
b_color =
color3
opacity =
op
flash = fl
hue = h
else
x = bx.x
y = bx.y
width =
bx.width
height =
bx.height
size = by
i_color =
bw
f_color =
bh
b_color =
progress
opacity =
color1
flash =
color2
hue =
color3
end
if size <
0
size = 0
end
if size >
100
size = 100
end
bar_bmp =
Bitmap.new(width,height)
blank =
Color.new(0,0,0,0)
r =
b_color.red/2
g = b_color.green/2
b =
b_color.blue/2
a =
b_color.alpha
color =
Color.new(r,g,b,a)
bar_bmp.fill_rect(0,0,bar_bmp.width,bar_bmp.height,color)
bar_bmp.set_pixel(0,0,blank)
bar_bmp.set_pixel(bar_bmp.width-1,0,blank)
bar_bmp.set_pixel(0,bar_bmp.height-1,blank)
bar_bmp.set_pixel(bar_bmp.width-1,bar_bmp.height-1,blank)
r =
(i_color.red + f_color.red)/2
g =
(i_color.green + f_color.green)/2
b =
(i_color.blue + f_color.blue)/2
a =
(i_color.alpha + f_color.alpha)/2
color_1 =
Color.new(r/2,g/2,b/2,a)
color_2 =
Color.new(r/3.5,g/3.5,b/3.5,a)
w = width -
2
h = height -
2
if w <= 0
w = 1
end
if h <= 0
h = 1
end
bck_bmp =
Bitmap.new(w,h)
bck_bmp.fill_gradient_rect(0,0,w,h,color_1,color_2,1)
bck_bmp.set_pixel(0,0,blank)
bck_bmp.set_pixel(w-1,0,blank)
bck_bmp.set_pixel(0,h-1,blank)
bck_bmp.set_pixel(w-1,h-1,blank)
bck_rect =
Rect.new(0,0,w,h)
bar_bmp.blt(1,1,bck_bmp,bck_rect)
r =
(((i_color.red + f_color.red)/2) + b_color.red)/4
g =
(((i_color.green + f_color.green)/2) + b_color.green)/4
b =
(((i_color.blue + f_color.blue)/2) + b_color.blue)/4
a =
(((i_color.alpha + f_color.alpha)/2) + b_color.alpha)/1.5
color_3 =
Color.new(r,g,b,a)
w = width -
6
h = height -
6
if w <= 0
w = 1
end
if h <= 0
h = 1
end
int_bmp =
Bitmap.new(w,h)
int_bmp.fill_rect(0,0,w,h,color_3)
int_bmp.set_pixel(0,0,blank)
int_bmp.set_pixel(w-1,0,blank)
int_bmp.set_pixel(0,h-1,blank)
int_bmp.set_pixel(w-1,h-1,blank)
int_bmp.fill_rect(1,1,w-2,h-2,Color.new(0,0,0,190))
int_rect =
Rect.new(0,0,w,h)
bar_bmp.blt(3,3,int_bmp,int_rect)
w = width -
8
h = height -
8
if w <= 0
w = 1
end
if h <= 0
h = 1
end
sta_bmp =
Bitmap.new(w,h)
sta_bmp.clear
new_height =
((h * size)/100).to_i
r =
i_color.red * (((100-size)+50)/(100+((100-size)/2.0)))
g =
i_color.green * (((100-size)+50)/(100+((100-size)/2.0)))
b =
i_color.blue * (((100-size)+50)/(100+((100-size)/2.0)))
a =
i_color.alpha
color_i =
Color.new(r,g,b,a)
r =
f_color.red * ((size+50)/(100+(size/2.0)))
g =
f_color.green * ((size+50)/(100+(size/2.0)))
b =
f_color.blue * ((size+50)/(100+(size/2.0)))
a =
f_color.alpha
color_f =
Color.new(r,g,b,a)
sta_bmp.fill_gradient_rect(0,h-new_height,w,new_height,color_i,color_f,0)
sta_bmp.set_pixel(0,(h-new_height),blank)
sta_bmp.set_pixel(w-1,(h-new_height),blank)
sta_bmp.set_pixel(0,h-1,blank)
sta_bmp.set_pixel(w-1,h-1,blank)
if
flash.is_a?(Color)
sta_bmp.tone(flash)
end
sta_rect =
Rect.new(0,0,w,h)
bar_bmp.blt(4,4,sta_bmp,sta_rect)
if
hue.is_a?(Integer)
bar_bmp.hue_change(hue)
end
bar_id =
x+y+width+height
img_rect =
Rect.new(x,y,width,height)
img_bmp =
Bitmap.new(width,height)
slf =
self.clone
img_bmp.blt(0,0,slf,img_rect)
src =
Rect.new(0,0,width,height)
blt(x,y,bar_bmp,src,opacity)
data = []
data.push
(img_rect,img_bmp,size,i_color,f_color,b_color,opacity,flash,hue)
@vert_bar_data[bar_id] = data
end
#----------------------------------------------------------------
def
delete_vert_progress_bar(x=0,y=0,w=0,h=0,dt=nil)
if
x.is_a?(Integer)
id =
x+y+w+h
data2 = dt
else
id =
x.x+x.y+x.width+x.height
data2 = y
end
if
@vert_bar_data != nil
if
@vert_bar_data.include?(id)
data =
@vert_bar_data[id]
bmp =
data[1]
blt(data[0].x,data[0].y,bmp,Rect.new(0,0,bmp.width,bmp.height))
@vert_bar_data.delete(id)
if
data2.is_a?(Array)
vert_progress_bar(data2[0],data2[1],data2[2],data2[3],data2[4],data2[5],data2[6],data2[7])
end
end
end
end
#----------------------------------------------------------------
def
update_vert_progress_bar(x,y=nil,w=nil,h=nil,size=nil,op=nil,fl=nil,hue=nil)
if
x.is_a?(Integer)
id =
x+y+w+h
rect =
Rect.new(x,y,w,h)
if
@vert_bar_data.include?(id)
ary =
@vert_bar_data[id]
data =
[]
data.push rect
if
size.is_a?(Integer)
data.push size
else
data.push ary[2]
end
data.push ary[3]
data.push ary[4]
data.push ary[5]
if
op.is_a?(Integer)
data.push op
else
data.push ary[6]
end
if
fl.is_a?(Color)
data.push fl
else
if fl
== false
@vert_bar_data[id][7] = nil
end
data.push ary[7]
end
if
hue.is_a?(Integer)
data.push hue
else
data.push ary[8]
end
delete_vert_progress_bar(rect,data)
end
else
id =
x.x+x.y+x.width+x.height
if @vert_bar_data.include?(id)
ary =
@vert_bar_data[id]
data =
[]
data.push x
if
y.is_a?(Integer)
data.push y
else
data.push ary[2]
end
data.push ary[3]
data.push ary[4]
data.push ary[5]
if
w.is_a?(Integer)
data.push w
else
data.push ary[6]
end
if
h.is_a?(Color)
data.push h
else
if h
== false
@vert_bar_data[id][7] = nil
end
data.push ary[7]
end
if
size.is_a?(Integer)
data.push size
else
data.push ary[8]
end
delete_vert_progress_bar(x,data)
end
end
end
#----------------------------------------------------------------
def
modify_vert_progress_bar(x=0,y=nil,w=nil,h=nil,size=nil,c1=nil,c2=nil,c3=nil,op=nil,fl=nil,hue=nil)
if
x.is_a?(Integer)
id =
x+y+w+h
rect =
Rect.new(x,y,w,h)
if
@vert_bar_data.include?(id)
ary =
@vert_bar_data[id]
data =
[]
data.push rect
if
size.is_a?(Integer)
data.push size
else
data.push ary[2]
end
if
c1.is_a?(Color)
data.push c1
else
data.push
ary[3]
end
if
c2.is_a?(Color)
data.push c2
else
data.push ary[4]
end
if
c3.is_a?(Color)
data.push c3
else
data.push ary[5]
end
if
op.is_a?(Integer)
data.push op
else
data.push ary[6]
end
if
fl.is_a?(Color)
data.push fl
else
if fl
== false
@vert_bar_data[id][7] = nil
end
data.push ary[7]
end
if
hue.is_a?(Integer)
data.push hue
else
data.push ary[8]
end
delete_vert_progress_bar(rect,data)
end
else
id =
x.x+x.y+x.width+x.height
if
@vert_bar_data.include?(id)
data = []
data.push x
ary =
@vert_bar_data[id]
if
y.is_a?(Integer)
data.push y
else
data.push ary[2]
end
if
w.is_a?(Color)
data.push w
else
data.push ary[3]
end
if
h.is_a?(Color)
data.push h
else
data.push ary[4]
end
if
size.is_a?(Color)
data.push size
else
data.push ary[5]
end
if
c1.is_a?(Integer)
data.push c1
else
data.push ary[6]
end
if
c2.is_a?(Color)
data.push c2
else
if c2
== false
@vert_bar_data[id][7] = nil
end
data.push ary[7]
end
if c3.is_a?(Integer)
data.push c3
else
data.push ary[8]
end
delete_vert_progress_bar(x,data)
end
end
end
#----------------------------------------------------------------
# > Get
Average Pixel
#----------------------------------------------------------------
def
get_average_pixel(x,y,size=3)
if (size %
2) == 0
size -= 1
if size
< 3
return
get_pixel(x,y)
end
elsif size
<= 1
return
get_pixel(x,y)
end
initial_x =
x - ((size-1)/2).to_i
initial_y =
y - ((size-1)/2).to_i
final_x = x
+ ((size-1)/2).to_i
final_y = y
+ ((size-1)/2).to_i
r = 0.0
g = 0.0
b = 0.0
a = 0.0
average = 0
for px in
initial_x..final_x
for py in initial_y..final_y
color =
get_pixel(px,py)
r +=
color.red
g +=
color.green
b +=
color.blue
a +=
color.alpha
average
+= 1
end
end
red = r /
average
green = g /
average
blue = b /
average
alpha = a /
average
return
Color.new(red,green,blue,alpha)
end
#================================================================
# ENDING OF
UTILITY GROUP
#================================================================
end
Conclusion
Well, that’s all ladies and gentleman! ^^
I hope someone finds this update useful. On the
next version I’ll value more the speed since some methods of this update can
make your game lag a bit. Some functions are incomplete on another viewpoint.
(For example the draw_circle could draw just a part of the circle, passing the
angle wanted to draw.)
For those grammar-extravagant people, I beg
sincere excuses about my veery poooor English…. Since that’s not my native
language, it’s fairly difficult to write and speak.
And some of you may not understand the bar for
now, but it’s really useful when you don’t want to recreate a whole bitmap just
for update a silly bar, be it for HP or SP, or AP, or experience, or inside a
HP/SP HUD, or everything else….
Credits
First to me, this was a lot of hard work, so I
want some recognition…
-
Linkin_T
-
Cogwheel (I think that´s the guy’s name….)
That´s all.
Enjoy! =^.^=