Yehuda Katz wrote:
> The only difficult thing about a star plugin is reporting fractional 
> star-counts. Otherwise, it's *really* trivial. I would use a hidden 
> text-field or somesuch, and bind clicking the stars to updating the field.
>
> As to reporting the existing star counts, you could use a blank star 
> template stick it in front of a full star image, which increases or 
> decreases in size based upon the value of the hidden field.
>
That's one way to do it... here's another potential method;

  Create star images where the inside of the star is transparent and its 
border is solid/opaque/black. Fill the negative space (image area 
outside the star) with white (or whatever matches the background 
color/pattern of the area the stars will populate on the webpage).

  Now, since you know the width of each star image, you can calculate 
how many pixels match a particular rating. For instance, say you have 5 
stars lined up, each 100px wide -- If the rating is 50% (2.5 of 5 stars) 
the "pixel percentage" would be 250px.

  You can then fill the background of the div containing the stars with 
a contrasting color proportionally to the "pixel percentage". I'd likely 
use a fixed height div with the calculated 250px width & a z-index just 
below the star images to accomplish this for a 50% rating.

The result would show the leftmost 2 stars filled in with the 
contrasting color, the 3rd star half way filled, and the last two 
"empty". This method is "cooler" than the commonly known CSS method as 
it supports higher visual accuracy (for instance 3/100 of a star can be 
filled).

~ Brice


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to