Package lib :: Module geom
[hide private]
[frames] | no frames]

Module geom

source code

general-purpose geometry routines

Classes [hide private]
  VLayout
vertical layout manager
  HLayout
horizontal layout manager defined as a transpose of VLayout
  GLayout
grid layout manager
Functions [hide private]
float
rect_ratio(r)
returns the ratio of rect r which is defined as width/height
source code
(float,float,float,float)
rect_rel_scale(r, fw, fh, align_x=0, align_y=0)
relatively scale a rect
source code
(float,float,float,float)
rect_pad(r, pad)
returns a padded rect by reducing border by the pad tuple (top,left,bottom,right)
source code
(float,float,float,float)
rect_to_abs(r)
get absolute coordinates (x0,y0,x1,y1) from rect definition (x,y,w,h)
source code
(float,float,float,float)
abs_to_rect(a)
get rect definition (x,y,w,h) from absolute coordinates (x0,y0,x1,y1)
source code
(float,float,float,float)
rect_from_origin(r)
returns a similar rect with top-left corner at (0,0)
source code
(float,float,float,float)
rect_hull(r1, r2)
returns the smallest rect containing r1 and r2
source code
((float,float,float,float),(float,float,float,float))
rect_hsplit(r, f=0.5, fdist=0.0)
split a rect horizontally
source code
((float,float,float,float),(float,float,float,float))
rect_vsplit(r, f=0.5, fdist=0.0)
split a rect vertically, similarly to rect_hsplit
source code
tuple
color_mix(a, b, frac)
mix two colors
source code
tuple
color_scale(a, frac)
scale color values
source code
tuple
color_auto_fg(bg, light=(1, 1, 1), dark=(0, 0, 0))
return light or dark foreground color based on an ad-hoc evaluation of bg
source code
Variables [hide private]
  __package__ = None
Function Details [hide private]

rect_rel_scale(r, fw, fh, align_x=0, align_y=0)

source code 

relatively scale a rect

Parameters:
  • fw (float in [0,1]) - width fraction (to be multiplied)
  • fh (float in [0,1]) - height fraction (to be multiplied)
  • align_x (float in [-1,1]) - determines the relative position of the new rect with respect to the old one. A value of 0 aligns in the center, a value of -1 aligns on the left, a value of 1 aligns on the right hand side. Intermediate values do linear interpolation.
  • align_y (float in [-1,1]) - Performs vertical (top-bottom) alignment similarly to align_x.
Returns: (float,float,float,float)

rect_hsplit(r, f=0.5, fdist=0.0)

source code 

split a rect horizontally

Parameters:
  • f (float in [0,1]) - split fraction
  • fdist - fraction of space to discard before splitting (free space)
Returns: ((float,float,float,float),(float,float,float,float))
tuple (r1,r2) with splits and free space evenly distributed before r1, between r1 and r2 and after r2

color_mix(a, b, frac)

source code 

mix two colors

Parameters:
  • frac (float in [0,1]) - amount of first color
Returns: tuple

color_scale(a, frac)

source code 

scale color values

Parameters:
  • frac (float) - scale amount (to be multiplied)
Returns: tuple