cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              body
  height: 100%
  background: #444
    
canvas 
  position: absolute
  top: 50%
  left: 50% 
  transform: translate(-50%,-50%)
            
          
!
            
              SIZE = 400
quarterSize = SIZE / 4
threQuarters = SIZE - quarterSize;
TWO_PI = Math.PI * 2

createCanvas = ->
  canvas = document.createElement "canvas"
  canvas.width = SIZE
  canvas.height = SIZE
  canvas

canvas = createCanvas()
document.body.appendChild(canvas)
c = canvas.getContext("2d")
trails = createCanvas() 
ct = trails.getContext("2d")

clear = ->
  c.fillStyle = "black"
  c.fillRect 0, 0, SIZE, SIZE
  ct.fillStyle = "black"
  ct.fillRect 0, 0, SIZE, SIZE
  return

clear()
document.getElementById("erase").onclick = clear

class DrawingThing
  constructor : (x, y) ->
    @x = x
    @y = y
    @radii = [30 , 60, 90]
    @num = @radii.length
    @thetas = [Math.random() * TWO_PI
               Math.random() * TWO_PI
               Math.random() * TWO_PI]
    @thetasInc = [Math.random() * 0.2 - 0.1
                  Math.random() * 0.2 - 0.1 
                  Math.random() * 0.2 - 0.1]

  draw : ->
    ct.strokeStyle = "rgba(255,255,255,0.1)"
    for i in [0...@num]
      x = @x + @radii[i] * Math.cos(@thetas[i])
      y = @y + @radii[i] * Math.sin(@thetas[i])

      if i == 0
        ct.beginPath();
        ct.moveTo(x, y);
      else
        ct.lineTo(x, y);

      c.strokeStyle = "rgba(255,255,255,0.5)"
      c.fillStyle = "white"
      c.beginPath()
      c.arc(@x, @y, @radii[i], 0, TWO_PI, false)
      c.stroke();

      c.beginPath();
      c.arc(x, y, 2, 0, TWO_PI, false);
      c.fill();
      @thetas[i] += @thetasInc[i];

    ct.closePath();
    ct.stroke();

    return

drawingThings = [new DrawingThing(quarterSize, quarterSize)
                 new DrawingThing(threQuarters, quarterSize)
                 new DrawingThing(threQuarters, threQuarters)
                 new DrawingThing(quarterSize, threQuarters)];

setInterval(->
  c.drawImage(trails, 0, 0)

  for drawThing in drawingThings
    drawThing.draw()

 , 30);

return








            
          
!
999px
Loading ..................

Console