# === mkdraw script: construction de rectangle avec coins arrondis ===
#  JMB le 21.11.22


# Box with rounded corners.
# on construit en tournant dans le sens trigo
# %x0,%y0 is bottom left corner point
# %w,%h are width and height
# %rx, %ry  are corner radius x, y
define rect_rounded [ %x0 %y0 %w %h %rx %ry ] {
	move  %x0    ( %y0 + %h - %ry )
	curve  %x0 ( %y0 + %h - ( %ry * 0.45 ) ) ( %x0 + %rx * 0.45 )  ( %y0 + %h )  ( %x0 + %rx ) ( %y0 + %h )
	line    ( %x0 +  %w -  %rx )   ( %y0 + %h )
	curve  ( %x0 + %w - ( %rx * 0.45  ) ) ( %y0 + %h ) ( %x0 + %w ) ( %y0 + %h - ( %ry * 0.45  ) ) ( %x0 + %w ) ( %y0 + %h - %ry )
	line  ( %x0 + %w ) ( %y0 + %ry )
	curve ( %x0 + %w ) ( %y0 + ( %ry * 0.45 ) ) ( %x0 + %w - ( %rx * 0.45 ) ) %y0 ( %x0 + %w - %rx ) %y0
	line  ( %x0 + %rx ) %y0
	curve ( %x0 + ( %rx * 0.45 ) ) %y0 %x0 ( %y0 + ( %ry * 0.45 ) ) %x0 ( %y0 + %ry )
	line  %x0 ( %y0 + %h - %ry )
	close
}


