123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|597|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Creating rating stars as 1 image

Thu, 20 Aug 2009, 04:06
LostUser

I have a rating system from 0-5 stars, see graphic:



I need a way of algamising/combining a star graphic into one image
so that I do not repeat the DrawImage command over and over.

For example, instead of doing 3 calls to:



I want to do this:



Which will create 3 stars for me in a temporary graphic in one line.

Currently I am doing this:



Rather than doing this, is there some way of doing it in one call,
even if it is to some kind of temporary image that holds all the
stars?

Thu, 20 Aug 2009, 04:31
Jayenkai
Createimage contains a "number of frames" thing. Using that, do a quick loop at the start of your program, and pop all the star images into that. Make sure it's a global, and you can just draw that one image + frame, as opposed to constantly redrawing 1/0/0/0/0 over and over.

-=-=-
''Load, Next List!''
Thu, 20 Aug 2009, 06:01
9572AD
I tried to do that once. Then I decided it would be far easier to just have 6 images.

-=-=-
All the raw, animal magnetism of a rutabaga.
Thu, 20 Aug 2009, 11:29
LostUser
Hi there.

Do you mean, you have:

1 image that holds all images and then use the frame to show the right amount?

Or do you mean:

1 temporary image that holds all images and you display parts of it?

Sorry if I sound a bit confused.
Sun, 06 Sep 2009, 07:24
Teasy
With 1 call?
Perhaps something like this:





I recommend functions though!
E.g. DrawStars( x,y , numstars )
Sun, 06 Sep 2009, 07:27
Jayenkai
Oh yeah.
Man, I keep forgetting about that function!!

-=-=-
''Load, Next List!''
Thu, 24 Sep 2009, 02:43
LostUser
I've now resolved the problem by doing this:


Wed, 21 Oct 2009, 02:16
LostUser
How do I create rating stars that contain both the off/on state?

I am wanting to create ratings stars that have both the off/on state.

See this image:



In the above image it shows 4 stars in the on state and 1 star in the off state.

I have been trying for the last 2 days to recreate this with my above code and the original image posted -- but for whatever reason it does not show the off state at all.



If I replace the above call with:



It should show the off state, but it never does.

I would like to combine the off and on state into one rating stars image.

So, if it were 1 star it would show:

* 0 star on/5 stars off
* 1 star on/4 stars off
* 2 stars on/3 stars off
* 3 stars on/2 stars off
* 4 stars on/1 star off
* 5 stars on/0 stars off

Any help on this would be great.








Wed, 21 Oct 2009, 04:54
Jayenkai
Isn't this exactly what you've been trying to do the whole time?

-=-=-
''Load, Next List!''
Wed, 21 Oct 2009, 05:28
LostUser
No, apologies for the mis-understanding.

Originally I was trying to just output the "on" state for the stars, but combining the "off" and "on" state looks much better.

I will try the solution provided by Teasy to see if this will resolve my problem.
Thu, 22 Oct 2009, 02:18
LostUser
I have tested Teasy's code, this gives me what I was after.

Although I had a problem -- the stars are being displayed in the wrong order, the on state stars are appearing on the right hand side.

I resolved this problem thusly;

1) Changing the image Teasy posted so the on state images are first

2) Adding a switch statement in the function to invert the number of stars being shown (ie: if show = 5, then show = 0,etc)

Is there another way to invert the stars in their display, so that the on state stars appear on the left, and not on the right?

Many thanks.
Thu, 22 Oct 2009, 03:36
Jayenkai
Nah, that's pretty much how I'd do it..
Thu, 22 Oct 2009, 11:00
LostUser
Thanks for your help.

*Closed*