i3 KGC rX :: KPD.json-EST.js-VRML.js compressor

The compressor should result in a 50% size reduction; new lines are removed, white space is not.
The combined KPD and JSON files provided below are an example of required data for function.
Running the example will produce a KPX formatted version of the data.
Start JavaScript KPD/JSON to KPX compressing example, click to run.

KPD eval code - JavaScript example

Please note that the following eval code has been found to contain errors or code omission, and; May not function as directed/stated/described.
/*array data*/
var json_code = ["Extension","Objects","RealWidth","RealDepth","RealHeight","RealHeightFrom","RealPosX","RealPosY","RealRotation","Scale","Top","Left","Width","Depth","Height","HeightFrom","FixX","FixY","Show","Hide","Fixed","RotateBy","Comments","AddOns","FillColour","LineColour","BmpFile"];
var json_reduce = ["_e","_o","_W","_D","_H","_HF","_X","_Y","_R","_S","_t","_l","_w","_d","_h","_hf","_x","_y","__S","__H","_F","_r","_c","_a","_f","_L","_b"];
var json_known = ["C:\\\\Program Files\\\\Kitchen\\\\Objects\\\\Bitmaps\\\\STD\\\\","[width][ewidth]","[depth][edepth]","[height][eheight]","[heightfrom][eheightfrom]","[width]","[ewidth]","[depth]","[edepth]","[height]","[eheight]","[heightfrom]","[eheightfrom]","[cwidth\][ecwidth]","[cdepth][ecdepth]","[cheight][echeight]","[cheightfrom][echeightfrom]","[cwidth]","[ecwidth]","[cdepth]","[ecdepth]","[cheight]","[echeight]","[cheightfrom]","[echeightfrom]"];
var json_shorten = ["","W()","D()","H()","F()","W('","')","D('","')","H('","')","F('","')","w()","d()","h()","f()","w('","')","d('","')","h('","')","f('","')"];
var json_draw = ["(Fmovex+B1)-P2","(Fmovey+P1)+B2","Fmovex-P2","Fmovey+B2","Fmovex+B1","Fmovey+P1","MoveToDEF","LineToDEF","MoveTo","Fmovex","Fmovey","LineTo"];
var json_pack = ["BP","PB","FP","FB","fb","fp","mt","lt","MT","FX","FY","LT"];

/*function helper*/
cswap = function (ndata,tochange,reduce){ var jsonmax = tochange.length; var count = 0; var max = 50; var amok = false; for( var json_count = 0; json_count < jsonmax; json_count++){ do{ try{ ndata = ndata + reduce[json_count] + " = function(){ return \"" + tochange[json_count] + "\"; }\r\n"; }catch(e){ amok=false; /*UNSUPPORTED BROWSER*/ }
count++; if(count==max){amok=false}; }while(amok==true); count = 0; amok = true; }
return ndata; }

/*global values*/
var _0 = ''; var _1 = 0; var _5 = 0; var _2 = 0; var _6 = 0; var _3 = 0; var _7 = 0; var _4 = 0; var _8 = 0;

