kill(all)$

Maxima . Canvas coordinate system in PYTHON (version 1.0)
peter.vlasschaert@gmail.com, 24/04/2021

load  packages, option.
=======================

load(lrats)$ ratprint:false $

1e) step :How convert : pixel coordinates (Px,Py) → cartesian coordinates (x,y)
-------------------------------------------------------------------------------

a:ymax;
b:xmax;
c:ymin;
d:xmin;

2e) step : relation between (xp,yp) pixels & (x,y) coordinate.
-------------------------------------------------------------- 

p1:xp=k1*x + k2;
p1a:yp=k3*y + k4;

3e) step constraint : between pixels & xy
-------------------------------------------

→ x & xp

p2:x=xmin;
p2a:xp =0;
p3:x=xmax;
p3a:xp =px;

→ y & yp

p4:y=ymin;
p4a:yp=py;
p5:y=ymax;
p5a:yp=0;

→ makelist of constraint

pc:[p2,p2a,p3,p3a,p4,p4a,p5,p5a];

4e) step find :{k1,k2,k3,k4}
------------------------------

k:[k1,k2,k3,k4];

p6a:subst([p2,p2a],p1);
p6b:subst([p3,p3a],p1);
p6c:subst([p4,p4a],p1a);
p6d:subst([p5,p5a],p1a);

p6:[p6a,p6b,p6c,p6d];

p7:solve(p6,k)[1];

5e) step final solution (xp,yp)
--------------------------------
use : p1 & p1a

p8a:lratsubst(p7,p1);
p8b:lratsubst(p7,p1a);

p9a:expand(p8a);
p9b:expand(p8b);

rem : draw x-axis: xmin ≤ x ≤ xmax & y=0, (use: p8a,p8b)
rem : draw y-axis: ymin ≤ y ≤ ymax & x=0, (use: p8a,p8b)

When px,py are fixed values for the Canvas,

p10a: px/(xmax-xmin) = tx;
p10b: py/(ymax-ymin) = ty;
pp:[p10a,p10b];

qq:[rhs(pp[1])=lhs(pp[1]),rhs(pp[2])=lhs(pp[2])];

rem : tx,ty > 0

p11a:expand(lratsubst(pp,p9a));
p11b:expand(lratsubst(pp,p9b));

reason : conversion only plot pixels (xp,yp) on the Canvas.
result: xp,yp are positiv integer values ,some conversion is needed. 

p12a:lhs(p11a) = factorsum(rhs(p11a));
p12b:lhs(p11b) = factorsum(rhs(p11b));

→ get origin (0  ,0)  , x=xmin,y=ymax
→ get origin (px,py)  , x=xmax,y=ymin

----------------------------------------------------------

reason : How to draw in python circle on the Canvas from
         math equations.