File:PythonSinEx36.png

From TORI
Jump to: navigation, search
PythonSinEx36.png(640 × 220 pixels, file size: 5 KB, MIME type: image/png)

Summary

Example of direct graphics from Python to EPS

Description

import math
f= open("36.eps","w+")

def ado(x,y):
 f.write("%!PS-Adobe-2.0 EPSF-2.0\r\n%%")
 f.write("BoundingBox: 0 0 %d " %x)
 f.write("%d\r\n" %y)
 f.write("/RGB {setrgbcolor} bind def\r\n")
 f.write("/W {setlinewidth} bind def\r\n")
 f.write("/M {moveto} bind def\r\n")
 f.write("/L {lineto} bind def\r\n")
 f.write("/C {closepath} bind def\r\n")
 f.write("/S {stroke} bind def\r\n")

ado(640,220)

f.write("320 110 translate\r\n")
f.write("100 100 scale\r\n")
f.write("1 setlinejoin 2 setlinecap\r\n")

def M(x,y):
 f.write("%f " %x)
 f.write("%f M\n" %y)

def L(x,y):
 f.write("%f " %x)
 f.write("%f L\n" %y)

for n in range(-1,2):
 M(-3.14, n)
 L( 3.14, n)

for n in range(-6,7):
 M(n,1)
 L(n,-1)
f.write("0 0 0 RGB .02 W S\r\n")

M(-3.14,0)
for n in range(-31,33):
 x= math.sin(.1*n)
 L(.1*n,x)
f.write("1 0 0 RGB .1 W S\r\n")
f.write("showpage\r\n")
f.close()
print("closed\n")
import os
#os.system("epstopdf 36.eps")
#os.system("    open 36.pdf")
os.system("epstopdf 36.eps")
os.system("   xpdf 36.pdf")
os.system("convert 36.eps PNG8:36.png")

References

</references/>

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current05:46, 21 March 2021Thumbnail for version as of 05:46, 21 March 2021640 × 220 (5 KB)T (talk | contribs)Example of direct graphics from Python to EPS ==Description== <pre> import math f= open("36.eps","w+") def ado(x,y): f.write("%!PS-Adobe-2.0 EPSF-2.0\r\n%%") f.write("BoundingBox: 0 0 %d " %x) f.write("%d\r\n" %y) f.write("/RGB {setrgbco...
  • You cannot overwrite this file.

There are no pages that link to this file.

Metadata