Okay, here's a quick API Reference. Open this window while you're playing with yourself in the sandbox.
And while at it, check the Raphaël's documentation too.
Here's how to start with the RaphBoard:
// v1.0.2
// Attach RaphBoard to the container
$( document ).ready( function( $ ) {
$( "#board" ).RaphBoard();
// It can be invoked with options too:
$( "#board" ).RaphBoard( { "showToolBar": false } );
});
// RaphBoard will take its container's dimensions, so don't hesitate
// to show some style (put this in the <head> section of your page)
<style>
#board {
width: 650px;
height: 380px;
background-color: black;
}
</style>
The main object.
Parameter(s): Object with key/value pairs or single key/value pair
// Set global options for every new RaphBoard:
$.RaphBoard.options( { "showToolBar": false } );
// Set options during initialization:
var board = $( "#board" ).RaphBoard( { "stroke": "#777" } );
// Set options after RaphBoard initialization:
board.options( { "strokeWidth": 6 } );
board.options( "lineCap", "round" );
Default options and values:
May be useful if you want "view only" mode and you load the content via .fromJSON() method or using the board in "non-interactive" mode.
May be useful if you want to create your own toolbar or use the board in "non-interactive" mode.
Take a look at Raphaël's Attributes documentation for possible values.
Take a look at Raphaël's Attributes documentation for possible values.
RaphBoard uses 4 default strokes that a user can choose from in the AttributesPanel:
If you set some other value here, it will be overridden by user's selection in AttributesPanel.
Therefore, it only makes sense in "non-interactive" mode.
Take a look at Raphaël's Attributes documentation for possible values.
Take a look at Raphaël's Attributes documentation for possible values.
Take a look at Raphaël's Attributes documentation for possible values.
Take a look at Raphaël's Attributes documentation for possible values.
Take a look at Raphaël's Attributes documentation for possible values.
Set to null
if no animation required.
Take a look at Raphaël's Animation documentation for possible values.
RaphBoard provides "hooks" to catch interactive drawing events:
At the moment, RaphBoard does NOT use Raphaël's eve event handler. It's planned for future releases.
There are two methods available:
Parameter(s): String, Function
RaphBoard.on( "before_cut", function () {
return false; // Cancel the operation
} );
Returns: RaphBoard
Parameter(s): String
RaphBoard.off( "before_cut" );
Returns: RaphBoard
RaphBoard.version();
RaphBoard.UUID();
RaphBoard.left();
RaphBoard.top();
RaphBoard.width();
RaphBoard.height();
RaphBoard.isEnabled();
RaphBoard.canUndo();
RaphBoard.canRedo();
Parameter(s): None
Trigger event(s): None
RaphBoard.enable();
Returns: RaphBoard
Parameter(s): None
Trigger event(s): None
RaphBoard.disable();
Returns: RaphBoard
Parameter(s): String
Trigger event(s): "before_mode_change", "after_mode_change"
// "move|pen|line|arrow|circle|ellipse|rect|text|cut"
RaphBoard.mode( "pen" );
Returns: Mode ( String )
NOTE: If called without parameter, only returns current mode and no event is triggered.
Parameter(s): Integer
Trigger event(s): None
RaphBoard.element( id );
Returns: Element
Parameter(s): Integer, Integer, Integer
Trigger event(s): None
RaphBoard.move( redCircle.id, 456, 123 );
Returns: Element
Parameter(s): Integer, Integer, Integer, Integer
Trigger event(s): None
RaphBoard.line( 0, 0, 456, 123 );
Returns: Element
NOTE: Set line attributes via RaphBoard.options
Parameter(s): Integer, Integer, Integer, Integer
Trigger event(s): None
RaphBoard.arrow( 0, 0, 456, 123 );
Returns: Element
NOTE: Set arrow attributes via RaphBoard.options
Parameter(s): Integer, Integer, Integer
Trigger event(s): None
RaphBoard.circle( 456, 123, 50 );
Returns: Element
NOTE: Set circle attributes via RaphBoard.options
Parameter(s): Integer, Integer, Integer, Integer
Trigger event(s): None
RaphBoard.ellipse( 456, 123, 100, 50 );
Returns: Element
NOTE: Set ellipse attributes via RaphBoard.options
Parameter(s): Integer, Integer, Integer, Integer
Trigger event(s): None
RaphBoard.rect( 456, 123, 100, 50 );
Returns: Element
NOTE: Set rectangle attributes via RaphBoard.options
Parameter(s): Integer, Integer, String, Integer
Trigger event(s): "after_end"
RaphBoard.text( 456, 123, "Text!", 24 );
Returns: Element
NOTE: Set text attributes via RaphBoard.options
Parameter(s): Integer
Trigger event(s): None
RaphBoard.cut( redCircle.id );
Returns: Boolean true if cut
Parameter(s): Integer, Function to execute on element
Trigger event(s): None
RaphBoard.toJSON( redCircle.id, null );
Returns: JSON string
Parameter(s): JSON object or string, Function to execute on element
Trigger event(s): None
RaphBoard.fromJSON( jsonDrawing, null );
Returns: None
NOTE: This method has not been fully tested yet.
Parameter(s): None
Trigger event(s): None
RaphBoard.undo();
Returns: RaphBoard
Parameter(s): None
Trigger event(s): None
RaphBoard.clearUndo();
Returns: RaphBoard
Parameter(s): None
Trigger event(s): None
RaphBoard.redo();
Returns: RaphBoard
Parameter(s): None
Trigger event(s): None
RaphBoard.clearRedo();
Returns: RaphBoard
Parameter(s): None
Trigger event(s): None
RaphBoard.indicateUndoRedo();
Returns: RaphBoard
Parameter(s): None
Trigger event(s): None
RaphBoard.clear();
Returns: RaphBoard
NOTE: Does not clear undo/redo buffers.
Parameter(s): None
Trigger event(s): None
RaphBoard.flush();
Returns: RaphBoard
NOTE: Clears undo/redo buffers as well.
This is Raphaël.paper wrapper. See Raphaël's Paper documentation for more info.
Canvas.paper();
The AttributesPanel contains drawing attributes - colors, line width and such.
AttributesPanel.paper();
Parameter(s): None
AttributesPanel.show();
Returns: AttributesPanel
NOTE: It will disable all interactions with board (toolbar and paper).
Parameter(s): None
AttributesPanel.hide();
Returns: AttributesPanel
NOTE: It will re-enable all interactions with board (toolbar and paper) after .show().
The ToolBar can contain many buttons and they can be selectively shown or hidden, enabled or disabled. See the Button object for more info.
ToolBar.height();
ToolBar.background();
ToolBar.buttons();
Parameter(s): None
ToolBar.enable();
Returns: ToolBar
NOTE: Does not show the ToolBar, just make it responsive (ie. after .disable()).
Parameter(s): None
ToolBar.disable();
Returns: ToolBar
NOTE: Does not hide the ToolBar, just make it unresponsive.
Parameter(s): Button
ToolBar.addButton( button );
Returns: ToolBar
Parameter(s): Button, Integer
ToolBar.insertButton( button, 3 );
Returns: ToolBar
Parameter(s): Button
ToolBar.removeButton( button );
Returns: ToolBar
Parameter(s): String
ToolBar.button( "circle" );
Returns: Button
Parameter(s): None
ToolBar.deselectAll();
Returns: ToolBar
NOTE: Does not hide the buttons, just turns off Button's highlight & glow.
The ToolBar can contain many buttons and they can be selectively shown, enabled or highlighted. See the ToolBar object for more info on button manipulation.
The Button can contain many icons and they can be selectively shown or hidden, one at a time - showing one icon will hide others. See the Button object for more info.
ButtonIcon.isGlowing();
ButtonIcon.isVisible();
Parameter(s): Boolean
ButtonIcon.glow( true );
Returns: Icon
Parameter(s): None
ButtonIcon.show();
Returns: Icon
Parameter(s): None
ButtonIcon.hide();
Returns: Icon
Report intolerances and bugs to the project's issue tracker and pray for mercy,
or share your frustration (yeah, like anyone cares, tsk.)
Copyright © 2012-2013 Miroslav Hibler. Licensed by MIT license.