Latest Changes
Differences between version #6774 and #6818
2,10c2,4
< public static function lEquation (T:Dynamic, x1:Float, x2:Float, y0:Float, y1:Float, y2:Float) :Dynamic {
<
< var x0 = (x2 - x1) * (y0 - y1) / (y2 - y1) + x1;
<
< return switch (T) {
< case Int: Math.round ( x0 );
< default : x0;
< }
< }
---
> public static function lEquation (x1:Float, x2:Float, y0:Float, y1:Float, y2:Float) :Float {
> return (x2 - x1) * (y0 - y1) / (y2 - y1) + x1;
> }
12,15c6,9
< What is this equation useful? For a lot of things, here's an example how to move a progress bar when you know the percent loaded:
< <code haxe>progressBar.width = lEquation (Int, 0, 530, percent, 0, 100);</code>
< T is the type you want to return, Int or Float
< 0 - 530 means that the width of the progressBar will change from 0 to 530 when the percent will take values from 0 to 100
---
> What is this equation useful? For a lot of things that changes their values linearly. Here's an example how to move a progress bar when you know the percent loaded:
> <code haxe>progressBar.width = lEquation (0, 530, percent, 0, 100);</code>
> 0 - 530 means that the width of the progressBar will change from 0 to 530 when the percent will take values from 0 to 100.
> I find it useful because you don't have to think the formula again and again, you know visually what values to put in the function.
| Ver | Date | Entry | Lg | User | Action |
|---|---|---|---|---|---|
| #18057 | 2013-04-27 07:39:01 | doc/start/objc | en | cristibaluta | View | Diff |
| #18056 | 2013-04-27 07:39:01 | doc/start/objc | en | cristibaluta | Set title to Getting started with Haxe/ObjC |
| #15549 | 2012-10-08 10:02:09 | download/make | en | cristibaluta | View | Diff |
| #12654 | 2012-03-28 12:52:06 | doc/snip/selective_trace | en | cristibaluta | View | Diff |
| #10766 | 2011-07-21 17:03:35 | com/showcase | en | cristibaluta | View | Diff |
| #10765 | 2011-07-21 17:02:09 | com/showcase | en | cristibaluta | View | Diff |
| #10406 | 2011-04-06 16:32:31 | download | en | cristibaluta | View | Diff |
| #10405 | 2011-04-06 16:30:40 | download | en | cristibaluta | View | Diff |
| #9319 | 2010-10-18 12:07:40 | doc/snip/stringwithformat | en | cristibaluta | Set title to stringWithFormat |
| #9318 | 2010-10-18 12:06:04 | doc/snip/stringwithformat | en | cristibaluta | View | Diff |
| #8475 | 2010-05-28 10:23:24 | doc/js/ajax | en | cristibaluta | View | Diff |
| #6827 | 2009-08-20 06:23:26 | doc/snip/lequation | en | cristibaluta | View | Diff |
| #6820 | 2009-08-19 11:40:46 | doc/snip/lequation | en | cristibaluta | View | Diff |
| #6819 | 2009-08-19 11:16:35 | doc/snip/lequation | en | cristibaluta | View | Diff |
| #6818 | 2009-08-19 11:15:17 | doc/snip/lequation | en | cristibaluta | View | Diff |
| #6774 | 2009-08-18 23:11:59 | doc/snip/lequation | en | cristibaluta | View | Diff |
| #6773 | 2009-08-18 23:11:59 | doc/snip/lequation | en | cristibaluta | Set title to Equation of a straight line |
| #6772 | 2009-08-18 22:44:35 | doc/snip/saferemove | en | cristibaluta | View | Diff |
| #6771 | 2009-08-18 22:44:35 | doc/snip/saferemove | en | cristibaluta | Set title to Safe remove |
Previous | Next