Merge.
Chris Pressey
9 years ago
63 | 63 | svg.style.border = "1px solid blue"; |
64 | 64 | |
65 | 65 | input.onchange = function() { |
66 | var x = Math.floor(Math.random() * ((width / 2) - 20)) + 10; | |
67 | var y = Math.floor(Math.random() * (height - 20)) + 10; | |
68 | var size = 10 + Math.floor(Math.random() * 10); | |
66 | 69 | var e = yoob.makeSVGElem(svg, "text", { |
67 | x: Math.floor(Math.random() * ((width / 2) - 20)) + 10, | |
68 | y: Math.floor(Math.random() * (height - 20)) + 10, | |
70 | x: x, | |
71 | y: y, | |
69 | 72 | fill: "black", |
70 | "font-size": 10 + Math.floor(Math.random() * 10) | |
73 | "font-size": size | |
71 | 74 | }); |
72 | 75 | e.innerHTML = input.value; |
73 | 76 | input.value = ""; |
77 | ||
78 | /* You can also do this by changing the SVG element's innerHTML, like so: */ | |
79 | ||
80 | /* | |
81 | svg.innerHTML += '<text x="' + x + '" y="' + y + '" fill="black" font-size="' + size + '">' + text + '</text>'; | |
82 | */ | |
74 | 83 | }; |
75 | 84 | |
76 | 85 | input.focus(); |