Edit the module

This page allows you to edit the existing module (Grove serial camera (Pure JS)).

Basic Information

Provide basic information of the module.

* Photo URLs that end with any one of .jpg, .jpeg, .png or that are uploaded to the Gyazo web service in the PNG format (e.g.https://gyazo.com/hogehoge) are supported.

Relevant URLs

Relevant URLs can be edited in the module page.

Card preview
Grove serial camera (Pure JS)
'16/9/18 8:39
The driver was tested with the Grove Serial Camera.

Layout information

Provide the source code of the module layout in JavaScript.

function Camera(port) { this._port = port; this._name = function() { return 'Camera(' + this._port + ')'; }; this._print = function (g, options) { g.drawRectangle(- 7.5, - 7.5, 15, 15); g.drawCircle(- 14, - 14, 1); g.drawCircle(+ 14, - 14, 1); g.drawCircle(- 14, + 14, 1); g.drawCircle(+ 14, + 14, 1); if (!options.print) { g.drawCircle(0, 0, 7); g.drawRectangle(- 19, - 19, 38, 38); g.drawText(this._name(), - 19, + 19); } }; }
Layout
How to write code
  • First, define a function that represents this module.
  • Define methods _name, _bounds, _print within the class, where ...
  • _name method returns the name of the module for display.
  • _bounds method returns the bounding box of the module as a Rectangle instance.
  • _print method takes graphics context Graphics and printing options PrintOptions as its arguments.
More details can be found at the howto page.
Delete