reduceKPD = function(){
/*KPD placeholders - inline un-reduce*/
try{ eval ( cswap("",json_code, json_reduce) ); }catch(e){}
try{ eval ( cswap("",json_draw, json_pack) ); }catch(e){}

evalKPDinit = function(){
/*KPD values - inline un-shorten */
E = function(_0){ var donothing = true; alert(_0); }
/* was json encoder - get.cgi - rewritten in reverse to decode for javascript 2013 */
W = function (widtheq){ widtheq = widtheq.replace(/\[width\]/,""); widtheq = widtheq.replace(/\[ewidth\]/,""); try{ if(widtheq=="0"||widtheq==""||widtheq=="undefined"||widtheq==null){widtheq = "+0";} }catch(e){widtheq = "+0";}
return mathstime(userWidth, widtheq); }
D = function (deptheq){ deptheq = deptheq.replace(/\[depth\]/,""); deptheq = deptheq.replace(/\[edepth\]/,""); try{ if(deptheq=="0"||deptheq==""||deptheq=="undefined"||deptheq==null){deptheq = "+0";} }catch(e){deptheq = "+0";}
return mathstime(userDepth, deptheq); }
H = function (heighteq){ heighteq = heighteq.replace(/\[height\]/,""); heighteq = heighteq.replace(/\[eheight\]/,""); try{ if(heighteq=="0"||heighteq==""||heighteq=="undefined"||heighteq==null){heighteq = "+0";} }catch(e){heighteq = "+0";}
return mathstime(userHeight, heighteq); }
F = function (heightfromeq){ heightfromeq = heightfromeq.replace(/\[heightfrom\]/,""); heightfromeq = heightfromeq.replace(/\[eheightfrom\]/,""); try{ if(heightfromeq=="0"||heightfromeq==""||heightfromeq=="undefined"||heightfromeq==null){heightfromeq = "+0";} }catch(e){heightfromeq = "+0";}
return mathstime(userHeightFrom, heightfromeq); }
w = function (widtheq){ widtheq = widtheq.replace(/\[cwidth\]/,""); widtheq = widtheq.replace(/\[ecwidth\]/,""); try{ if(widtheq=="0"||widtheq==""||widtheq=="undefined"||widtheq==null){widtheq = "+0";} }catch(e){widtheq = "+0";}
return mathstime(cpuWidth, widtheq); }
d = function (deptheq){ deptheq = deptheq.replace(/\[cdepth\]/,""); deptheq = deptheq.replace(/\[ecdepth\]/,""); try{ if(deptheq=="0"||deptheq==""||deptheq=="undefined"||deptheq==null){deptheq = "+0";} }catch(e){deptheq = "+0";}
return mathstime(cpuDepth, deptheq); }
h = function (heighteq){ heighteq = heighteq.replace(/\[cheight\]/,""); heighteq = heighteq.replace(/\[echeight\]/,""); try{ if(heighteq=="0"||heighteq==""||heighteq=="undefined"||heighteq==null){heighteq = "+0";} }catch(e){heighteq = "+0";}
return mathstime(cpuHeight, heighteq); }
f = function (heightfromeq){ heightfromeq = heightfromeq.replace(/\[cheightfrom\]/,""); heightfromeq = heightfromeq.replace(/\[echeightfrom\]/,""); try{ if(heightfromeq=="0"||heightfromeq==""||heightfromeq=="undefined"||heightfromeq==null){heightfromeq = "+0";} }catch(e){heightfromeq = "+0";}
return mathstime(cpuHeightFrom, heightfromeq); }

/* sub mathstime - get.cgi  - rewritten for javascript 2013 */
mathstime = function(mt0,mt1){ try{ mt0 = mt0 - 0.0001; mt0 = mt0 + 0.0001; try{if (mt1=="") { mt1 = 0; }}catch(e){ mt1 = 0; }
if (mt1.match(/\-/)) { mt1 = mt1.replace(/\-/,""); mt1 = mt1 - 0.0001; mt1 = mt1 + 0.0001; mt1 = mt0 - mt1; }
if (mt1.match(/\+/)) { mt1 = mt1.replace(/\+/,""); mt1 = mt1 - 0.0001; mt1 = mt1 + 0.0001; mt1 = mt0 + mt1; }
if (mt1.match(/\*/)) { mt1 = mt1.replace(/\*/,""); mt1 = ceil(mt0 * mt1); }
if (mt0 != 0 && mt1.match(/\\/)) { mt1 = mt1.replace(/\\/,""); mt1 = ceil(mt0 / mt1); }
if (mt0 != 0 && mt1.match(/\//)) { mt1 = mt1.replace(/\//,""); mt1 = ceil(mt0 / mt1); }
return mt1; }catch(e){return 0;} }

/*KPD shape values - read only strings*/
BP = function(){ try{ return "(Fmovex+B1)-P2"; }catch(e){E(e);} }
PB = function(){ try{ return "(Fmovey+P1)+B2"; }catch(e){E(e);} }
FP = function(){ try{ return "Fmovex-P2"; }catch(e){E(e);} }
FB = function(){ try{ return "Fmovey+B2"; }catch(e){E(e);} }
fb = function(){ try{ return "Fmovex+B1"; }catch(e){E(e);} }
fp = function(){ try{ return "Fmovey+P1"; }catch(e){E(e);} }
mt = function(){ try{ return "MoveToDEF"; }catch(e){E(e);} }
lt = function(){ try{ return "LineToDEF"; }catch(e){E(e);} }
MT = function(){ try{ return "MoveTo"; }catch(e){E(e);} }
FX = function(){ try{ return "Fmovex"; }catch(e){E(e);} }
FY = function(){ try{ return "Fmovey"; }catch(e){E(e);} }
LT = function(){ try{ return "LineTo"; }catch(e){E(e);} }
}catch(e){ alert('can not init uncompress system'); }


KPD read data - Javascript example

var bc2diArray = kpd_bc2di();
var bc2dii1nullExtensionVALUE = bc2diArray['null'][0]._e;

KPD multi object item storage - NS example

An extra 80% compression may be achived using this example when adding multiple object items that share a common data structure.

If an i1 item already exists within an array with the name of null which sub-array differs in content - then create a new parameter iVALUE and append the array.
The new iVALUE must be formed so when read back, the new iVALUE can be seen as the original user entered text: eg i1.
Shape and all as-same parameters with the same values as the existing array should remain un-changed.

KPD transfer - NS example

gz and other methods for data compression may be enacted using standard web server and file system protocols.
More value swapping, Base64 encoding, and white space removal could be performed if desired but could lead to loss of output structure, depending on data comformance to processing.
The suggest transfer format is that using HTTP protocols as it enables cache services by default, if the host is configured to do so.

BC2DI.KPD - KitCAD transfer

The following examples provide known KPD transfer methods (or from SDK for KitCAD2).

KitCAD v5 2.27

The following examples provide known KPD i3 KGC transfer methods (or from SDK for KitCAD i3).



The following examples provide known KPX generation form KitCAD i3 KGC.

The following examples provide known KPX transfer methods.

KitCAD i3 KGC rX

See i3libsys-http-localhost-get-svr.zip above for an example.

KitCAD i3 KGC rX graphics

See i3libsys-i3imgsys_phpdesktop-msie-1.14-php-5.4.33.zip above for a working example.

KPX examples

The Javascript file of 81519201192038514161751931513.js contains KPD, QUOTE and VRML information
The Javascript file of 81519201192038514161751931513_.js contains encoded graphic information

KPX back to KitCAD i3 KGC example

The user entered KPX Object Item can be decoded back into the original KitCAD i3 KGC (online) format;
The decompressor example will reverse KPD KPX encoding.

KitCAD i3 KGC size and rotation calculator converters

The user entered size calculated to pixels; See Size calculator converter, and Rotation calculator converter.

Submit files for KitCAD i3 KGC rX online

At this time - because of processing and coding requirements, only offline processing is possible.
To submit KitCAD i3 KGC rX KPX files create an Email with the subject of KITCAD and attach the files for submission.
Senders Email address will be used to generate end user file name when uploaded online.
(See website contact page for current To: Email address information)
Submitted files will be reviewed and permitting compliance with site requirements then should be available online until account request for removal/alteration


This document and thing is provided as is, it is the basis for compression for KitCAD i3 KGC rX versions.
There are errors; The KPX, array, object, js, json, structure, values, Or/And the code will be changed from the above when finished, the above is an example only.
Possible other uses include but are not limited to any mix of the following: Encryption, security, compression, inflation, processing math, system related function, single web page library and editor for KitCAD i3 KGC rX (-500Kb).
The invention/thing/idea described here is disclosed as a existing thing which is or may not be freeware/s, shareware/s, or any other kind of software/s and IP that is for sale/s or reuse/s without express written consent of a reuse addressed to the user/s by its origial author.
(c)Copyright 2012-2017 as written by Jason Robinson for the Kitchen Pages, and computer software. All Rights are reserved.