OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <style> | 2 <style> |
3 .group { | 3 .group { |
4 width: 400px; | 4 width: 400px; |
5 } | 5 } |
6 </style> | 6 </style> |
7 <body></body> | 7 <body></body> |
8 <script> | 8 <script> |
9 function createSvgElement(name, attributes) { | 9 function createSvgElement(name, attributes) { |
10 var element = document.createElementNS('http://www.w3.org/2000/svg', name); | 10 var element = document.createElementNS('http://www.w3.org/2000/svg', name); |
(...skipping 18 matching lines...) Expand all Loading... |
29 "hue", | 29 "hue", |
30 "saturation", | 30 "saturation", |
31 "color", | 31 "color", |
32 "luminosity" | 32 "luminosity" |
33 ]; | 33 ]; |
34 | 34 |
35 [ | 35 [ |
36 {a: 'rgb(255,0,0)', b: 'rgb(0,255,0)' }, | 36 {a: 'rgb(255,0,0)', b: 'rgb(0,255,0)' }, |
37 {a: 'rgb(51,64,204)', b: 'rgb(153,192,102)' }, | 37 {a: 'rgb(51,64,204)', b: 'rgb(153,192,102)' }, |
38 {a: 'rgba(51,64,204,0.5)', b: 'rgba(153,192,102,0.5)' }, | 38 {a: 'rgba(51,64,204,0.5)', b: 'rgba(153,192,102,0.5)' }, |
39 ].forEach(function(colors) { | 39 ].forEach(function(colors, groupNr) { |
40 var group = document.createElement('div'); | 40 var group = document.createElement('div'); |
41 group.className = 'group'; | 41 group.className = 'group'; |
42 document.body.appendChild(group); | 42 document.body.appendChild(group); |
43 | 43 |
44 blendModes.forEach(function(mode, i) { | 44 blendModes.forEach(function(mode) { |
45 var filterId = 'f_' + mode; | 45 var filterId = 'f_' + mode + groupNr; |
46 var filter = createSvgElement('filter', { id: filterId, x: 0, y: 0, width: 1
, height: 1 }); | 46 var filter = createSvgElement('filter', { id: filterId, x: 0, y: 0, width: 1
, height: 1 }); |
47 filter.appendChild(createSvgElement('feFlood', { result: 'a', 'flood-color':
colors.a })); | 47 filter.appendChild(createSvgElement('feFlood', { result: 'a', 'flood-color':
colors.a })); |
48 filter.appendChild(createSvgElement('feFlood', { result: 'b', 'flood-color':
colors.b })); | 48 filter.appendChild(createSvgElement('feFlood', { result: 'b', 'flood-color':
colors.b })); |
49 filter.appendChild(createSvgElement('feBlend', { in: 'a', in2: 'b', mode: mo
de })); | 49 filter.appendChild(createSvgElement('feBlend', { in: 'a', in2: 'b', mode: mo
de })); |
50 var svgRoot = createSvgElement('svg', { width: '50', height: '50' }); | 50 var svgRoot = createSvgElement('svg', { width: '50', height: '50' }); |
51 var rect = createSvgElement('rect', { width: 50, height: 50, filter: 'url(#'
+ filterId + ')' }); | 51 var rect = createSvgElement('rect', { width: 50, height: 50, filter: 'url(#'
+ filterId + ')' }); |
52 svgRoot.appendChild(filter); | 52 svgRoot.appendChild(filter); |
53 svgRoot.appendChild(rect); | 53 svgRoot.appendChild(rect); |
54 group.appendChild(svgRoot); | 54 group.appendChild(svgRoot); |
55 }); | 55 }); |
56 }); | 56 }); |
57 </script> | 57 </script> |
OLD | NEW |