Skip to content
Jarvis Niu edited this page Feb 23, 2016 · 4 revisions

Bu is the namespace of this library. It contains:

Constants

Shapes related

  • Bu.DEFAULT_STROKE_STYLE = '#048'
  • Bu.DEFAULT_FILL_STYLE = 'rgba(64, 128, 192, 0.5)'
  • Bu.DEFAULT_DASH_STYLE = [8, 4]

Curve related

  • Bu.DEFAULT_SPLINE_SMOOTH = 0.25 # range in [0 ~ 1]

Interaction related

  • Bu.DEFAULT_STROKE_STYLE_HOVER = 'rgba(255, 128, 0, 0.75)'
  • Bu.DEFAULT_FILL_STYLE_HOVER = 'rgba(255, 128, 128, 0.5)'

Texts related

  • Bu.DEFAULT_TEXT_FILL_STYLE = 'black'

Default size

  • Bu.DEFAULT_IMAGE_SIZE = 20
  • Bu.POINT_RENDER_SIZE = 2.25
  • Bu.POINT_LABEL_OFFSET = 5

Bounds related

  • Bu.DEFAULT_BOUND_STROKE_STYLE = '#444'
  • Bu.DEFAULT_BOUND_DASH_STYLE = [6, 6]

Computation related

  • Bu.DEFAULT_NEAR_DIST = 5

Mouse interact

  • Bu.MOUSE_BUTTON_NONE = -1
  • Bu.MOUSE_BUTTON_LEFT = 0
  • Bu.MOUSE_BUTTON_MIDDLE = 1
  • Bu.MOUSE_BUTTON_RIGHT = 2

Utility Functions

Function Description
Bu.average calculate the mean value of several numbers
Bu.bevel calculate the hypotenuse from the cathetuses
Bu.rand generate a random number between two numbers
Bu.r2d convert an angle from radian to deg
Bu.now get current time
Bu.combineOptions combine the given options with the default options
Bu.clone clone an Object or Array
Bu.data use localStorage to persist data

Polyfills

Polyfill Description
Function::property define a property to an object
Function::throttle limit the frequency of function call
Function::debounce delay the call of function
Array::each Iterate this Array and do something with the items
Array::map Iterate this Array and map the items to a new Array
Clone this wiki locally