What's going on?

This example demonstrates how to bind RockyJS to a canvas, and update the output at a regular interval. More information about the key RockyJS API calls for this example can be found below.

var rocky = Rocky.bindCanvas(el)

This method creates an instance of Rocky, and binds it to a canvas object. Once we have a Rocky object, we can use it to invoke a subset of Pebble's C API, and have the results rendered on the canvas.

rocky.export_global_c_symbols()

This method pollutes the global namespace with a subset of Pebble's C API. This allows you to invoke (the implemented) functions from Pebble's C API without having to preface every call with rocky.functionName.

rocky.mark_dirty()

This method indicates to Rocky that update_proc should be invoked.

rocky.update_proc

Rocky's update_proc is a method that will be invoked everytime the canvas is marked as dirty with the mark_dirty method. The update_proc takes two parameters: ctx - the graphics context, and bounds - the bounds of the window.

Dog image courtesy of OpenGameArt.org

Fork me on GitHub