Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-1"></div>
    <div class="col-sm-10">
      <br/>
      <br/>
      <br/><br/>
        <canvas id="canvas01" width="1200" height="400"></canvas>
      <br/>
       <button type="button" class="btn btn-xs btn-dark" id="startStop">start/stop</button>
      <button type="button" class="btn btn-xs btn-dark" id="slowFast">slow/fast</button>
<!--       <pre><code id="dump"></pre></code> -->
    </div>
    <div class="col-sm-1"></div>
  </div>
              
            
!

CSS

              
                body {
  background-color: #222;
  margin: 0;
  padding-left: 40px;
  padding-top: 40px;
  
}

#canvas01 {
  background-color: #222;
  position: relative;
  /*   top: 50%;
  left: 50%; */
  /*   transform: translate(-50%, -50%); */
  width: 600px;
  height: 200px;
}

pre {
  max-width: 480px;
  color: indianred;
  white-space: normal;
  background-color: #111;
  border-color: #333;
}

.btn-dark {
  color: #000000;
  background-color: #777;
  border-color: #555;
  outline: none;
}

.btn-dark:hover,
.btn-dark:focus,
.btn-dark:active,
.open .dropdown-toggle.btn-dark {
  color: #222222;
  background-color: #888;
  border-color: #444;
  outline: none;
}

.btn.active.focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn:active:focus, .btn:focus{
  outline: none;
}
              
            
!

JS

              
                var canvas = document.getElementById("canvas01");
var ctx = canvas.getContext("2d");
var iso = new Isomer(canvas);
var Shape = Isomer.Shape;
var Point = Isomer.Point;
var Color = Isomer.Color;
var Path = Isomer.Path;
var blueT = new Color(0, 255, 255, 0.2);
var blue = new Color(0, 255, 255, 1);
var goldenR = new Color(218, 165, 32, 0.2);
var white = new Color(255, 255, 255, 0.2);
var gOffset = -1.5;
var Grid = makeGrid(2, 2, gOffset);
var N1 = Shape.Prism(Point(2.5, 6.5, gOffset), 1, 1, 0.8);
var N2 = Shape.Prism(Point(2.5, 4.5, gOffset), 1, 1, 0.8);
var N3 = Shape.Prism(Point(2.5, 2.5, gOffset), 1, 1, 0.8);
var N4 = Shape.Prism(Point(2.5, 0.5, gOffset), 1, 1, 0.8);
var running = false;
var rate = 1;
var incDec = true;
var slowFast = document.getElementById("slowFast");


var pN3 = new Path([
  new Point(3, 1.5, (0.4) + gOffset),
  new Point(3, 2.5, (0.4) + gOffset),
  new Point(3, 2.5, (0.4) + gOffset)
]);

var pN2 = new Path([
  new Point(3, 3.5, (0.4) + gOffset),
  new Point(3, 4.5, (0.4) + gOffset),
  new Point(3, 4.5, (0.4) + gOffset)
]);

var pN1 = new Path([
  new Point(3, 5.5, (0.4) + gOffset),
  new Point(3, 6.5, (0.4) + gOffset),
  new Point(3, 6.5, (0.4) + gOffset)
]);

var pN4 = new Path([
  new Point(2.5, 1, (0.4) + gOffset),
  new Point(1.5, 1, (0.4) + gOffset),
  new Point(1.5, 7, (0.4) + gOffset),
  new Point(2.5, 7, (0.4) + gOffset),
  new Point(1.5, 7, (0.4) + gOffset),
  new Point(1.5, 1, (0.4) + gOffset)
]);

var fillA1p = 0;
var fA1 = false;



function fillN1() {
  fA1 = false;
  var A1B = Shape.Prism(Point(2.5, 6.5 + (1 - fillA1p / 100), gOffset), 1, fillA1p / 100, 0.8);
  iso.add(A1B, blueT);
  if (fillA1p < 100) {    
          fillA1p = Math.min(fillA1p + rate, 100);
  } else if (fillA2p >= 100){
    fA1 = true;
    fillA1p = 0;
     ctx.fillStyle = "rgba(0, 255, 255, 0.6)";
     ctx.fillText('Neuron 1', 440, 50);
  }
}

var fillA2p = 100;
var fA2 = false;

