Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add a vector / illustrated style cylinder example.

  • Loading branch information...
commit 5453b65bbb289b074827c73f53859b68b1289be2 1 parent 4d337c5
Dean McNamee authored

Showing 1 changed file with 40 additions and 0 deletions. Show diff stats Hide diff stats

  1. 40  demos/path_cylinder.js
40  demos/path_cylinder.js
... ...
@@ -0,0 +1,40 @@
  1
+// (c) Dean McNamee <dean@gmail.com>.  All rights reserved.
  2
+
  3
+function start3d() {
  4
+  var screen_canvas = document.getElementById('canvas');
  5
+  var renderer = new Pre3d.Renderer(screen_canvas);
  6
+
  7
+  var circle = Pre3d.PathUtils.makeCircle();
  8
+
  9
+  renderer.ctx.setStrokeColor(0x52 / 255, 0xbb / 255, 0x5c / 255, 1);
  10
+  renderer.ctx.lineWidth = 2;
  11
+
  12
+  function draw() {
  13
+    // White background.
  14
+    renderer.ctx.setFillColor(1, 1, 1, 1);
  15
+    renderer.drawBackground();
  16
+
  17
+    renderer.transform.reset();
  18
+    renderer.transform.translate(-0.5, 0, 0);  // Center over the origin.
  19
+
  20
+    var side_line = Pre3d.PathUtils.makeLine({x: 0, y: 0, z: -0.5},
  21
+                                             {x: 0, y: 0, z: -5});
  22
+    renderer.pushTransform();
  23
+    for (var i = 0, il = 8; i < il; ++i) {
  24
+      renderer.transform.rotateZ(1/il * Math.PI * 2);
  25
+      renderer.drawPath(side_line);
  26
+    }
  27
+    renderer.popTransform();
  28
+
  29
+    for (var i = 0; i < 10; ++i) {
  30
+      renderer.transform.translate(0, 0, -0.5);
  31
+      renderer.drawPath(circle);
  32
+    }
  33
+  }
  34
+
  35
+  renderer.camera.focal_length = 2.5;
  36
+  DemoUtils.autoCamera(renderer, 0, 0, -8, 0, 0, 0, draw);
  37
+  draw();
  38
+}
  39
+
  40
+start3d();

0 notes on commit 5453b65

Please sign in to comment.
Something went wrong with that request. Please try again.