Drawing contents.. again!
#1
It's that time once again..

I have icons of all kinds of sizes, now how would I go around and get all of them in a specific spot no matter the size?

I'm giving my equipment scene a complete overhaul, and now I would like to show armors and weapons centered at specific spots on an image of the actors body.

I kinda got it, but things start to get ugly when armor1 is 31*29 and armor2 is 48*48 anyway.

I really don't have the time to perfect each display, times 3! As there are 3 different locations where I would need this.

I thought I could achieve the above by making all icons the ''same size'' using:

Code:
maxx = 50
maxy = 50
correctionx = maxx - bitmap.width
correctiony = maxy - bitmap.height
adjustx = bitmap.width + correctionx
adjusty = bitmap.height + correctionx
self.contents.blt(238 + adjustx, 279 + adjusty, bitmap, Rect.new(0, 0, 640, 480))

It just doesn't work as perfect as I would like it to. Sarcasm

I don't know if it can be done, and perhaps it's overthinking things but what about letting rmxp open the bitmap and locate the first black x & y pixel?
Is there even a method for that?

Thanks in advance and for reading, did you notice it too by the way? Well now you did.
}
#2
from the help guide, Bitmap class "get_pixel(x, y) Gets the color (Color) at the specified pixel (x, y)." That way would work but it might be a tad slow. If you are careful about your redraws, you could definitely do it that way. Do you really need to do it that way, though? Unless your armor comes in many weird sizes (asymmetrical, widely different shoulder bits) you should be able to get the width and height similar to how Sprite_Characters are drawn; that is, x = width /2 + offset, y = height + offset.

Why are you blting over the whole screen (640 by 480) anyways? at maximum you should only have to do it over the actor body image.
}
#3
Perhaps, you may wish to have this minor script-ette? Pardon possible syntax errors... I'm writing it from work, so I am actually unsure about the Icon Cache statement. *sigh*

This script add-on should allow you to draw an icon within a centered area, the icon's own width and height adjusting placement as it loads. As I put it within the Window_Base class, it should be accessible from virtually any window scripts that has it as a parent class (most all are).

AND... you don't have a size limit for your icons. Could be used as a basis for other pictures too. Also, if no filename is present... it won't blit.

Code:
class Window_Base
  #------------------------------------------------------------------
  # * Draw centered icon in place
  #    x : x-location (assuming center coordinates)
  #    y : y-location (assuming center coordinates)
  #    filename : icon filename
  #------------------------------------------------------------------
  def centered_icon(x, y, filename=nil)
    # exit out if no file exists or is empty string
    return if filename.nil?
    return if filename = ""
    # Acquire the bitmap
    bitmap    = RPG::Cache.icons(iconfile)
    # Adjust target coords based on bitmap size (half each)
    dest_x    = x - (bitmap.width/2).to_i
    dest_y    = y - (bitmap.height/2).to_i
    # create destination rectangle based on full bitmap size
    dest_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    # Blit image into centered position
    self.contents.blt(dest_x, dest_y, bitmap, dest_rect)
  end
end
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
}
#4
Thanks again Dervvulfman! That worked out quite right after adjusting it to my liking, but still not as good as I would like.

The good : http://i.cubeupload.com/ispTrq.png

The bad : http://i.cubeupload.com/9q6Fg2.png

I know I could make the first shield higher, so that the second one gets displayed well, but that's exactly what I not want.

Am I doomed to adjusting every item a few pixels?
}
#5
OR... you can do what I do.... create the items on blank PNG files... These PNG files would all be the same size, and you can adjust your icon-like images to take up the center area of the image, as little or as much as you'd like...

When the script takes your picture, it's only going for the exact point. This way, you can ensure that your image will get to the right spot everytime in your favorite image editor.

And btw, let me say, I am LOVING your equipment menu page... That's so close to what I was envisioning for Roguehaven.... is yours full drag and drop yet?
[Image: yy7iKKb.png]

ITCH: jayray.itch.io
Currently working on Goblin Gulch (MV)
Currently working on JayVinci Resurrection
Currently working on Bakin ABS (BAKIN)
}
#6
I think I suddenly prefer adjusting some icons their x & y coordinates over manually opening every icon file in a program that supports transparency.

Cause yea.. with around 1200 icons..

This can be closed, I'll just remove the shadow of the icons so it doesn't look weird.

Thanks again DerVVulfman!
}
#7
KK. Closing

NOTE: Members may self close a request thread by flagging it 'Solved (and close)'. Only saying as many others are unaware that can be done.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
}


Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Drawing contents Gardesion 3 4,930 03-17-2014, 04:53 AM
Last Post: JayRay



Users browsing this thread: 1 Guest(s)