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.

              <script src="https://rawgit.com/kirbysayshi/6654845/raw/boid.js"></script><script src="https://rawgit.com/kirbysayshi/6654845/raw/drawing.js"></script>
<script src="https://rawgit.com/kirbysayshi/6654845/raw/stepstate.js"></script>
              html, body { margin: 0; padding: 5px; font-family: Helvetica, sans; }
canvas { padding: 10px; }
p { font-size: 10px; }
// Shared code available at https://gist.github.com/kirbysayshi/6654845

var ctx0 = ctx('Fixed DT (100) drawn at 60fps')
  , ctx1 = ctx('Fixed DT (100) drawn interpolated at 60fps')

var boid0 = new Boid(25, 25, 25)
  , boid1 = new Boid(25, 25, 25)

var acceleration = 5;

boid0.acel.x += acceleration;
boid1.acel.x += acceleration;

var ssi = new StepStateInterpolator(100, function logics(dt) {
  // dt is the target, constant dt.
  boid0.boundsCheck(ctx0.canvas.width, acceleration);
  boid1.boundsCheck(ctx1.canvas.width, acceleration);
}, function draws(dt, ratio) {
  drawCurrentPosition(ctx0, boid0);
  drawInterpolatedPosition(ctx1, boid1, ratio);

var lastTime = Date.now() - 16.666666;

(function frame() {
  var now = Date.now();
  var dt = now - lastTime;
  //return false; // Uncomment to halt drawing while developing :)
  lastTime = now;
Loading ..................