Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.60 KB | None | 0 0
  1. open ImgUtil
  2. type F = C of point*int*colour|R of point*point*colour|M of F*F
  3. let rec K (x,y) f=(match f with|C((q,e),r,c) when ((q-x)*(q-x)+(e-y)*(e-y)<=r*r)->S c|R((q,e),(a,d),c) when (q<=x&&x<=a&&e<=y&&y<=d)->S c|M (q,e) -> (match (K(x,y) q, K(x,y) e) with |(N,c)->c|(c,N)->c|(S (r, g, b), S(e,G,B))->S((r+e)/2,(g+G)/2,(b+B)/2))|_->N)
  4. let makePicture (n) (f) (w) (h)=let (d, P, b, p)=(fromRgb (1,1,1),(fun c->fromRgb(match K c f with | S g -> g|N->(128,128,128))),mk w h,List.concat(List.init(w-1) (fun x->List.init(h-1) (fun y->(x,y))))) in (List.map(fun(x,y)->setPixel(P (x,y)) (x,y) b) p,toPngFile n b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement