RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Bitmap Addons 1.5

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Bitmap Addons
Version: 1.5
Author: modern algebra
Date: August 21, 2009

Version History


  • <Version 1.5> 08.21.2009 - added extra options to greyscale, as well as allowing for a "default opacity" and "default greyscale"
  • <Version 1.0> 02.19.2009 - Original Release

Planned Future Versions

  • <Version 2.0> - polygon and pie features. So outline_polygon, outline_pie, fill_polygon, fill_pie, fill_area


Description


This is a Scripter's Tool, not a standalone script. If you are not a scripter, then you will only want this script if it is used by a script that you do want.

This script adds methods into Bitmap for drawing ellipses, as well as one for drawing a straight line.

Features

  • New! Can greyscale a designated Rect object within a bitmap
  • New! Can now set a default opacity (and greyscale boolean) for the methods blt and stretch_blt to use
  • Can draw outline or fill an ellipse (or circle)
  • Can draw rectangles with rounded edges
  • Can draw diagonally oriented lines

Screenshots



Instructions

Please see header of the script for instructions

Script


Code: [Select]
#==============================================================================
#  Bitmap Addons
#  Version: 1.5
#  Author: modern algebra (rmrk.net)
#  Date: August 21, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    This is a simple scripter's tool with methods added into Bitmap for drawing
#   ellipses, as well as one for drawing a straight line. The methods it adds
#   are:
#      outline_ellipse
#      fill_ellipse
#      fill_rounded_rect
#      draw_line
#      greyscale
#
#    It also allows you to change opacity and greyscale of blt and stretch_blt
#   externally with the public instance variables:
#
#      bitmap.ma_default_opacity = [0-255]
#      bitmap.ma_default_greyscale = false
#
#    These codes allow you to be able to change the opacity or greyscale what a
#   method like draw_character draws without overwriting it entirely. You want
#   it to draw the character opaque or grey if the character is dead? All you
#   need to do is change the default opacity or greyscale before running the
#   method.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    To use this, simply put it above main. For some of these, it is necessary
#   to create an ellipse object and pass it as an argument. You can create an
#   ellipse with the code:
#
#     Ellipse.new (x, y, a, b)
#       x : the top left x position
#       y : the top left y position
#       a : the width of oval from origin to the side
#       b : the height of oval from origin. If nil, then a is radius of circle
#
#   There are four new methods added to bitmap that can be used:
#
#      outline_ellipse (ellipse[, colour, width, steps])
#        ellipse : the ellipse object being drawn
#        colour  : the colour of the outline. Assumed font colour if not specified
#        width   : the thickness of the line. Assumed 1 if not specified
#        steps   : can set a number of steps for increased accuracy. If not
#                  specified, it will estimate the number of steps
#
#      fill_ellipse (ellipse[, colour, steps])
#        ellipse : the ellipse object being drawn
#        colour  : the colour of the ellipse. Assumed font colour if not specified
#        steps   : can set a number of steps for increased accuracy. If not
#                  specified, it will estimate the number of steps
#
#      fill_rounded_rect (ellipse[, colour, w)
#        ellipse : the ellipse object being drawn
#        colour  : the colour of the outline. Assumed font colour if not specified
#        w       : the number of pixels at which to round the edge.
#
#      draw_line
#        x0      : the initial x coordinate
#        y0      : the initial y coordinate
#        x1      : the end x coordinate
#        y1      : the end y coordinate
#        colour  : the colour of the outline. Assumed font colour if not specified
#
#      greyscale (rect)
#        rect : the Rect object over which that part of the bitmap will be greyed.
#==============================================================================
# ** Ellipse
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Stores an ellipse object.
#==============================================================================

class Ellipse < Rect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :h # The x position of the origin
  attr_reader   :k # The y position of the origin
  alias a width
  alias b height
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #     x : the top left x position
  #     y : the top left y position
  #     a : the width of oval from origin to the side
  #     b : the height of oval from origin. If nil, then a is radius of circle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (x, y, a, b = nil)
    b = a if b.nil?
    super (x, y, a, b)
    @h = x + a
    @k = y + b
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Within?
  #    x : the x coordinate being tested
  #    y : the y coordinate being tested
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def within? (x, y)
    x_square = ((x - @h)*(x - @h)).to_f / (a*a)
    y_square = ((y - @k)*(y - @k)).to_f / (b*b)
    # If "radius" <= 1, then it must be within the ellipse
    return (x_square + y_square) <= 1
  end
end

#==============================================================================
# ** Bitmap
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    attr_accessor - ma_default_opacity, ma_default_greyscale
#    aliased methods - blt; stretch_blt
#    new methods - fill_ellipse; outline_ellipse; fill_rounded_rect; draw_line
#==============================================================================

class Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :ma_default_opacity
  attr_accessor :ma_default_greyscale
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdnabr_dfltopac_init_bmpadon_2lh3 initialize unless $@
  def initialize (*args)
    # Initialize new public instance variable
    @ma_default_opacity = 255
    @ma_default_greyscale = false
    # Run Original Method
    mdnabr_dfltopac_init_bmpadon_2lh3 (*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * BLT
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mnalgba_bitmapaddons_opacdflt_blt_2hb5 blt unless $@
  def blt (x, y, src_bmp, src_rect, opacity = @ma_default_opacity, grey = @ma_default_greyscale, *args)
    if grey
      src_bmp = src_bmp.dup
      src_bmp.greyscale (src_rect)
    end
    # Run Original Method
    mnalgba_bitmapaddons_opacdflt_blt_2hb5 (x, y, src_bmp, src_rect, opacity, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Stretch BLT
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modrnalgbra_strtchblt_bmpdons_opc_0lk2 stretch_blt unless $@
  def stretch_blt (dest_rect, src_bmp, src_rect, opacity = @ma_default_opacity, grey = @ma_default_greyscale, *args)
    if grey
      src_bmp = src_bmp.dup
      src_bmp.greyscale (src_rect)
    end
    # Run Original Method
    modrnalgbra_strtchblt_bmpdons_opc_0lk2 (dest_rect, src_bmp, src_rect, opacity, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Outline Ellipse
  #    ellipse : the ellipse being drawn
  #    width   : the width of the bar
  #    colour  : the colour of the outline
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def outline_ellipse (ellipse, colour = font.color, width = 1, steps = 0)
    # For neatness, define local variables a and b to the ellipse variables
    a, b = ellipse.a, ellipse.b
    # Use Ramanujan's approximation of the Circumference of an ellipse
    steps = Math::PI*(3*(a + b) - Math.sqrt((3*a + b)*(a + 3*b))) if steps == 0
    radian_modifier = (2*Math::PI) / steps
    for i in 0...steps
      t = (radian_modifier*i) % (2*Math::PI)
      # Expressed parametrically:
      #   x = h + acos(t), y = k + bsin(t) : where t ranges from 0 to 2pi
      x = (ellipse.h + (a*Math.cos(t)))
      y = (ellipse.k + (b*Math.sin(t)))
      set_pixel (x, y, colour)
    end
    # Thicken the line
    if width > 1
      ellipse = Ellipse.new (ellipse.x + 1, ellipse.y + 1, ellipse.a - 1, ellipse.b - 1)
      outline_ellipse (ellipse, colour, width - 1, steps)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Fill Ellipse
  #    ellipse : the ellipse being drawn
  #    colour  : the colour of the outline
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def fill_ellipse (ellipse, colour = font.color, steps = 0)
    # For neatness, define local variables a and b to the ellipse variables
    a, b = ellipse.a, ellipse.b
    # Use Ramanujan's approximation of the Circumference of an ellipse
    steps = Math::PI*(3*(a + b) - Math.sqrt((3*a + b)*(a + 3*b))) if steps == 0
    radian_modifier = (2*Math::PI) / steps
    for i in 0...(steps / 2)
      t = (radian_modifier*i)
      # Expressed parametrically:
      #   x = h + acos(t), y = k + bsin(t) : where t ranges from 0 to 2pi
      x = ellipse.h + (a*Math.cos(t))
      y = ellipse.k - (b*Math.sin(t))
      fill_rect (x, y, 1, 2*(ellipse.k - y), colour)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Fill Rounded Rectangle
  #    rect    : the rectangle being drawn
  #    colour  : the colour of the outline
  #    w       : the number of pixels to cover by rounding
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #  Used to fill a rectangle with rounded corners
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def fill_rounded_rect (rect, colour = font.color, w = 8)
    # Draw Body of the rectangle
    fill_rect (rect.x + w, rect.y, rect.width - 2*w, rect.height, colour)
    # Draw Left Vertical Rect
    fill_rect (rect.x, rect.y + w, w, rect.height - 2*w, colour)
    # Draw Right Vertical Rect
    x = rect.x + rect.width - w
    fill_rect (x, rect.y + w, w, rect.height - 2*w, colour)
    # Make a circle
    circle = Ellipse.new (0, 0, w)
    for i in 0...w
      for j in 0...w
        # Upper Left Corner
        set_pixel (rect.x + i, rect.y + j, colour) if circle.within? (i, j)
        # Upper Right Corner
        set_pixel (rect.x + rect.width - w + i, rect.y + j, colour) if circle.within? (i + w, j)
        # Bottom Left Corner
        set_pixel (rect.x + i, rect.y + rect.height - w + j, colour) if circle.within? (i, j + w)
        # Bottom Right Corner
        set_pixel (rect.x + rect.width - w + i, rect.y + rect.height - w + j, colour) if circle.within? (i + w, j + w)
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Line
  #    x0, y0 : the coordinates of the start of the line.
  #    x1, y1 : the coordinates of the end of the line.
  #``````````````````````````````````````````````````````````````````````````
  #  This uses Bresenham's algorithm to draw a line
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def draw_line (x0, y0, x1, y1, colour = font.color)
    # Set boolean for steep lines
    steep = (y1 - y0).abs > (x1 - x0).abs
    if steep
      # Reflect across y=x
      tmp = x0
      x0, y0 = y0, tmp
      tmp = x1
      x1, y1 = y1, tmp
    end
    # If in negative direction
    if x0 > x1
      # Swap initial points
      tmp = x0
      x0, x1 = x1, tmp
      tmp = y0
      y0, y1 = y1, tmp
    end
    ystep = y0 < y1 ? 1 : -1
    deltax = x1 - x0
    deltay = (y1 - y0).abs
    error = deltax / 2
    y = y0
    # Advance by Rows
    for x in x0.to_i...x1.to_i
      steep ? set_pixel (y, x, colour) : set_pixel (x, y, colour)
      error -= deltay
      if error < 0
        y += ystep
        error += deltax
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * GreyScale
  #    rect : the rect to greyscale
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def greyscale (rect = Rect.new (0, 0, self.width, self.height))
    # For each pixel in chosen rect of the bitmap
    for i in rect.x...rect.x + rect.width
      for j in rect.y...rect.y + rect.height
        colour = self.get_pixel (i,j)
        # Get the weighted average of the pixels for a proper shade of grey
        grey_pixel = (colour.red*0.3 + colour.green*0.59 + colour.blue*0.11)
        colour.red = colour.green = colour.blue = grey_pixel
        # Set the pixel to the new shade of grey
        self.set_pixel (i,j,colour)
      end
    end
  end
end

Credit


  • modern algebra

Thanks

This script uses:

  • Ramanujan's approximation of the Circumference of an ellipse
  • Bresenham's algorithm to draw a line

Support


Please post here at rmrk.net for swiftest support.

Known Compatibility Issues

No known compatibility issues

Author's Notes


I wrote this a while ago for my Quest Journal, but since I intend to use it for other scripts, I thought it would be useful if it were released as standalone. I realize that these are probably not the most efficient ways to draw these basic geometric shapes, and I welcome any suggestions that would help me improve the algorithms used.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: April 08, 2010, 05:30:40 PM by modern algebra »

**
Rep:
Level 84
cool script modern algebra. going to get some use from me :)

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
This is a pretty good add-on to the bitmap class. I was looking the other day for a way to fill objects and this should help figure out what I was doing wrong.

**
Rep:
Level 86
Very nice script. ^^
I haven't done anything further than fill_rect and draw_line in my life. :P

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
This script has now been updated to Version 1.5

There are a few new features:

A) added a greyscale method to bitmap, allowing you to grey a designated Rect object of the Bitmap.
B) added "default opacity" and "default greyscale" as public instance variables
C) changed blt and stretch_blt to function off of the new default values and added a boolean argument for greyscale. Basically, now, instead of opacity defaulting to 255, it defaults to the value of default_opacity. The arguments are now:
Code: [Select]
  bitmap.blt (x, y, bitmap, src_rect[, opacity = @ma_default_opacity[, greyscale boolean = @ma_default_greyscale]])
  bitmap.stretch_blt (dest_rect, src_bitmap, src_rect[, opacity = @ma_default_opacity[, greyscale boolean = @ma_default_greyscale]])

