OEM-circuits
ASCII/OEM-circuits
by Ruslan Alikberov
HTML
<body onload="Init()">
<img style=display:none...
JavaScript
var
recode = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№¤■ "
,circuits = new Array()
,cnv,list
,fnt,img = new Image();
// Split circuits base
// Input syntax:
// PAGE: ... circuit page name and description ...
// ... circuit body ...
// .CLIP left top right bottom
// Output resource:
// {page#1:[height][width], ... page#n:[height][width]}
function Splitter(base) {
base = base.split(/\r\n|\n/);
page = new Array();
fill = new Array();
name = "";
for(i = 0; i < 320; ++ i)
fill[i] = 0x20;
for(i = 0; i < base.length; ++ i)
switch(base[i].substr(0, 6)) {
case "PAGE: ":
if(name != "")
return alert("Line #" + i + ": Unexpected redefinition over page '" + name + "'");
name = base[i].substr(6);
clip = new Array();
width = 0;
break;
case ".CLIP ":
if(!name)
return alert("Line #" + i + ": Undefined page completation");
if(!width ++ && !clip.length)
return alert("Line #" + i + ": Unable to complete of empty page");
if(width ++ > fill.length)
return alert("Line #" + i + ": Too wide page. More than " + fill.length);
for(y = clip.length; y; -- y)
clip[y] = clip[y - 1].concat(fill.slice(0, width - clip[y - 1].length));
clip[y] = fill.slice(0, width);
clip.push(fill.slice(0, width));
width = base[i].substr(6).split(" ");
page[page.length] =
{name: name
,clip:
{left: isFinite(width[0]) ? width[0] : 0
,top: isFinite(width[1]) ? width[1] : 0
,right: isFinite(width[2]) ? width[2] : 0
,bottom: isFinite(width[3]) ? width[3] : 0
}
,page: clip
};
name = "";
break;
default:
y = clip.length;
clip[y] = new Array(0x20);
for(x = 0; x < base[i].length; ++ x)
clip[y][x + 1] = recode.indexOf(base[i].charAt(x));
if(width < base[i].length)
width =...