Distributing elements

From TaskDepender
Jump to: navigation, search
(Design)
(Design)
Line 39: Line 39:
 
<math>S  = \displaystyle\frac{x_{max}-x_{min}-W}{N-1}</math>
 
<math>S  = \displaystyle\frac{x_{max}-x_{min}-W}{N-1}</math>
  
 
+
Since the algorithm assumes elements that the elements are ordered by position of the left edges, this additional step must be performed before running the described algorithm.
The steps that need to be performed when the selected elements are to be horizontally distributed:
+
# Order the selected elements by position of the left edges.
+
# Set <tt>x_min</tt> to hold the left edge of the first element which is the leftmost edge.
+
# Set <tt>x_max</tt> to hold the right edge of the last element which is the rightmost edge.
+
# Set <tt>sum_width</tt> to hold the sum of the widths of all the elements.
+
# Set <tt>s=(x_max-x_min-sum_width)/(N-1)</tt>x_min</tt> to hold the space between two adjacent elements.
+
# Reposition all the elements except the first and the last element to their new position using the determined space.
+
 
+
<syntaxhighlight lang="cpp">
+
;
+
</syntaxhighlight>
+
  
 
== Implementation ==
 
== Implementation ==

Revision as of 18:39, 11 November 2011