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.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

               <canvas id="c"></canvas>
 Current factor:
 <input id="factor" onchange="setFactor()" type="number" value="0">
 <input id="speed" onchange="setSpeed()" type="number" value="0.1">
 <button onclick="play()" style="cursor:pointer;">Play</button>
 <button onclick="stop()" style="cursor:pointer;">Stop</button>

 * Copyright (C) 2016
 * Created by missingdays
 * Distributed under terms of the MIT license.

var canvas = new fabric.Canvas("c");

var center = [300, 300];
var radius = 250;
canvas.setHeight(center[0] * 2);
canvas.setWidth(center[1] * 2);

// Number of circles
var n = 200;

var circlesCoords = [];
var circles = [];
var lines = [];

var options = {
    factor: 0,
    speed: 0.1,
    stopped: false,

var inputFactor = document.getElementById("factor");
var inputSpeed = document.getElementById("speed");

function makeLine(coords){
    return new fabric.Line(coords, {
        fill: "#FF6B35",
        stroke: "#FF6B35",
        strokeWidth: 1,
        selectable: false

function makeCircle(left, top){
    return new fabric.Circle({
        left: left - 2,
        top: top - 2,
        strokeWidth: 1,
        radius: 2,
        fill: "#fff",
        stroke: "#777"

function init(){

    for(var i = 0; i < n; i++){

        var left = center[0] + radius * Math.cos(i * 2 * Math.PI / n);
        var top = center[1] + radius * Math.sin(i * 2 * Math.PI / n);

        circlesCoords.push([left, top]);

        var circle = makeCircle(left, top);

    for(var i = 1; i < n; i++){
        lines.push(makeLine([0, 0, 0, 0]));

    canvas.add.apply(canvas, circles);
    canvas.add.apply(canvas, lines);

 * c is a factor of multiplication
function redraw(c){
    for(var i = 0; i < n - 1; i++){
        var x1 = circlesCoords[i][0];
        var y1 = circlesCoords[i][1];
        var x2 = circlesCoords[Math.floor(c * i) % n][0];
        var y2 = circlesCoords[Math.floor(c * i) % n][1];

        var line = lines[i];
        line.set("x1", x1);
        line.set("x2", x2);
        line.set("y1", y1);
        line.set("y2", y2)

function nextFrame(timestamp){


    options.factor += options.speed;

    inputFactor.value = options.factor;


function play(){
        options.stopped = false;

function stop(){
    options.stopped = true;

function setFactor(){
    options.factor = parseFloat(inputFactor.value);

function setSpeed(){
    options.speed = parseFloat(inputSpeed.value);


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................