Browse Source

Complete options panel

Tyler Hallada 9 years ago
parent
commit
3671e5c7fc
4 changed files with 67 additions and 4 deletions
  1. 1 0
      _data/magic.yml
  2. 49 0
      css/main.css
  3. 8 2
      js/magic.js
  4. 9 2
      magic/index.html

+ 1 - 0
_data/magic.yml

@@ -7,3 +7,4 @@ minDuration: 50
7 7
 splineLength: 15
8 8
 maxAngleChange: 180
9 9
 minAngleChange: 90
10
+randomColored: true

+ 49 - 0
css/main.css

@@ -432,3 +432,52 @@ a.no-decoration:hover {
432 432
   color: #444;
433 433
   text-decoration: none;
434 434
 }
435
+
436
+/*****************************************************************************/
437
+/*
438
+/* Magic
439
+/*
440
+/*****************************************************************************/
441
+
442
+div.options-panel {
443
+  position: fixed;
444
+  bottom: 0;
445
+  left: 0;
446
+  padding: 10px;
447
+  width: 100%;
448
+  z-index: 10;
449
+  height: auto;
450
+  background-color: rgba(140,120,100,0.75);
451
+  color: white;
452
+}
453
+
454
+div.controls-tab {
455
+  position: relative;
456
+}
457
+
458
+div.controls {
459
+  position: absolute;
460
+  top: -2.6rem;
461
+  right: 1rem;
462
+  height: 2rem;
463
+  padding-right: 5px;
464
+  padding-left: 5px;
465
+  background-color: rgba(140,120,100,0.75);
466
+}
467
+
468
+div.controls button {
469
+  padding: 0.25rem;
470
+  margin-top: 0.25rem;
471
+  background-color: rgb(100, 100, 100);
472
+  border: 1px grey solid;
473
+  color: white;
474
+  font-size: small;
475
+}
476
+
477
+div.options-panel form {
478
+  text-align: center
479
+}
480
+
481
+div.options-panel form label {
482
+  display: block;
483
+}

+ 8 - 2
js/magic.js

@@ -31,6 +31,9 @@ var Magic = function (options) {
31 31
     // Average length of new spline (branch)
32 32
     this.splineLength = options.splineLength || 15;
33 33
 
34
+    // Whether new spells are cast with a new random color
35
+    this.randomColored = options.randomColored || true;
36
+
34 37
     this.paused = false;
35 38
 
36 39
     // Save this query here now that the page is loaded
@@ -174,8 +177,11 @@ Magic.prototype.cast = function(x, y, angle, chain) {
174 177
         angle = Math.random() * 360;
175 178
     }
176 179
 
177
-    var color = this.pickRandomColor();
178
-    var colorString = "rgb(" + color.r + "," + color.g + "," + color.b + ")";
180
+    var colorString = "rgb(10,10,10)";
181
+    if (this.randomColored) {
182
+        var color = this.pickRandomColor();
183
+        colorString = "rgb(" + color.r + "," + color.g + "," + color.b + ")";
184
+    }
179 185
 
180 186
     // Create new spell (branch)
181 187
     this.spells.push({

+ 9 - 2
magic/index.html

@@ -81,18 +81,25 @@ title: Tyler Hallada
81 81
       </div>
82 82
     </div>
83 83
     <div class="row clearfix">
84
-      <div class="column half">
84
+      <div class="column third">
85 85
         <form oninput="output.value=minAngleChange.value;updateMagic('minAngleChange', parseInt(minAngleChange.value))">
86 86
           <label for="minAngleChange">Min Angle</label>
87 87
           <input type="range" min=0 max=360 value={{site.data.magic.minAngleChange}} id="minAngleChange" step=1>
88 88
           <output name="output" for="minAngleChange">{{site.data.magic.minAngleChange}}</output>
89 89
         </form>
90 90
       </div>
91
-      <div class="column half">
91
+      <div class="column third">
92 92
         <form oninput="output.value=maxAngleChange.value;updateMagic('maxAngleChange', parseInt(maxAngleChange.value))">
93 93
           <label for="maxAngleChange">Max Angle</label>
94 94
           <input type="range" min=0 max=360 value={{site.data.magic.maxAngleChange}} id="maxAngleChange" step=1>
95 95
           <output name="output" for="maxAngleChange">{{site.data.magic.maxAngleChange}}</output>
96 96
         </form>
97 97
       </div>
98
+      <div class="column third">
99
+        <form onchange="output.value=randomColored.checked;updateMagic('randomColored', randomColored.checked)">
100
+          <label for="randomColored">Randomly Colored</label>
101
+          <input type="checkbox" {% if site.data.magic.randomColored %}checked{% endif %} id="randomColored">
102
+          <output name="output" for="randomColored">{{site.data.magic.randomColored}}</output>
103
+        </form>
104
+      </div>
98 105
 </div>