         paths
 
     paths.url = () ->
-      "url(#" + paths.id() + ")"
-        
+      "url(##{id})"
+
     paths
-
-}

    path = (orientation) ->
      switch orientation
        when "0/8" then do (s=size) -> "M "+s/2+", 0 l 0, "+s
        when "vertical" then do (s=size) -> "M "+s/2+", 0 l 0, "+s
        when "1/8" then do (s=size) -> "M "+s/4+",0 l "+s/2+","+s+" M "+-s/4+",0 l "+s/2+","+s+" M "+s*3/4+",0 l "+s/2+","+s
        when "2/8" then do (s=size) -> "M 0,"+s+" l "+s+","+-s+" M "+-s/4+","+s/4+" l "+s/2+","+-s/2+" M "+3/4*s+","+5/4*s+" l "+s/2+","+-s/2
        when "diagonal" then do (s=size) -> "M 0,"+s+" l "+s+","+-s+" M "+-s/4+","+s/4+" l "+s/2+","+-s/2+" M "+3/4*s+","+5/4*s+" l "+s/2+","+-s/2
        when "3/8" then do (s=size) -> "M 0,"+3/4*s+" l "+s+","+-s/2+" M 0,"+s/4+" l "+s+","+-s/2+" M 0,"+s*5/4+" l "+s+","+-s/2
        when "4/8" then do (s=size) -> "M 0,"+s/2+" l "+s+",0"
        when "horizontal" then do (s=size) -> "M 0,"+s/2+" l "+s+",0"
        when "5/8" then do (s=size) -> "M 0,"+-s/4+" l "+s+","+s/2+"M 0,"+s/4+" l "+s+","+s/2+"M 0,"+s*3/4+" l "+s+","+s/2
        when "6/8" then do (s=size) -> "M 0,0 l "+s+","+s+" M "+-s/4+","+3/4*s+" l "+s/2+","+s/2+" M "+s*3/4+","+-s/4+" l "+s/2+","+s/2
        when "7/8" then do (s=size) -> "M "+-s/4+",0 l "+s/2+","+s+" M "+s/4+",0 l "+s/2+","+s+" M "+s*3/4+",0 l "+s/2+","+s
        else do (s=size) -> "M "+s/2+", 0 l 0, "+s

    lines = () ->
      g = this.append("defs")
          .append("pattern")
          .attr("id", id)
          .attr("patternUnits", "userSpaceOnUse")
          .attr("width", size)
          .attr("height", size)
      if background
        g.append("rect")
            .attr("width", size)
            .attr("height", size)
            .attr("fill", background)
      for o in orientation
        g.append("path")
            .attr("d", path(o))
            .attr("stroke-width", strokeWidth)
            .attr("shape-rendering", shapeRendering)
            .attr("stroke", stroke)
            .attr("stroke-linecap", "square")

    lines.background = (_) ->
      background = _



# helper function
rand = () ->
  "#{Math.random().toString(36)}00000000000000000"
    .replace /[^a-z]+/g, ""
    .slice 0, 5

umd = (factory) ->
  if typeof exports is 'object'
    module.exports = factory()
  else if typeof define is 'function' and define.amd
    define [], factory
  else
    @textures = factory()

# global factory
umd ->

  # circles ------------------------------------------------------------

  circles: () ->
    size = 20
    background = ""
    radius = 2
