
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
marking-surface
Advanced tools
MarkingSurface = require 'marking-surface'
{Mark, Tool, ToolControls} = MarkingSurface
This is a quick overview. Read the source.
A Mark is just an hash-style object with a set method that fires a change event. In MVC terms, this is a model.
It also converts cleanly to JSON, ignoring underscore-prefixed keys.
Custom setters can be created by extending the class and including a set propertyName method. Not that the name has a space in it, so wrap it in quotes.
class Point extends Mark
x: 0
y: 0
'set x': (value) -> Math.min 1, Math.max 0, value
'set y': (value) -> Math.min 1, Math.max 0, value
A Tool watches its instance of Mark, calling render when the mark changes. In MVC terms, it is both a view and a controller.
If you need to use a subclass of Mark or ToolControls (detailed below), you can associate them with a tool by changing the tool class's Mark and Controls property.
class PointTool extends Tool
@Mark: Point
@Controls: PointControls
You should create all the shapes you'll need in the initialize method using createShape to ensure that events are delegated properly. createShape can also apply class names to new shape elements. New shape elements are added to the root group group, which you can use to apply global transformations.
initialize: ->
@spot = @createShape 'circle.the-spot', cx: 0, cy: 0, r: 10
In addition to initialize, There are a few important methods to extend:
onFirstClick fires when the mouse is first pressed on the marking surface.onFirstDrag is fired when dragging during an initial click.onFirstRelease is fired when releaseing after an initial click.render should reposition the shapes according to the properties of the tool's mark.select should change the view so it's apparent that this tool is selected (e.g. a thicker stroke), deselect the opposite.Events fired on a shape will be passed to on eventName. Again note the space.
'on click': ->
alert 'Something was clicked!'
And each shape can have its own event handlers:
'on click spot': ->
alert 'A spot was clicked!'
Some special event names are *start, *drag, and *end, which work with mouse and touch events.
ToolControls are associated with a Tool instance. Provide markup in the template property. Its render method is called when its tool's mark changes, and should update the markup to reflect the state of the mark. Position the controls near the tool with moveTo, which can be called from render or from the its tool's render method.
A MarkingSurface is just a holder for tools. Instantiate one, and pass it a tool property. Then append its el where you need it.
ms = new MarkingSurface tool: PointTool
document.body.appendChild ms.el
During development, run cake serve to run a CoffeeScript-friendly dev server and compile from src to lib.
FAQs
Marking surface ===============
We found that marking-surface demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.