**
Rep: +0/-0Level 76
RMRK Junior
The same thing happens here as withyour catalogue base script.

***
Rep:
Level 81
Monster Hunter
Modern Algebra? how do i use the draw_line command?
it just says:
Code: [Select]
draw_line
#        x0      : the initial x coordinate
#        y0      : the initial y coordinate
#        x1      : the end x coordinate
#        y1      : the end y coordinate
#        colour  : the colour of the outline. Assumed font colour if not specified

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
It's:

Code: [Select]
draw_line(x0, y0, x1, y1, colour)

x0 and y0 are the coordinates of the start pixel, while x1 and y1 are the coordinates of the end pixel.

So:
Code: [Select]
draw_line (5, 8, 34, 17, Color.new(0, 0, 0))

would draw a black line from (5, 8) to (34, 17).

***
Rep:
Level 81
Monster Hunter
It's:

Code: [Select]
draw_line(x0, y0, x1, y1, colour)

x0 and y0 are the coordinates of the start pixel, while x1 and y1 are the coordinates of the end pixel.

So:
Code: [Select]
draw_line (5, 8, 34, 17, Color.new(0, 0, 0))

would draw a black line from (5, 8) to (34, 17).

i tried this in an event but it doesn't work (before i saw your post)
Code: [Select]
draw_line (x0, y0, x1, y1, colour)
x0 = $game_player.x
y0 = $game_player.y
x1 = $game_map.events[7].x
y1 = $game_map.events[7].y
colour = font.color

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Really nice; used this before and it's come in handy.

