X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=fds%2Fanim%2Fdessin.js;fp=fds%2Fanim%2Fdessin.js;h=82249e79f63ae75566a8c9ae9eaa312170fe302a;hb=6e8bc5175a0d55e46d072fce27496d93beee3f83;hp=0000000000000000000000000000000000000000;hpb=14a82e5a3b99f42a6efa97af7a8144710783fdd3;p=hacks%2FsimpleWebSlides.git diff --git a/fds/anim/dessin.js b/fds/anim/dessin.js new file mode 100644 index 0000000..82249e7 --- /dev/null +++ b/fds/anim/dessin.js @@ -0,0 +1,193 @@ +var content = document.getElementById("content"); + +function del_all () { + while (content.hasChildNodes()) { + content.removeChild(content.lastChild); + }; + +} +function del_line () +{ + + if (content.hasChildNodes()) { + content.removeChild(content.lastChild); + }; + +} + +function add_line() +{ + var children = content.childNodes; + var id = children.length; + var div = document.createElement("div"); + div.setAttribute("id", "div" + id); + div.setAttribute("class", "horizontal"); + var table = document.createElement("table"); + table.setAttribute("id", "table" + id); + var row = document.createElement("tr"); + row.setAttribute("id", "row" + id); + row.setAttribute("class", "row"); + var text = document.createElement("input"); + text.setAttribute("id", "textfield" + id); + text.setAttribute("class", "textfield"); + text.setAttribute("type", "text"); + text.size=10; + text.setAttribute("onkeypress", "do_keypress(" + id + ")"); + table.appendChild(row); + div.appendChild(text); + div.appendChild(table); + content.appendChild(div); + +} + +var wait = false; +function reset_wait(id) { wait = false; draw_line(id);} +function do_keypress(id) +{ + if (!wait) { + wait = true; + setTimeout("reset_wait(" + id + ")", 1000); + }; +} + +function draw_line(id) +{ + var row = document.getElementById("row" + id); + var text = document.getElementById("textfield" + id); + var next = row.firstChild; + var tmp = null; + while(next) { + tmp = next.nextSibling; + row.removeChild(next); + next = tmp; + }; + pixels = text.value.split(","); + var colors = new Array(); + colors[0] = "black"; + colors[1] = "white"; + var c = 0; + for (s in pixels) + { + if (pixels[s] >= 0 && pixels[s] <= 15) { + for(i = 0; i < pixels[s]; i++) + { + var td = document.createElement("td"); + td.setAttribute("id", "cell" + id + "_" + i); + var span = document.createElement("span"); + span.setAttribute("class", colors[c]); + td.appendChild(span); + row.appendChild(td); + }; + } else { + continue; + }; + c = (c + 1) % 2; + }; +} + +var dessins = []; +dessins[0] = [ + "0, 7, 2, 7", + "0, 6, 1, 2, 1, 6", + "0, 6, 1, 2, 1, 6", + "0, 5, 1, 4, 1, 5", + "6, 4, 6", + "1, 14, 1", + "0, 1, 1, 4, 1, 2, 1, 4, 1, 1", + "0, 2, 1, 3, 1, 2, 1, 3, 1, 2", + "0, 3, 1, 2, 1, 2, 1, 2, 1, 3", + "0, 3, 1, 8, 1, 3", + "0, 2, 1, 10, 1, 2", + "0, 2, 1, 10, 1, 2", + "0, 1, 1, 5, 2, 5, 1, 1", + "0, 1, 1, 3, 2, 2, 2, 3, 1, 1", + "1, 2, 2, 6, 2, 2, 1", + "3, 10, 3" +]; + +dessins[1] = [ + " 0, 5, 5, 6 ", + " 0, 3, 2, 5, 2, 4 ", + " 0, 2, 1, 9, 1, 3 ", + " 0, 1, 1, 11, 1, 2 ", + " 0, 1, 1, 1, 1, 1, 1, 8, 1, 1 ", + " 1, 2, 1, 1, 1, 4, 3, 2, 1 ", + " 1, 2, 1, 1, 1, 3, 1, 2, 1, 2, 1 ", + " 1, 11, 1, 1, 1, 1 ", + " 1, 1, 1, 1, 1, 1, 1, 4, 1, 3, 1 ", + " 1, 1, 5, 8, 1 ", + " 1, 1, 5, 8, 1 ", + " 0, 1, 1, 1, 5, 7, 1 ", + " 0, 1, 1, 2, 1, 1, 1, 1, 1, 5, 1, 1 ", + " 0, 2, 1, 10, 1, 2 ", + " 0, 3, 2, 6, 2, 3 ", + " 0, 5, 6, 5 " +]; + +dessins[2] = [ + "0, 5, 6, 5", + "0, 3, 4, 2, 4, 3", + "0, 1, 6, 2, 6, 1", + "1, 2, 4, 2, 4, 2, 1", + "1, 3, 2, 4, 2, 3, 1", + "1, 14, 1", + "2, 4, 4, 4, 2", + "2, 3, 6, 3, 2", + "1, 4, 6, 4, 1", + "1, 1, 12, 1, 1", + "1, 1, 1, 3, 1, 2, 1, 3, 1, 1, 1", + "3, 3, 1, 2, 1, 3, 3", + "1, 5, 1, 2, 1, 5, 1", + "0, 1, 1, 12, 1, 1", + "0, 1, 2, 10, 2, 1", + "0, 2, 12, 2" +]; +dessins[3] = [ + "0, 7, 2, 7", + "0, 2, 1, 3, 1, 2, 1, 3, 1, 2", + "0, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1", + "0, 1, 1, 2, 1, 6, 1, 2, 1, 1", + "1, 14, 1", + "1, 4, 2, 3, 2, 3, 1", + "1, 3, 1, 2, 1, 1, 1, 2, 1, 2, 1", + "1, 14, 1", + "0, 1, 1, 12, 1, 1", + "0, 2, 1, 10, 1, 2", + "0, 3, 1, 7, 2, 3", + "0, 4, 7, 5", + "0, 3, 4, 2, 1, 1, 3, 2", + "0, 2, 1, 3, 1, 2, 2, 3, 1, 1", + "0, 1, 1, 5, 1, 1, 1, 5, 1", + "0, 1, 1, 5, 3, 5, 1" +]; + +dessins[4] = [ + "0, 2, 12, 2", + "0, 1, 1, 12, 1, 1", + "1, 3, 7, 2, 1, 1, 1", + "1, 2, 1, 7, 1, 3, 1", + "1, 1, 1, 9, 1, 2, 1", + "1, 1, 1, 2, 4, 3, 1, 2, 1", + "1, 2, 6, 3, 1, 2, 1", + "1, 4, 1, 5, 1, 3, 1", + "1, 4, 1, 3, 2, 4, 1", + "1, 5, 3, 6, 1", + "1, 4, 1, 3, 1, 5, 1", + "1, 4, 1, 3, 1, 5, 1", + "1, 5, 3, 4, 1, 1, 1", + "1, 10, 2, 2, 1", + "0, 1, 1, 12, 1, 1", + "0, 2, 12, 2" +]; + +function fill_and_draw(sel) { + var value = sel.options[sel.selectedIndex].value; + del_all(); + var tab = dessins[Math.min(parseInt(value + ""),dessins.length) - 1]; + for (var i = 0 ; i < tab.length; i++){ + add_line (); + var t = document.getElementById("textfield" + i); + t.value = tab[i]; + draw_line(i); + }; +} \ No newline at end of file