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.