Skip to content

Instantly share code, notes, and snippets.

@jasongilman
Created June 7, 2016 00:24
Show Gist options
  • Save jasongilman/47a52766bb59be7b77fd6f76676f6925 to your computer and use it in GitHub Desktop.
Save jasongilman/47a52766bb59be7b77fd6f76676f6925 to your computer and use it in GitHub Desktop.
Atom Canvas Block Decoration
// Paste this into the inspector in Atom.
var element = document.createElement('div')
var canvas = document.createElement("canvas")
element.appendChild(canvas)
element.style.setProperty("width", "100%")
element.style.setProperty("height", "150px")
canvas.style.setProperty("width", "100%")
canvas.style.setProperty("height", "100%")
canvas.style.setProperty("background-color", "white")
var editor = atom.workspace.getActiveTextEditor()
var marker = editor.markScreenPosition([0, 0])
editor.decorateMarker(marker, {type: 'block', position: 'before', item: element})
ctx = canvas.getContext("2d")
ctx.beginPath()
ctx.moveTo(0,0)
ctx.lineTo(25,24)
ctx.stroke()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment