Skip to content

Instantly share code, notes, and snippets.

@dom96
Created June 7, 2016 13:36
Show Gist options
  • Save dom96/18413eb7e06b58727cc4d457c6b76fc9 to your computer and use it in GitHub Desktop.
Save dom96/18413eb7e06b58727cc4d457c6b76fc9 to your computer and use it in GitHub Desktop.
import dom
type
CanvasRenderingContext* = ref object
fillStyle* {.importc.}: cstring
strokeStyle* {.importc.}: cstring
width* {.importc.}: int
height* {.importc.}: int
shadowColor* {.importc.}: cstring
shadowBlur* {.importc.}: int
lineWidth* {.importc.}: int
font* {.importc.}: cstring
ContextAttributes* = ref object
alpha* {.importc.}: bool
# TODO: WebGL
{.push importcpp.}
proc getContext*(canvasElement: Element, contextType: cstring,
contextAttributes = ContextAttributes(alpha: true)): CanvasRenderingContext
proc fillRect*(context: CanvasRenderingContext,
x, y, width, height: int)
proc beginPath*(context: CanvasRenderingContext)
proc moveTo*(context: CanvasRenderingContext, x, y: int)
proc lineTo*(context: CanvasRenderingContext, x, y: int)
proc stroke*(context: CanvasRenderingContext)
proc fillText*(context: CanvasRenderingContext, text: cstring, x, y: int)
proc translate*(context: CanvasRenderingContext, x, y: int)
proc setTransform*(context: CanvasRenderingContext, a, b, c, d, e, f: int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment