File:PythonAdoExamole01.png

From TORI
Revision as of 18:37, 2 December 2024 by T (talk | contribs) (→‎Generator: xpdf)
Jump to navigation Jump to search

Original file(1,020 × 420 pixels, file size: 7 KB, MIME type: image/png)

Summary


Example of use of Python routine Ado.py

Generator

import math
o= open("PythonAdoExamole01.eps","w+")

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

ado(1020,420)

o.write("10 10 translate\r\n")
o.write("100 100 scale\r\n")
o.write("1 setlinejoin 2 setlinecap\r\n")

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

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

for n in range(0,5):
 M(0, n)
 L(10, n)

for n in range(0,11):
 M(n,4)
 L(n,0)
o.write("0 0 0 RGB .02 W S\r\n")

a = [3.190074, 3.00812328, 2.81343466, 2.60300605, 2.37695838, 2.1300704, 1.86308525, 1.57027974, 1.24972556, 0.89783445, 0.50733685]

for n in range(0,11):
 print n, a[n]

M(0,a[0])
for n in range(1,11):
# x= math.sin(.1*n)
 L(n,a[n])
o.write("1 0 0 RGB .1 W S\r\n")
o.write("showpage\r\n")
o.close()
print("closed\n")
import os
os.system("epstopdf PythonAdoExamole01.eps")
os.system("    xpdf PythonAdoExamole01.pdf")

Warnig

Command «open» in the last line of the code above is supported at macintosh.

For other operational systems, it may have need to be replaced to «display» or «xpdf».

For portability, the result is transformed with command

convert PythonAdoExamole01.eps png8:PythonAdoExamole01.png

References

Keywords

«Ado.py», «Python»,

File history

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

Date/TimeThumbnailDimensionsUserComment
current06:03, 2 December 2024Thumbnail for version as of 06:03, 2 December 20241,020 × 420 (7 KB)T (talk | contribs)== Summary == {{oP}} Example of use of Python routine Ado.py ==Generator== <pre> import math o= open("PythonAdoExamole01.eps","w+") def ado(x,y): o.write("%!PS-Adobe-2.0 EPSF-2.0\r\n%%") o.write("BoundingBox: 0 0 %d " %x) o.write("%d\r\n" %y) o.write("/RGB {setrgbcolor} bind def\r\n") o.write("/W {setlinewidth} bind def\r\n") o.write("/M {moveto} bind def\r\n") o.write("/L {lineto} bind def\r\n") o.write("/C {closepath} bind def\r\n") o.write("/S {stroke} bind def\r\n")...

There are no pages that use this file.

Metadata