function fillA2() {
  fA2 = false;
  var A2B = Shape.Prism(Point(2.5, 4.5 + (1 - fillA2p / 100), gOffset), 1, fillA2p / 100, 0.8);
  iso.add(A2B, blueT);

  if (fA1 && fillA2p >= 100) {
    fA2 = true;
    fillA2p = 0;
    ctx.fillStyle = "rgba(0, 255, 255, 0.6)";
    ctx.fillText('Neuron 2', 540, 110);
  } else if (fillA2p < 100) {
        fillA2p = Math.min(fillA2p + rate, 100);
  }
}

var fillA3p = 100;
var fA3 = false;

function fillA3() {
  fA3 = false;
  var A3B = Shape.Prism(Point(2.5, 2.5 + (1 - fillA3p / 200), gOffset), 1, fillA3p / 200, 0.8);
  iso.add(A3B, blueT);

  if (fA2 && fillA3p >= 200) {
    fA3 = true;
    fillA3p = 0;
    ctx.fillStyle = "rgba(0, 255, 255, 0.6)";
    ctx.fillText('Neuron 3', 640, 170);
  } else if (fillA3p < 200) {
    fillA3p = Math.min(fillA3p + rate, 200);
  }
}

var fillA4p = 20;
var fA4 = false;

function fillA4() {
  fA4 = false;
  var A4B = Shape.Prism(Point(2.5, 0.5 + (1 - fillA4p / 20), gOffset), 1, fillA4p / 20, 0.8);
  iso.add(A4B, blueT);

  if (fA3 && fillA4p >= 20) {
    fA4 = true;
    fillA4p = 0;
    ctx.fillStyle = "rgba(0, 255, 255, 0.6)";
    ctx.fillText('Neuron 4', 740, 230);    
  } else if (fillA4p < 20 ) {      
    fillA4p = Math.min(fillA4p + rate, 20);
  }
}


function text() {
  // TEXT : 
  ctx.font = '24px Arial';
  ctx.fillStyle = "rgba(255, 255, 255, 0.1)";
  ctx.fillText('Neuron 1', 440, 50);
  ctx.fillText('Neuron 2', 540, 110);
  ctx.fillText('Neuron 3', 640, 170);
  ctx.fillText('Neuron 4', 740, 230);
}

function draw() {
  iso.canvas.clear();
  text();
  fA1 ? (iso.add(pN1, blue)) : (iso.add(pN1, blueT));
  fA2 ? (iso.add(pN2, blue)) : (iso.add(pN2, blueT));
  fA3 ? (iso.add(pN3, blue)) : (iso.add(pN3, blueT));
  iso.add(Grid.translate(2, 0, 0), goldenR);
  iso.add(Grid.translate(2, 2, 0), goldenR);
  iso.add(Grid.translate(2, 4, 0), goldenR);
  iso.add(Grid.translate(2, 6, 0), goldenR);
  iso.add(N1, white);
  iso.add(N2, white);
  iso.add(N3, white);
  iso.add(N4, white);
  fillN1();
  fillA2();
  fillA3();
  fillA4();
  if (running) {
    requestAnimationFrame(draw)
  };
}

function init() {
  draw();
}

init();

document.getElementById("startStop").onclick = function() {
  running = !running;
  draw();
  //  console.log(running);
}


slowFast.onclick = function() {
  if (rate < 20 && incDec){
    inceDec = true;
    rate++; 
    slowFast.innerHTML = 'Faster';
  } else if( rate > 0 ){
    incDec = false;
    slowFast.innerHTML = 'Slower';
    rate--;
  } else {
    incDec = !incDec;
    slowFast.innerHTML = 'stalled';
  }
  console.log(rate);
}

// GridMaker V2
function makeGrid(xSize, ySize, zHeight) {
  var paths = new Path;
  for (x = 0; x < xSize + 1; x++) {
    paths.push(new Point(x, 0, zHeight));
    paths.push(new Point(x, xSize, zHeight));
    paths.push(new Point(x, 0, zHeight));
  };
  for (y = 0; y < ySize + 1; y++) {
    paths.push(new Point(0, y, zHeight));
    paths.push(new Point(ySize, y, zHeight));
    paths.push(new Point(0, y, zHeight));
  };
  return paths;
}
              
            
!
999px

Console