HanSolo / SteelSeries-Canvas

The HTML5 Canvas port of the SteelSeries component library. Mainly contains gauges.
120 stars 76 forks source link

GradientWrappers must start at zero - limitation #12

Closed AllonisDave closed 10 years ago

AllonisDave commented 10 years ago

It appears the current gradientwrapper range must always start at 0 or the gradients are not calculated properly. To get around this limitation I changed

fraction = currentValue / gradRange;

to if (minValue > 0) { fraction = (currentValue - (maxValue - minValue)) / gradRange; } else { fraction = currentValue / gradRange; }

there may be a better way but this worked for me.

mcrossley commented 10 years ago

Hi, sorry for the long delay on this. Thanks for reporting this issue. Shouldn't the correct solution be?...

fraction = (currentValue - minValue) / gradRange;
fraction = Math.max(Math.min(fraction, 1), 0);
AllonisDave commented 10 years ago

Yes, that’s what I ended up implementing.

Dave Perrico

Cinemar, Inc.

http://www.cinemaronline.com

928-282-1501 (Tel)

Home Automation & Media Management Solutions

From: Mark Crossley [mailto:notifications@github.com] Sent: Wednesday, August 20, 2014 10:41 AM To: HanSolo/SteelSeries-Canvas Cc: Dave Perrico Subject: Re: [SteelSeries-Canvas] GradientWrappers must start at zero - limitation (#12)

Hi, sorry for the long delay on this. Thanks for reporting this issue. Shouldn't the correct solution be?...

fraction = (currentValue - minValue) / gradRange; fraction = Math.max(Math.min(fraction, 1), 0);

— Reply to this email directly or view it on GitHub https://github.com/HanSolo/SteelSeries-Canvas/issues/12#issuecomment-52813701 . https://github.com/notifications/beacon/7607428__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyNDE3NTY1OSwiZGF0YSI6eyJpZCI6MzI0NTI1MDR9fQ==--27312c466c0becf4b780a536b43fca94f1e90a70.gif

mcrossley commented 10 years ago

Thanks, fixed in v0.14.9 just published.