lamp
by mistercrunch
HTML
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="2160px" height="1440px" viewBox="0 0 2160 1440" enable-background="new 0 0 2160 1440" xml:space="preserve">
</svg>
CSS
path, circle, rect {
stroke:grey;
fill:none;
}
circle {
stroke:black;
fill:none;
}
JavaScript
var height_inches = 11.5;
var width_inches = 116.0;
var nb_pieces = 100.0;
var one_inch = 72.0;
var dent_size = (one_inch/8) * 0.95;
var r = one_inch * 2.5;
var r = ((height_inches / 1.618)/2) * one_inch;
var ring_width = one_inch * 1;
var height = one_inch * height_inches;
var definition = 200;
num_wave = 5.0;
margin = 0.0;
dent_perc = 0.10;
var base_width = dent_size * 2;
var overall_width = width_inches * one_inch;
var curve_width = (overall_width / nb_pieces) - (2*base_width);
var width = (2*base_width) + curve_width;
var svg = d3.select('svg');
curves = [];
lines = [];
function lfo(perc_height, perc_width, num_waves, amplitude, drop_factor, every){
perc = (num_waves * perc_height) + (perc_width * drop_factor);
if(Math.round(perc) % every == 0){
cos = Math.cos(perc * 2* Math.PI);
val = ((cos+1)/2) * amplitude;
}
else {
val = 0;
}
return val;
}
for(i=0; i<nb_pieces; i++){
perc_width = (i/nb_pieces);
offset = i*(width+margin);
curve_offset = offset + base_width;
lines.push([
[offset + width, height],
[offset, height],
[offset, 0],
[offset + width, 0]
]);
curve = [];
for(j=0; j<=definition; j++){
perc_height = (j/definition);
lfo_1 = lfo(perc_height, perc_width, 5, curve_width, 8, 2);
lfo_2 = lfo(perc_height, perc_width, 10, curve_width, -32, 4);
lfo_3 = lfo(perc_height, perc_width, 20, curve_width, 64, 4);
curve.push([
curve_offset + d3.max([lfo_1, lfo_2, lfo_3]),
(height / definition) * j
]);
}
curves.push(curve);
// Dents to fit in
line = []
y = dent_perc * height;
line.push([offset, y - (dent_size/2) ]);
line.push([offset+dent_size, y - (dent_size/2) ]);
line.push([offset+dent_size, y + (dent_size/2) ]);
line.push([offset, y + (dent_size/2) ]);
lines.push(line)
line = []
y =...