BB.BaseBrush2D
Base 2D brush class extended by BB.ImageBrush2D, BB.LineBrush2D, etc...
Index
Methods
- BB.BaseBrush2D constructor
- draw
- scale
- update
Constructor
BB.BaseBrush2D
(
-
[config]
)
-
[config]
Parameters:
-
[config]
Object optionalAn optional config hash to initialize any of BB.BaseBrush2D's public properties
Example:
var brush = new BB.BaseBrush2D({ width: 100,
height: 100, color: new BB.Color(255, 0, 0) });
Properties
color
BB.Color
default:null
The brush's color.
height
Number
default:10
The brush's height.
hidden
Boolean
default:false
Wether or not to draw the brush to the screen. Toggle this variable to hide and show the brush.
rotation
Number
default:0
The brush's rotation in degrees. This property is not always used with each brush variant.
type
String
default:"base"
The type of brush. Defaults to "base" for BB.BaseBrush, "image" for BB.ImageBrush, etc... and should be treated as read-only.
width
Number
default:10
The brush's width.
x
Number
default:0
The brush's x position.
y
Number
default:0
The brush's y position.
Methods
draw
()
Base draw method. Usually called once per animation frame.
scale
(
-
amount
)
-
amount
Multiplies width and height properties by amount.
Parameters:
-
amount
NumberAmount to scale width and height by
Example:
var brush = new BB.BaseBrush2D({ width: 50, height: 100 });
brush.scale(2);
brush.width // 100
brush.height // 200
update
(
-
controllerModule
)
-
controllerModule
Base update method. Usually called once per animation frame.
Parameters:
-
controllerModule
ObjectAn object with x and y properties and optionally an isDown boolean (used for beginning and ending strokeds/marks).
Example:
var mouseInput = new BB.MouseInput(document.getElementById('canvas'));
var pointer = new BB.Pointer(mouseInput);
var brush = new BB.BaseBrush2D();
// called once per animation frame (from somewhere else in your app)
function update() {
mouseInput.update();
pointer.update();
brush.update(pointer); // update the brush using the pointer
}