moeseth
moeseth

Reputation: 1945

UIImage fill colour but not border

I have the stars image as shown and I'd like to fill the colour based on rating of a user.

five stars

How could I do that?

Upvotes: 0

Views: 83

Answers (1)

Daij-Djan
Daij-Djan

Reputation: 50089

a) use the flood algorithm to fill an area (all connected pixels with the same color) starting from a given pixel with one color.
For that you'd have to fix the image though as the white in the stars 1 and 2 connect directly.

b) setup a NSBezierPath for a star and fill the path. Transform it to move the path horizontally from star to star.
You should also fix the image so that the stars are evenly distributed.

c) use 5 pngs and based on the number of stars to coulor, draw a different png.
This sean image of an empty star & an image of ONE fullstarems easiest.


best IMHO:

d) have 3 images. ONE empty star, ONE full star, ONE half star, draw the image 5 times .. depending on how many stars are full, half full or empty

Upvotes: 1

Related Questions