added color selector

This commit is contained in:
eelfroth 2017-01-06 04:38:24 +01:00
parent b63d6ce4f1
commit 2fcf524e79
2 changed files with 15 additions and 9 deletions

View File

@ -237,6 +237,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
break; break;
case "strokeLinecap": case "strokeLinecap":
vector_element.style.strokeLinecap = value; vector_element.style.strokeLinecap = value;
break;
case "stroke":
vector_element.style.stroke = value;
} }
} }
} }

View File

@ -33,6 +33,7 @@
<option value="round">round</option> <option value="round">round</option>
<option value="square">square</option> <option value="square">square</option>
</select> </select>
<b>COLOR</b> <input id="color" type="color" value="#000000" onchange="dotgrid.update_style('stroke', this.value);">
<b>WIDTH</b> <input id="width" type="number" value="490" min="1" step="1"> <b>WIDTH</b> <input id="width" type="number" value="490" min="1" step="1">
@ -43,7 +44,8 @@
</pre> </pre>
<script> <script>
var new_grid = function() { return new Dotgrid(document.getElementById('width').value, var new_grid = function() {
return new Dotgrid(document.getElementById('width').value,
document.getElementById('height').value, document.getElementById('height').value,
Math.round( document.getElementById('width').value / document.getElementById('grid').value ), Math.round( document.getElementById('width').value / document.getElementById('grid').value ),
Math.round( document.getElementById('height').value / document.getElementById('grid').value ), Math.round( document.getElementById('height').value / document.getElementById('grid').value ),
@ -51,7 +53,8 @@
document.getElementById('block').value, document.getElementById('block').value,
document.getElementById('thickness').value, document.getElementById('thickness').value,
document.getElementById('linecap').value, document.getElementById('linecap').value,
"#000000"); }; document.getElementById('color').value);
};
dotgrid = new_grid(); dotgrid = new_grid();
dotgrid.install(); dotgrid.install();
var keyboard = new Keyboard(); var keyboard = new Keyboard();