Any chance of programming in anti-aliased lines, MA?

***
Rep:
Level 81
Monster Hunter
so how should i do this in an event ?
the command i used doesn't seem to work -_-"

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, the method is in Bitmap, which means to do it you will need to make a sprite or window and draw it on the bitmap in that class.

@cozziekuns - I don't know if I will return to this script to do that, but if I make a VXA version I would, and then I would probably port it back to VX. I currently have no plans to do so though.

***
Rep:
Level 81
Monster Hunter
Well, the method is in Bitmap, which means to do it you will need to make a sprite or window and draw it on the bitmap in that class.

@cozziekuns - I don't know if I will return to this script to do that, but if I make a VXA version I would, and then I would probably port it back to VX. I currently have no plans to do so though.
could you give me an example for a sprite , whats the code? ^^

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
What do you mean? There are lots of sprites in the default classes.

***
Rep:
Level 81
Monster Hunter
What do you mean? There are lots of sprites in the default classes.
i mean that i would just like to create a line on the map scene but i don't know the code ^^

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
You have to create a new sprite, with a sufficiently large bitmap, position it to where you want it to be, then draw the line.

You don't want to do it directly through an event - it would be best to do it in Scene_Map and just have an event call initialize that process.

I don't really have the time to give you a tutorial on Sprites, but hopefully it suffices to give this example:

Code: [Select]
@line_sprite = Sprite.new
@line_sprite.bitmap = Bitmap.new(64, 64)
@line_sprite.x = 200
@line_sprite.y = 300
@line_sprite.bitmap.draw_line(0, 0, 32, 48, Color.new(0, 0, 0))

Obviously that's ugly and useless, but maybe it will give you an idea of what to do. If you want the sprite to be more dynamic it might be worthwhile to make a subclass of Sprite to handle the processing.

***
Rep:
Level 81
Monster Hunter
You have to create a new sprite, with a sufficiently large bitmap, position it to where you want it to be, then draw the line.

You don't want to do it directly through an event - it would be best to do it in Scene_Map and just have an event call initialize that process.

I don't really have the time to give you a tutorial on Sprites, but hopefully it suffices to give this example:

Code: [Select]
@line_sprite = Sprite.new
@line_sprite.bitmap = Bitmap.new(64, 64)
@line_sprite.x = 200
@line_sprite.y = 300
@line_sprite.bitmap.draw_line(0, 0, 32, 48, Color.new(0, 0, 0))

Obviously that's ugly and useless, but maybe it will give you an idea of what to do. If you want the sprite to be more dynamic it might be worthwhile to make a subclass of Sprite to handle the processing.

Thanks MA i'll take a look ;)

***
Rep:
Level 81
Monster Hunter
MA how would i make a line from one point to an other point, i'm trying to make a fishing system with variables and events :p
letting a line go from the player to an event/coordinates.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I think I answered this question, didn't I?

Make a sprite and use the draw_line method on its bitmap.

***
Rep:
Level 81
Monster Hunter
I think I answered this question, didn't I?

Make a sprite and use the draw_line method on its bitmap.
yeah well i never figured out how to get it to work :(

***
hail satan buddy 666
Rep:
Level 55
Blagil VlUE
Useful script, i like it so many script, modern algebra
[

**
Rep: +0/-0Level 37
RMRK Junior
I can't believe I'm actually in need for this... LOL! Never thought so >.<

I was really excited when I read this:
Quote
<Version 2.0> - polygon and pie features. So outline_polygon, outline_pie, fill_polygon, fill_pie, fill_area

only to then discover it's listed as 'planned future versions' T.T :(

Thanks for your awesomeness, MA!

Edit: VX? Buuuh :(
Edit2: Look at what I found: http://www.whiteflute.org/wfrgss/?mode=view&realmId=1&pageId=25#h5_simple_draw_pie28start_x2c20start_y2c20end_x2c20end_y2c20color202cstart_angle202c20sweep_angle202cfill202cwidth203d20129 :O
« Last Edit: April 15, 2015, 01:38:44 AM by Kyuukon »

やれやれだぜ。