Skip to content

Commit

Permalink
backup some JS to SRC.JS
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannining committed May 6, 2019
1 parent 274de80 commit 2825716
Show file tree
Hide file tree
Showing 13 changed files with 1,951 additions and 269 deletions.
43 changes: 24 additions & 19 deletions 3d.html

Large diffs are not rendered by default.

891 changes: 891 additions & 0 deletions 3dx.html

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions ace-src.js

Large diffs are not rendered by default.

505 changes: 494 additions & 11 deletions ace.js

Large diffs are not rendered by default.

255 changes: 255 additions & 0 deletions clipper-src.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions costy-x.js
Expand Up @@ -435,7 +435,7 @@ function prepare_line2(lenmm,lines) {
return newlines;
}
}
function gcodepush(lenmm, X1, Y1, lenmm,line,closed){
function gcodepush(lenmm, X1, Y1, lenmm1,line,closed){
var area;
if (closed)area=xarea();else area=1;
var lines;
Expand Down Expand Up @@ -540,7 +540,7 @@ function doengrave(){
}
var pup = "G0 Z"+getvalue('safez')+"\n";
var pdn = getvalue('pdn');
var overs=10;
var overs=getvalue('overshoot')*1;
if (cmd==CMD_CNC)overs=0;
nsortx=function (a,b) {
return (a[0]*1 - b[0]*1);
Expand Down
36 changes: 21 additions & 15 deletions engrave.html
Expand Up @@ -54,7 +54,8 @@
<tr><td>Pass<td><input id=repeat2 value=2 size=1 class=saveit>x
<tr><td colspan=2><button id=regcode>Finishing GCODE </button>

<tr><td colspan=2><br><b>Roughing using Flat Nose</b>
<tr><td colspan=2><br><b>Optional Roughing Flat Nose</b>
<tr><td>Feed <td><input id=speed2 size=3 value="100" class=saveit>mm/s
<tr><td>Flat Dia <td><input id=dia2 value=6 size=2 class=saveit>
<tr><td>First Pass<td><input id=repeat3 value=3 size=3 class=saveit>x
<tr><td>Pass<td><input id=repeat4 value=3 size=3 class=saveit>x
Expand Down Expand Up @@ -135,9 +136,13 @@
}

function setvalue(el, val) {
if ($(el)==undefined)return;
var e=$(el);
if (e==undefined)return;
if (el=="gcode")editorgcode.setValue(val,-1);
else $(el).value = val;
else {
if (e.type=='checkbox')e.checked=val;
else e.value = val;
}
}
function setevent(ev,bt,act){
if ($(bt)==undefined)return;
Expand Down Expand Up @@ -215,24 +220,25 @@

function generategcode2(){
var stepy=mh/bmh;
var r=getvalue("dia2")*0.4;
var r=getvalue("dia2")*0.5+0.5;
var feedmethod=getvalue("feedmethod");
var step=(r/stepy);
generategcode0(r,feedmethod,2,step,getvalue("repeat3"),getvalue("repeat4"));
var step=Math.ceil(r/stepy);
var feed=getvalue("speed2")*60;
generategcode0(r,feedmethod,2,step,getvalue("repeat3"),getvalue("repeat4"),feed);
}
function generategcode(){
var feedmethod=getvalue("feedmethod");
var endmill=getvalue("endmill")*1;
var r=getvalue("dia")*0.5;
generategcode0(r,feedmethod,endmill,1,getvalue("repeat1"),getvalue("repeat2"));
var feed=getvalue("speed")*60;
generategcode0(r,feedmethod,endmill,1,getvalue("repeat1"),getvalue("repeat2"),feed);
}
function generategcode0(r,feedmethod,endmill,skip,rep1,rep2){
function generategcode0(r,feedmethod,endmill,skip,rep1,rep2,feed){
prepareimage();
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var scale = 25.4 / getvalue('mdpi');
var zdown=getvalue("zdown");
var feed=getvalue("speed")*60;
var waktu=0;
var w0=0;
var w1=0;
Expand Down Expand Up @@ -322,7 +328,7 @@
var rep=rep2;
var zsc,a;
if (j==0)rep=Math.max(rep1,rep2);
gcodes.push(";Line "+j+"\nG1 Z-"+mround(zm)+" Y"+mround(j*stepy));
gcodes.push(";Line "+j+"\nG1 Z"+mround(-zm)+" Y"+mround(j*stepy));
for (var r=0;r<rep;r++){
n=!n;
var lz=-1000;
Expand All @@ -340,8 +346,8 @@
//if (zm==undefined)zm=0;
//if (zm==NaN)zm=0;
if ((lz!=zm) || (ni==0) || (ni==bmw-1)){
if (ni>0)gcodes.push("G1 X"+mround(lx)+" Z-"+mround(lz));
gcodes.push("G1 X"+mround(xp)+" Z-"+mround(zm));
if (ni>0)gcodes.push("G1 X"+mround(lx)+" Z"+mround(-lz));
gcodes.push("G1 X"+mround(xp)+" Z"+mround(-zm));
lz=zm;
}
lx=xp;
Expand Down Expand Up @@ -379,11 +385,11 @@
//if (zm==NaN)zm=0;
var g1;
if (m)g1="G1 Y"+mround(yp); else g1="G1 X"+mround(xp);
//gcodes.push(g1+" Z-"+mround(zm));return;
//gcodes.push(g1+" Z"+mround(-zm));return;

if ((lz!=zm) || fp){
if (lx)gcodes.push(lx+" Z-"+mround(lz));
gcodes.push(g1+" Z-"+mround(zm));
if (lx)gcodes.push(lx+" Z"+mround(-lz));
gcodes.push(g1+" Z"+mround(-zm));
lz=zm;
}
lx=g1;
Expand Down
56 changes: 43 additions & 13 deletions graf.html
Expand Up @@ -33,11 +33,15 @@
<option value=0 selected>CNC</option>
<option value=1>Laser</option>
</select><br>
DPI <input id=mdpi value=72 size=3 class=saveit>
DPI <input id=usedpi type=checkbox size=3 class=saveit><input id=mdpi value=72 size=3 class=saveit>
<br>Width <input id=mwidth value=100 size=11 class=saveit>mm
<td>
<b>Gcode</b>

<hr><b>LASER</b>
<br>Over <input id=over size=3 value="5" class=saveit>
<br>OfsX <input id=ofsX size=3 value="0" class=saveit>
<br>OfsY <input id=ofsY size=3 value="0" class=saveit>
<br>Speed <input id=speed1 size=3 value="100" class=saveit>mm/s
<br>Pixel shift <input id=shf size=1 value="1" class=saveit>
<br>Tools on <input id=tool2 size=6 value="M3 S255" class=saveit> off <input id=tool1 size=6 value="M3 S0" class=saveit>
Expand Down Expand Up @@ -68,7 +72,6 @@

<script>
var ws =0;
var overshot=15;
function $(id) {
return document.getElementById(id);
}
Expand All @@ -80,12 +83,22 @@
return Math.round(x * 1000.0) / 1000.0;
}

function getvalue(el){
return document.getElementById(el).value;
function getvalue(el) {
if ($(el)==undefined)return "";
if (el=="gcode")return editorgcode.getValue();
else return $(el).value;
}
function setvalue(el,val){
document.getElementById(el).value=val;

function setvalue(el, val) {
var e=$(el);
if (e==undefined)return;
if (el=="gcode")editorgcode.setValue(val,-1);
else {
if (e.type=='checkbox')e.checked=val;
else e.value = val;
}
}

function setevent(ev,bt,act){
document.getElementById(bt).addEventListener(ev, act,false);
}
Expand Down Expand Up @@ -147,16 +160,32 @@

var floyd1=[7, 4,4,1];
var memlimit=8000;
var overshot=5;

ditherit = function() {
var c = document.getElementById("myCanvas");
var img = document.getElementById("thepic");
udpi=$("usedpi").checked;
var scale = 25.4 / getvalue('mdpi');
overshot=getvalue("over")*1;
rwidth=scale*img.naturalWidth;
rheight=scale*img.naturalHeight;
if (!udpi){
ww=getvalue("mwidth").split("x");
rwidth=ww[0]*1;
if (ww[1]==undefined)
rheight=ww[0]*img.naturalHeight/img.naturalWidth;
else
rheight=ww[1]*1;
scale=rwidth/img.naturalWidth;
setvalue('mdpi',mround(25.4/scale));
}
img.width=getvalue("width")*1;

c.width=img.width;
c.height=getvalue("height");
ofx=getvalue("ofsX")*1;
ofy=getvalue("ofsY")*1;
var ctx = c.getContext("2d");
var flip=$("flip").checked;
ctx.drawImage(img, 0, 0,c.width,c.height);
Expand Down Expand Up @@ -196,6 +225,7 @@
var gamma=getvalue("gamma")*1.0;
var mw=rwidth*1.0;
var mh=rheight*1.0;
//if (udpi)
setvalue("mwidth",mround(mw)+"x"+mround(mh));
//var mh=mw*c.height/c.width;
var dotscale=mw/c.width;
Expand Down Expand Up @@ -357,8 +387,8 @@
//pxstop=Math.min(c.width-dx,pxstop+2);
//pxstart=0;
//pxstop=c.width-dx;
px1=mround(dotscale*pxstart);
px2=mround(dotscale*pxstop);
px1=mround(dotscale*pxstart+ofx);
px2=mround(dotscale*pxstop+ofx);
if (mtype==1){
//gcode+=";"+pxstart+","+pxstop+"\n";
pxstop=bp+(pxstop-pxstart);
Expand All @@ -377,15 +407,15 @@
if (jk%2==1){
gcode+=";>>\n";
gcode+="G0 F"+speed+" E"+pxstart+" X"+mround(px1-ccc)+"\n";
gcode+="G0 S0 X"+mround(px1)+" Y"+mround((j)*ystep)+"\n";
gcode+="G0 S0 X"+mround(px1)+" Y"+mround((j)*ystep+ofy)+"\n";
gcode+="G1 S255 F"+speed+" X"+px2+" E"+pxstop+"\n"
//gcode+="G0 S0 X"+mround(px2+ccc)+"\n";
farx=px2+overshot*3;
} else {
// next y
gcode+=";<<\n";
gcode+="G0 F"+speed+" E"+(pxstop+shf)+" X"+mround(px2+ccc)+"\n";
gcode+="G0 S0 X"+mround(px2)+" Y"+mround((j)*ystep)+"\n";
gcode+="G0 S0 X"+mround(px2)+" Y"+mround((j)*ystep+ofy)+"\n";
gcode+="G1 S255 F"+speed+" X"+(px1)+" E"+(pxstart+shf)+"\n";
//gcode+="G0 S0 X"+mround(px1-ccc)+"\n";
farx=px1-overshot*3;
Expand All @@ -404,11 +434,11 @@
xstep=mw/gc.length;
zstep=zdown/25;
lv=" ";
x=xstep*idx;
gcode+=tool1+"\nG0 F"+speed+" X"+mround(x)+" Y"+mround((j)*ystep)+"\n";
x=xstep*idx+ofx;
gcode+=tool1+"\nG0 F"+speed+" X"+mround(x)+" Y"+mround((j)*ystep+ofy)+"\n";
for (var i=0;i<gc.length;i++){
v=gc[idx];
x=xstep*idx;
x=xstep*idx+ofx;
if (v!='z'){
gcode+="G0 F"+speed+" X"+mround(x)+"\n";
z=25-(gc.charCodeAt(idx)-97);
Expand Down
14 changes: 7 additions & 7 deletions index.html
Expand Up @@ -110,6 +110,7 @@
<tr><td colspan=2><font color=blue><b>BLUE engrave feed</b></font></td><td colspan=2><input id=rasterfeed class=saveit size=15 value=200></td></tr>
<tr><td colspan=2>Blue engrave outline</td><td colspan=2><input id=rasteroutfeed class=saveit size=15 value=200></td></tr>
<tr><td colspan=2>Enable Engrave </td><td colspan=2><input size=1 type=checkbox id=enableraster checked class=saveit></td></tr>
<tr><td colspan=2>Overshoot </td><td colspan=2><input size=1 id=overshoot size=3 value=5 class=saveit></td></tr>
<tr><td colspan=2>Enable Outline </td><td colspan=2><input size=1 type=checkbox id=rasteroutline checked class=saveit></td></tr>
<tr><td colspan=2>Engrave Y DPI </td><td colspan=2><input id=rasterdpi class=saveit size=15 value=100></td></tr>
<tr><td colspan=2>Enable stroke-width </td><td colspan=2><input size=1 type=checkbox id=strokeoffset checked class=saveit></td></tr>
Expand Down Expand Up @@ -142,13 +143,12 @@
<option value="8,1,3,1500">Laser Triplek 3mm</option>
<option value="6,1,5,1500">Laser Triplek 5mm</option>
<option value="6,2,9,1500">Laser Triplek 9mm</option>
<option value="6,1,3,1500">MDF 3mm</option>
<option value="30,12,6,1000,6.5">CND MDF 6mm</option>
<option value="30,20,9,1000,9.5">CNC MDF 9mm</option>
<option value="30,11,9,1000,11">CNC MDF-H 10mm</option>
<option value="30,8,27,1000,4.5">CNC ACP 4mm</option>
<option value="30,4,20,1000,5.5">CNC PVC 5mm</option>
<option value="30,10,32,1000,9.5">CNC PVC 9mm</option>
<option value="6,1,3,1500">MDF Hijau 3mm</option>
<option value="30,11,9,1500,10.5">CNC MDF-H 9.5mm</option>
<option value="40,6,20,1500,3.5">CNC ACP 3mm</option>
<option value="40,8,27,1500,4.5">CNC ACP 4mm</option>
<option value="30,5,20,1500,5.5">CNC PVC 5mm</option>
<option value="30,11,32,1500,9.5">CNC PVC 9mm</option>
</select></td></tr>
<tr><td>Mat Price/cm2</td><td colspan=2><input id=matprice class=saveit size=4></td></tr>
<tr><td>Cut Price/min</td><td colspan=2><input id=cutprice class=saveit size=4></td></tr>
Expand Down
2 changes: 1 addition & 1 deletion inkscape/laser.py
12 changes: 6 additions & 6 deletions serial.js
Expand Up @@ -224,7 +224,7 @@ function executegcodes2() {
} else {
bt.innerHTML = "Engrave";
stopit();
sendgcode("M2");
//sendgcode("M2");
}
}
function executepgcodes() {
Expand Down Expand Up @@ -886,12 +886,12 @@ window.onresize = function() {
var sc=parseFloat(getvalue("zoom1"));
var nw = Math.max(100, window.innerWidth - 765);
var v = $('myCanvas1');
v.width = nw;
v.width = nw*sc;
nh=Math.max(300, 500 * nw / 600);
v.height = nh;
$('myCanvas1td').width=nw*sc+50;
$('myCanvas1div').style.width=nw*sc+50;
$('myCanvas1div').style.height=nh*sc;
v.height = nh*sc;
$('myCanvas1td').width=nw+50;
$('myCanvas1div').style.width=nw+50;
$('myCanvas1div').style.height=nh;
gcode_verify();
}

Expand Down

0 comments on commit 2825716

Please sign in to comment.