Advertisement
Guest User

Untitled

a guest
Mar 6th, 2014
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.61 KB | None | 0 0
  1.     // width and height of my area
  2.     let w = f w
  3.     let h = f (h - 30)
  4.  
  5.     // element size (min) and element margin
  6.     let el_s = f 100
  7.     let el_m = f 25
  8.  
  9.     // how many elements + margin we can fit in one row (with fractions)
  10.     let n = max 1.0f ((w - el_m) / (el_s + el_m))
  11.  
  12.     // how many elements floored
  13.     let y = int n
  14.  
  15.     // how much extra space we got left over
  16.     let x = n - (f y)
  17.    
  18.     // how much extra size we need to add to each element, giving the final el_s
  19.     let s = ((w - el_m) * (x / n)) / (f y)
  20.  
  21.     // final size of each element
  22.     let el_s' = int (el_s + s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement