Several polygones with SVG output
Code: "tech_pythagoras.py". Programming language: Python DMelt Version 1.7. Last modified: 02/09/1971. License: Pro
https://datamelt.org/code/cache/tech_pythagoras_1362.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from jhplot import *
from net.sf.drawj2d import Drawj2d

f="drawing.hcl"
out="drawing.svg"

s="""
offset 80 80
unitlength 10

set a 3
set b 4

# vertices
set ML "-[+ $a $b] -$b" ; # middle left
set BM "-$b 0"          ; # bottom middle
set BL "-[+ $a $b] 0"   ; # bottom left

# draw squares
m 0 0; rectangle -[+ $a $b] -[+ $a $b];
m $BM; lr $b -$a; lr -$a -$b; lr -$b $a; l $BM;

# draw dimension lines
pen red 0.2
font tex 6; # Sets font to computer modern, 6mm
set d [mm 10]
m [++ $BL "0 $d"]
dimlinerel $a 0  a
dimlinerel $b 0  b
dimline [geom.parallel "0 -$a" $BM $d] c
m "$d 0"
dimlinerel 0 -$a a
dimlinerel 0 -$b b
"""
with open(f, "w") as xfile:
    xfile.write(s)

args=["-T" "svg", "-W", "100", "-H", "60", "-o", out, f]
Drawj2d.Run(args)
IViewSVG(out)


Ads help maintain this website.