Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075927 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:57:28 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Drawing on a certain portion an image
Pages: [1]
Print
Author Topic: Drawing on a certain portion an image  (Read 482 times)
Cheezmeister
Level 1
*



View Profile
« on: September 13, 2012, 03:57:28 PM »

I have a meter. Let's say it's a health meter. It's a pretty health meter. It has a pretty background, a pretty foreground, and a not-so-pretty dynamic portion.

The dynamic portion, however, doesn't occupy the entire area of the background. It's an arbitrary portion in the center (the X's, for example):

Code:
..............
.....XXXXXXX..
..............

Right now I'm hard-coding this location. That's gross, and makes babies cry. Plus, it breaks my graphics every time I change up the art.

I'm thinking of using a mask to indicate the rectangle I'm interested in, but that's another layer of complexity, and another image I'd have to maintain. Any more clever solutions I'm not thinking of?
Logged

Procrastinating on: RA (http://luchenlabs.com/apps/ra) | More at http://luchenlabs.com/projects
My heart goes out to you for asking a simple question and getting a million complicated answers; it's sort of how this forum works... -Evan Balster
TobiasW
Level 8
***


This can only end brilliantly!


View Profile WWW Email
« Reply #1 on: September 13, 2012, 04:14:56 PM »

If it is a) formed in a regular way (like a rectangle), b) doesn't change too often and c) you don't have more than a few different health meters, I don't see any reason why it shouldn't be manually entered in a constant together with other asset-specific constants.
Logged

Ludophonic
Level 2
**


View Profile WWW
« Reply #2 on: September 13, 2012, 07:17:06 PM »

Instead of a separate mask image you could include two pixels of an otherwise unused colour to indicate the top-left and bottom-right corners of the meter.

If you'd rather have the meter 'mask' and solid rectangle, you could find the corners easy enough but you'd also have to look at the surrounding pixels when iterating through the image.

Many image formats have an area for extra data — often used to save photo info — that you could stick your position data in. If whatever program you're using to create your images has scripting support you could write a script to stick the info where it needs to be, perhaps based on the bounding rectangle of one of your layers.
Logged
randomnine
Level 1
*


View Profile WWW
« Reply #3 on: September 14, 2012, 01:10:33 AM »

If you want a prettier dynamic portion, you could use three images:

- the empty health meter
- the full health meter
- a gradient map which, given the current health level, determines which of the above two images to use on a per-pixel basis
Logged

ASnogarD
Level 1
*



View Profile
« Reply #4 on: September 14, 2012, 04:25:08 AM »

I assume you have a sort of image that surrounds your gameplay area with a hole for the meter to display, but if you adjust the image and the hole is moved it messes up the meter ?

In that case you could draw the surround image without a hole, then add a smaller image that sits ontop and blends in with the surround and draw the 'hole' (like a black box) in this image, then code in the meter using the image with a holes' xy values to determine the meters positioning (so if you move the hole it moves the meter too ).

Logged

Somethings are painfully obvious, others must be made obvious... painfully.
Christian Knudsen
Level 10
*****



View Profile WWW Email
« Reply #5 on: September 14, 2012, 04:40:08 AM »

Are you really changing the artwork so often that hardcoding the position is an issue? Sounds weird to me.
Logged

Laserbrain Studios
Currently working on Hidden Asset (TIGSource DevLog)
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic