Skip to content

Instantly share code, notes, and snippets.

@joa
Created January 6, 2016 12:12
Show Gist options
  • Select an option

  • Save joa/6d82003859fddd17752b to your computer and use it in GitHub Desktop.

Select an option

Save joa/6d82003859fddd17752b to your computer and use it in GitHub Desktop.

Revisions

  1. joa created this gist Jan 6, 2016.
    47 changes: 47 additions & 0 deletions glc_circles.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    function onGLC(glc) {
    glc.loop();
    glc.size(400, 400);
    glc.setDuration(2);
    glc.setFPS(60);
    glc.setMode('single');
    glc.setEasing(false);
    var list = glc.renderList,
    width = glc.w,
    height = glc.h,
    color = glc.color;

    // your code goes here:

    var circleCount = 12
    var circleCountSquare = circleCount * circleCount
    var circleRadius = width / (circleCount + 1)

    var innerCircleIndex = 0

    for(var x = 0; x < circleCount; ++x) {
    for(var y = 0; y < circleCount; ++y) {
    var outerCircle = list.addCircle({
    x: (x + 1) * circleRadius,
    y: (y + 1) * circleRadius,
    radius: circleRadius,
    fill: false,
    stroke: true,
    strokeStyle: "#121212",
    rotation: [0, 360]
    })

    var phase = innerCircleIndex / (circleCount * 1.06125)

    var innerCircle = list.addCircle({
    x: circleRadius * Math.cos(phase * Math.PI * 2.0),
    y: circleRadius * Math.sin(phase * Math.PI * 2.0),
    radius: circleRadius * 0.1,
    fill: true,
    fillStyle: "#121212",
    parent: outerCircle
    })

    ++innerCircleIndex
    }
    }
    }