@state = {}; @drawMapLength = @drawMap.length
@extendDefaults()
@calcTransform()
calcTransform:->
rotate = "rotate(#{@props.angle}, #{@props.x}, #{@props.y})"
@props.transform = "#{rotate}"
extendDefaults:->
@props ?= {}
for key, value of @defaults
@props[key] = if @o[key]? then @o[key] else value
setAttr:(attr, value)->
if typeof attr is 'object'
keys = Object.keys(attr); len = keys.length; el = value or @el
while(len--)
key = keys[len]; val = attr[key]
el.setAttribute key, val
else @el.setAttribute attr, value
setProp:(attr, value)->
if typeof attr is 'object'
for key, val of attr
@props[key] = val
else @props[attr] = value
render:->
@isRendered = true
if @o.el? then @el = @o.el; @isForeign = true
else
@el = document.createElementNS @ns, @type or 'line'
!@o.isDrawLess and @draw(); @ctx.appendChild @el
drawMap: [
'stroke', 'stroke-width', 'stroke-opacity', 'stroke-dasharray', 'fill',
'stroke-dashoffset', 'stroke-linecap', 'fill-opacity', 'transform',
]
draw:->
@props.length = @getLength()
len = @drawMapLength
while(len--)
name = @drawMap[len]
switch name
when 'stroke-dasharray', 'stroke-dashoffset'
@castStrokeDash name
--> COVER return if not ctx and not el return true