x-08-psi > restart; > peindrePixel:=proc(x,y,g) > global dessin; > dessin[h-y,x+1]:=evalf(g,3) > end: > peindreRegion:=proc(w,h,a,b) > local x,y; > for x from 0 to w-1 do > for y from 0 to h-1 do > if a*x+b fi; > od; > od; > RETURN(); > end: > w:=10;h:=10;a:=0.2;b:=2.8;dessin:=matrix(w,h,0):peindreRegion(w,h,a,b);evalm(dessin); w := 10 h := 10 a := .2 b := 2.8 [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 0 , 0 , 0 , 0] [ ] [1. , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] %1 := [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] > yMin:=proc(x) > global a,b; > RETURN (floor(a*x+b)) > end: > peindreRegionBis:=proc(w,h,a,b) > local x,y; > for x from 0 to w-1 do > for y from yMin(x) to h-1 do > peindrePixel(x,y,1) > od; > od; > RETURN(); > end: > dessin:=matrix(w,h,0):peindreRegionBis(w,h,a,b);evalm(dessin); [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 0 , 0 , 0 , 0] [ ] [1. , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] %1 := [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] > peindreRegionAA:=proc(w,h,a,b) > local x,y,score,g; > for x from 0 to w-1 do > for y from 0 to h-1 do > score:=0; > if a*(x)+b<=y then score:=score+1 fi; > if a*(x)+b<=y+1/2 then score:=score+1 fi; > if a*(x+1/2)+b<=y then score:=score+1 fi; > if a*(x+1/2)+b<=y+1/2 then score:=score+1 fi; > g:=(score)/4; > peindrePixel(x,y,g); > od; > od; > RETURN(); > end: > > dessin:=matrix(w,h,0):peindreRegionAA(w,h,a,b);evalm(dessin); [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , .750 , .500 , .500 , 0] [ ] [1. , .750 , .500 , .500 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] %1 := [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] > peindreRegionAABis:=proc(w,h,a,b) > local x,y,bg,bd,hg,hd,y1,y2,g,score; > for x from 0 to w-1 do > y1:=-floor(-a*x-b+0.5)-1;y2:=-floor(-a*x-a*0.5-b); > if y2>h then y2:=h fi; > for y from y1+1 to y2-1 do > score:=0; > if a*(x)+b<=y then score:=score+1 fi; > if a*(x)+b<=y+1/2 then score:=score+1 fi; > if a*(x+1/2)+b<=y then score:=score+1 fi; > if a*(x+1/2)+b<=y+1/2 then score:=score+1 fi; > g:=(score)/4; > peindrePixel(x,y,g); > od; > for y from y2 to h-1 do > peindrePixel(x,y,1); > > od; > od; > RETURN(); > end: > dessin:=matrix(w,h,0):peindreRegionAABis(w,h,a,b);evalm(dessin); [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [ ] [1. , 1. , 1. , 1. , 1. , 1. , .750 , .500 , .500 , 0] [ ] [1. , .750 , .500 , .500 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [ ] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] %1 := [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] > f:=t->(t-1+a/2)^2/2/a; 2 (t - 1 + 1/2 a) f := t -> 1/2 ---------------- a > peindreRegionAAA:=proc(w,h,a,b) > local x,y,S,s0,y1,y2; > S:=2-a/2-b+yMin(0); > y1:=yMin(0); > for x from 0 to w-1 do > y2:=y1+1; > if S<=1+a/2 then s0:=f(S) else s0:=S-1 fi; > if y1 if y2 if S<=1+a/2 then S:=1+S-a;y1:=y1+1 > else S:=S-a > fi; > for y from y2+1 to h-1 do > peindrePixel(x,y,1); > > od; > od; > RETURN(); > end: > dessin:=matrix(w,h,0):peindreRegionAAA(w,h,a,b);evalm(dessin); [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1.00 , 1.00 , 1.00 , 1.00] [1. , 1.00 , 1.00 , 1.00 , 1.00 , 1.00 , .900 , .700 , .500 , .300] [1.00 , .900 , .700 , .500 , .300 , .100 , 0 , 0 , 0 , 0] [.100 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] %1 := [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] > peindreRegionAAABis:=proc(w,h,a,b) > local x,y,S,s0,y1,y2,f0,f1,f2; > f0:=(1-b+floor(b))^2/a/2; > f1:=(1-b+floor(b))/a; > f2:=-a*f1; > S:=2-a/2-b+yMin(0); > y1:=yMin(0); > for x from 0 to w-1 do > y2:=y1+1; > if S<=1+a/2 then s0:=f0 else s0:=S-1 fi; > if y1 if y2 if S<=1+a/2 then > S:=1+S-a; > y1:=y1+1; > f0:=f0+f1+1/2/a; > f1:=f1+1/a; > f2:=-a*f1; > f0:=f0+f2+a/2; > f1:=f1-1; > f2:=-a*f1; > else S:=S-a; > f0:=f0+f2+a/2; > f1:=f1-1; > f2:=-a*f1; > fi; > for y from y2+1 to h-1 do > peindrePixel(x,y,1); > > od; > od; > RETURN(); > end: > dessin:=matrix(w,h,0):peindreRegionAAABis(w,h,a,b);evalm(dessin); [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.] [1. , 1. , 1. , 1. , 1. , 1. , 1.00 , 1.00 , 1.00 , 1.00] [1. , 1.00 , 1.00 , 1.00 , 1.00 , 1.00 , .900 , .700 , .500 , .300] [1.00 , .900 , .700 , .500 , .300 , .100 , 0 , 0 , 0 , 0] [.100 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0] %1 := [1., 1., 1., 1., 1., 1., 1., 1., 1., 1.] >