Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Start all three sliders at 33.333...%</p> <p>When the users moves a slider up say 10% : move the two other sliders down of 5%. But if one of two slider reaches 0 => only move the other one of ten percent. So it gives something like this :</p> <pre><code>User moved slider of x (my be positive or negative) for first slider if slider -x/2 &gt; 0 and x/2 &lt; 100 move this slider of -x/2 else move the other slider of -x/2 for second slider if slider -x/2 &gt; 0 and x/2 &lt; 100 move this slider of -x/2 else move the other slider of -x/2 end </code></pre> <p>Another possibility would be to consider that the sum os the available ressources is 100, the ressources are separated into n buckets (in your case 3). When the user moves a slider, he fixes the number of ressources in the corresponding bucket. And so you may either take ressources from other bucket or put ressources in these other buckets.</p> <p>You have something like :</p> <pre><code>state 1 ; modified bucket ; new number of ressources in that bucket modification = new number of ressources in the bucket - number of rescources in the state 1 for (int i=0 ; modification &gt; 0 ; i++){ i=i%nbr of buckets; if(bucket i != modified bucket){ if(number of ressources in bucket i-- &gt; 0 &amp;&amp; number of ressources in bucket i-- &lt; 100){ number of ressources in bucket i--; modification --; } } } </code></pre> <p>That is assuming the modification is positive (new number in the modified bucket is higher than before). This small algorithm would work with any number of buckets (sliders in your case).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload