function plotOrigin(pos, vrange) { var x = 0; var y = (pos + (vrange/2)) * this.h / vrange; if (y > 0 && y < this.h) { this.eps.writeln('0 ',y.toFixed(2),' moveto 0 4 rlineto 5 -4 rlineto -5 -4 rlineto closepath fill'); } } function plotTrace(list, ymu, vrange,label,label2) { if (label2) { this.eps.writeln(this.w - 60,' ',this.labely,' m (',label2,') show'); } if (label) { this.eps.writeln(this.w - 100,' ',this.labely,' m (',label,') show'); this.labely -= 15; } var x = 0; var y = (list[0] * ymu + (vrange/2)) * this.h / vrange; if (y < 0) y=0; if (y > this.h) y=this.h; this.eps.writeln(x.toFixed(2),' ',y.toFixed(2),' m'); for (var i=1; i this.h) y=this.h; this.eps.writeln(x.toFixed(2),' ',y.toFixed(2),' l'); } this.eps.writeln('stroke'); } function plotGraticule() { this.eps.writeln('%graticule'); this.eps.writeln('0.8 setgray [1 ',(this.h/50 - 1).toFixed(2),'] 0 setdash'); for (var i=1; i<10; i++) { if (i == 5) continue; this.eps.writeln(this.w * i / 10,' 0 moveto 0 ',this.h,' rlineto stroke'); } this.eps.writeln('0.8 setgray [1 ',(this.w/50 - 1).toFixed(2),'] 0 setdash'); for (var i=1; i<10; i++) { if (i == 5) continue; this.eps.writeln('0 ',this.h*i/10,' moveto ', this.w,' 0 rlineto stroke'); } this.eps.writeln('[] 0 setdash'); this.eps.writeln(this.w/2,' 0 moveto 0 ',this.h,' rlineto stroke'); this.eps.writeln('0 ',this.h/2,' moveto ', this.w,' 0 rlineto stroke'); } function plotHeader() { this.eps.writeln("%!PS-Adobe-3.0 EPSF-3.0"); this.eps.writeln("%%BoundingBox: 0 0 ",this.w," ",this.h); this.eps.writeln("%%PaperSize: ",this.w," ",this.h); this.eps.writeln("%%Creator:"); this.eps.writeln("%%Title:"); this.eps.writeln("%%DocumentFonts: Courier Helvetica Helvetica-Bold"); this.eps.writeln("%%DocumentNeededFonts: Courier Helvetica Helvetica-Bold"); this.eps.writeln("gsave"); this.eps.writeln("/m {moveto} def /l {lineto} def"); this.eps.writeln("/Helvetica findfont 10 scalefont setfont"); } function plotFinish() { this.eps.writeln("grestore"); } function plotRGB(r,g,b) { this.eps.writeln((r/255).toFixed(3),' ',(g/255).toFixed(3),' ',(b/255).toFixed(3),' setrgbcolor'); } function plotColor(i) { this.eps.writeln(this.colors[i],' setrgbcolor'); } function plotLabel(freq, rate) { //draw box and labels this.eps.writeln("0 setgray 0 0 moveto ",this.w," 0 rlineto 0 ",this.h," rlineto -",this.w," 0 rlineto closepath stroke"); this.eps.writeln('5 ',this.h-15,' m (', freq.toFixed(1),' Hz) show'); this.eps.writeln('5 ',this.h-27,' m (', (1000*rate).toFixed(1),' ms/div) show'); } function Plot(eps,w,h,colors) { if (colors) this.colors = this.colors.concat(colors); else this.colors = [".75 .75 0","0 0 1","1 0 0","0 .75 0"]; this.w = w; this.h = h; this.labely = h - 15; this.eps = eps; this.trace = plotTrace; this.finish= plotFinish; this.graticule = plotGraticule; this.color = plotColor; this.rgbcolor = plotRGB; this.label = plotLabel; this.header = plotHeader; this.origin = plotOrigin; this.header(); }