Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace JSRender:Primitives:
- class AbstractElement
- render: abstract
- element: (ctx, cb) ->
- stroke = ctx.strokeStyle
- fill = ctx.fillStyle
- ctx.beginPath()
- cb(ctx)
- ctx.closePath()
- ctx.strokeStyle = stroke
- ctx.fillStyle = fill
- before: (render) ->
- render.before (c) => @render(c)
- @
- after: (render) ->
- render.after (c) => @render(c)
- @
- namespace JSRender:Primitives:
- class HLine extends JSRender.Primitives.AbstractElement
- constructor: (opt = {})->
- @x = watch opt.x || 0
- @y = watch opt.y || 0
- @width = watch opt.width || 0
- @color = watch opt.color || false
- @size = watch opt.size || 1
- render: (ctx) ->
- @element ctx, =>
- if @color() isnt false
- ctx.moveTo @x(), @y()
- ctx.lineTo @x() + @width(), @y()
- ctx.strokeStyle = @color()
- ctx.lineWidth = @size()
- ctx.stroke()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement