2015-04-28 12:47:44 +02:00
|
|
|
var Viewer = function(_viewer) {
|
2015-04-25 17:26:12 +02:00
|
|
|
var className = "Viewer";
|
2015-04-28 12:47:44 +02:00
|
|
|
var viewer = _viewer;
|
2015-04-27 23:38:01 +02:00
|
|
|
var items = [];
|
2015-04-28 12:47:44 +02:00
|
|
|
var colors = ['#FF00BF','#FFBF00','#00FFFF','#0040FF','#00FF40','#7F00FF','#FF0000','#80FF00','#FF00BF','#FF0000'];
|
2015-04-25 17:26:12 +02:00
|
|
|
|
2015-04-28 12:47:44 +02:00
|
|
|
function setDoodles(doodles) {
|
2015-04-25 17:26:12 +02:00
|
|
|
for (var i=0; i<doodles.length; i++) {
|
2015-04-27 23:38:01 +02:00
|
|
|
var item = new ViewerItem(doodles[i]);
|
|
|
|
items.push(item);
|
|
|
|
var svg = item.getSvg();
|
2015-04-25 17:26:12 +02:00
|
|
|
viewer.append(svg);
|
2015-04-28 12:47:44 +02:00
|
|
|
item.setColor(colors[i % doodles.length]);
|
2015-04-25 17:26:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-28 12:47:44 +02:00
|
|
|
function clear() {
|
|
|
|
viewer.empty();
|
|
|
|
items.length = 0;
|
|
|
|
}
|
|
|
|
|
2015-04-25 17:26:12 +02:00
|
|
|
return {
|
|
|
|
setDoodles: setDoodles,
|
2015-04-28 12:47:44 +02:00
|
|
|
clear: clear,
|
2015-04-25 17:26:12 +02:00
|
|
|
}
|
|
|
|
}
|