/*
*
* JavaScript Windows ScriptingHost sample file
* usage: cscript trySVG2msg.js
*
--8<--- do_LED.bat ----
rem
rem
rem
:start
cscript trySVG2_LED.js
pause
goto start
-------------------
*/
var stdin = WScript.StdIn;
var stdout = WScript.StdOut;
/***************************************************
****************************************************/
header = ''
footer =
'Generate Three Phase Sine Waves to give clipped RGB values'+
' \n'+
''+
' This is based on a Wireless World article by N Darwood in November 1982.'+
' \n'+
'blinkt \n'+
'\n'+
'\n'+
''
rect = ''
/*
SVG Path -
The element is used to define a path.
The following commands are available for path data:
•M = moveto
•L = lineto
•H = horizontal lineto
•V = vertical lineto
•C = curveto
•S = smooth curveto
•Q = quadratic Bézier curve
•T = smooth quadratic Bézier curveto
•A = elliptical Arc
•Z = closepath
Note: All of the commands above can also be expressed with lower letters. Capital letters means absolutely positioned, lower cases means relatively positioned.
*/
src=100
dst=200
message="AtoB"
colour = "#ff3f00"
lineNum = 0
line = 100
path4 =''
id2=1
/* ********************************
SEC: x Functions to plot
**********************************/
path = ''
path2 = ''
path3 = ''
//path4 = ''
path5 = ''
/* write a function to generate the path */
/*
*
* A grid has horizontal vertical, minor and major axis, six lines.
* Graph Paper has Minor and Major. Do it at 10,100
*
*/
maxX = 640
maxY = 480
function grid(){
var tempStr = ''
return tempStr
}
/* write a function to generate the path */
function d1(){
path4 = ''
}
var opStr = header+"\n"+
grid_circles()+
//grid_circles_1_3()+
footer+
"\n"
fso = new ActiveXObject("Scripting.FileSystemObject");
function writeFile(){
var ForReading = 1, ForWriting = 2;
stdout.WriteLine( "outputting image " );
// Open the file for output.
var fop = fso.OpenTextFile(".\\tryCscriptSVG_LED.svg", ForWriting, true);
if ( fop ) { fop.WriteLine( opStr ); }
if ( fop ) { fop.close(); }
}
// writeFile()
//https://msdn.microsoft.com/en-us/library/64cdz8ax(v=vs.84).aspx
function process(){
while (!stdin.AtEndOfStream){
var ipStr ;
ipStr = stdin.ReadLine();
// ipA = ipStr.split( " " );
ipA = ipStr.split( / +/ );
stdout.WriteLine( "fd( " + ipA[ 2 ] + "," + ipA[4] + ");" );
}
}
//
function grid_circles(){
var A,B,C,n
var mr,mi,mt,ar,ai,r, f,rad;
rad = 2.0 * Math.PI * 0.2
mr=0.5
mi=0.0
r=1.01
ar=r*Math.sin( rad )
ai=r*Math.cos( rad )
// Generate Three Phase to give an RGB value
// This is based on a Wireless World article by N Darwood in November 1982.
n=0.2
A=0
//B=0.866
B=3
C=-B
var maxX = 200
var tempStr = ''
/* this function draws a 100x100 grid */
for ( x = 30 ; x < ( maxX+1 ) ; x+= 1 ){
mt= mr*ar-mi*ai
mi= mr*ai+mi*ar
mr=mt
// Generate Three Phase to give an RGB value
// This is based on a Wireless World article by N Darwood in November 1982.
A=A+n*(B-C)
B=B+n*(C-A)
C=C+n*(A-B)
tempStr += '\n'
id2++
}
return tempStr
}
function grid_circles_1_3(){
var A,B,C,n
var A2,B2,C2,n2
var mr,mi,mt, ar,ai,r, f,rad;
var m2r,m2i,m2t,a2r,a2i,tmp2, f,rad2;
rad = 2.0 * Math.PI * 0.01
rad2 = 2.0 * Math.PI * 0.04
mr=1.5
mi=0.0
m2r=1.5
m2i=0.0
r=1.002
ar=r*Math.cos( rad )
ai=r*Math.sin( rad )
a2r=r*Math.cos( rad2 )
a2i=r*Math.sin( rad2 )
// Generate Three Phase to give an RGB value
// This is based on a Wireless World article by N Darwood in November 1982.
n=0.05
A=0
//B=0.866
B=3
C=-B
n2= n/3
A2= 0
//B2=0.866
B2= B/2
C2=-B
var maxX = 200
var tempStr = ''
/* this function draws a 100x100 grid */
for ( x = 30 ; x < ( maxX+1 ) ; x+= 1 ){
mt= mr*ar-mi*ai
mi= mr*ai+mi*ar
mr=mt
m2t= m2r*a2r-m2i*a2i
m2i= m2r*a2i+m2i*a2r
m2r=m2t
// Generate Three Phase to give an RGB value
// This is based on a Wireless World article by N Darwood in November 1982.
A=A+n*(B-C)
B=B+n*(C-A)
C=C+n*(A-B)
A2=A2+n2*(B2-C2)
B2=B2+n2*(C2-A2)
C2=C2+n2*(A2-B2)
tempStr += '\n'
id2++
}
return tempStr
}
//process reads StdIo but does nothing
//process();
writeFile();
/*
program to write circuit.
Grid:-
*/
/*
*/
/*
var id=1
var clr = ""
var A,B,C,n
A=0
//B=0.866
B=3
C=-B
n=0.4
A=A+n*(B-C)
B=B+n*(C-A)
C=C+n*(A-B)
function plot_ts(){
svgElement = document.getElementById( "svg_up_"+id );
//svgElement.setAttributeNS( null, "fill", "#AA0" );
A=A+n*(B-C)
B=B+n*(C-A)
C=C+n*(A-B)
var rgb = 'rgb(' + ((128+A*120)&-1) + ',' + ((128+B*120)&-1) + ',' + ((128+C*120)&-1)+' )'
//rgb = "rgb(255,255,128)"
svgElement.setAttributeNS(
null,
"fill",
rgb
);
// Generate Three Phase to give an RGB value
// This is based on a Wireless World article by N Darwood in November 1982.
id++
if ( id == 171 ){
id=1
}
}
window.setInterval("plot_ts()",100);
*/