Skip to content

Instantly share code, notes, and snippets.

@shawntan
Created September 16, 2011 10:23
Show Gist options
  • Save shawntan/1221777 to your computer and use it in GitHub Desktop.
Save shawntan/1221777 to your computer and use it in GitHub Desktop.
%rotate(rotate(beside(rotate(beside(rotate(rotate(rotate(A))),rotate(rotate(A)))),rotate(beside(Expr,rotate(A))))))
tile(N,A,O):- spinit(N,A,Expr),montage(Expr,O).
spinit(0,A,A).
spinit(N,A,rotate(rotate(rotate(beside(rotate(beside(rotate(rotate(rotate(A))),rotate(rotate(A)))),rotate(beside(Expr,rotate(A)))))))):-
M is N-1,spinit(M,A,Expr),!.
ma(X=Expr;Exprs) :-
montage(Expr,X),
ma(Exprs),!.
ma(X=Expr) :-
montage(Expr,X),!.
montage(Expr,File) :-
evaluate(Expr,100,100,File).
evaluate(E,Width,Height,R) :-
E =.. [rotate,P],
atom_concat(R,'1',R1),
evaluate(P,Height,Width,R1),
write('convert -rotate 90 '),
write(R1),write('.jpg'),
write(' '),
write(R),write('.jpg'),
writeln(''),!.
evaluate(E,Width,Height,R) :-
E =.. [beside,P1,P2],
atom_concat(R,'1',R1),atom_concat(R,'2',R2),
W is Width/2,
evaluate(P1,W,Height,R1),evaluate(P2,W,Height,R2),
write('convert +append '),
write(R1),write('.jpg '),write(' '),
write(R2),write('.jpg'),write(' '),
write(R),write('.jpg'),
writeln(''),!.
evaluate(E,Width,Height,R) :-
atom(E),
write('convert -scale '),
write(Width),write('%%'),write('x'),
write(Height),write('%%'),write(' '),
write(E),write('.jpg'),write(' '),
write(R),write('.jpg'),
writeln(''),!.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment