/** brview([[apple,5,5,5]],Views). book \ \ 2 / \ / \ / / / / 5 / / \ / \ / * * * * * * /|5 * / | * / | ** / | | \ / | | | / | | / | | / \ | / \|/ F / \ / \ / /G / / | / / | E\ / | | \ / C | D / | | / A | / \ | / \|/ B **/ brview(Item) :- Item = [_Object, X, Y , Z], /** atom_length(Object,ObjectNameLength), atom_length(X,XLength), atom_length(Y,YLength), atom_length(Z,ZLength),**/ WinX is X+Y+4, WinY is X+Y+Z, createwindow(WinX, 0, WinY, [],Window1), drawprism(X, Y, Z, Window1,Window3), WinX2 is 2*WinX-1, WinY2 is 2*WinY-1, print(WinX2,WinY2,0,Window3). maximum(A,B,A) :- A >= B, !. minimum(A,B,B) :- B > A. createwindow(_X,Y,Y,Window,Window) :- !. createwindow(X,Y1,Y2, Window1,Window2) :- createrow(0,X,Y1, [],Row), append(Window1,Row,Window3), Y3 is Y1+1, createwindow(X,Y3, Y2, Window3, Window2). createrow(X,X,_,Row,Row) :- !. createrow(X1, X2, Y, Row1, Row2) :- createposition(X1,Y, Position), append(Row1,[Position],Row3), X3 is X1+1, createrow(X3,X2, Y,Row3,Row2). createposition(X, Y, Position) :- Position = [X,Y,' ']. drawprism(X,Y,Z,Window1,Window10) :- AX is 0, AY is X+1, BX is X+1, BY is 0, CX is X+Y+2, CY is Y+1, DX is BX, DY is BY+Z, EX is AX, EY is AY+Z-1, FX is Y+1, FY is X+Y+Z+1, GX is CX, GY is CY + Z -1, line1(AX,AY,BX,BY,Window1,Window2), line1(BX,BY,CX,CY,Window2,Window3), line1(AX,BX,EX,EY,Window3,Window4), line1(BX,BY,DX,DY,Window4,Window5), line1(CX,CY,GX,GY,Window5,Window6), line1(EX,EY,DX,DY,Window6,Window7), line1(EX,EY,FX,FY,Window7,Window8), line1(DX,DY,GX,GY,Window8,Window9), line1(FX,FY,GX,GY,Window9,Window10). line1(X,Y1,X,Y2,Window1,Window2) :- line3(X,Y1,Y2,Window1,Window2), !. line1(X1,Y1,X2,Y2,Window1,Window2) :- C is Y1-((Y2-Y1)/(X2-X1))*X1, M is (Y2-Y1)/(X2-X1), line2(X1,X2,C,M,Window1,Window2). line2(X,X,_,_,Window,Window) :- !. line2(X1,X2,C,M,Window1, Window2) :- draw(X1,C,M,Window1,Window3), /* deleted X2 */ X3 is X1+1, line2(X3,X2,C,M,Window3,Window2). line3(_X,Y,Y,Window,Window) :- !. line3(X,Y1,Y2,Window1,Window2) :- delete(Window1,[X,Y1,_],Window3), append(Window3,[[X,Y1,'*']],Window4), Y3 is Y1 +1, line3(X, Y3,Y2,Window4,Window2). draw(X1,C,M,Window1,Window2) :- /**X2? ** delete **/ Y is M*X1+C, delete(Window1,[X1,Y,_],Window3), append(Window3,[[X1,Y,'*']],Window2). /**writelabel(X,Y,Z,Object,XLength,YLength,_ZLength,Window1,Window2) :- HX is X+Y+4, HY is Y+Z+1, atom_chars(Object,ObjectChars), write1(HX,HY,ObjectChars,Window1,Window3), I1X is HX, I1Y is HY+1, write1(I1X,I1Y,X,Window3,Window4), I2X is I1X, I2Y is I1Y+XLength, write1(I2X,I2Y,Y,Window4,Window5), I3X is I2X, I3Y is I2Y+YLength, write1(I3X,I3Y,Z,Window5,Window2). /**atom_chars(CoordsString,[X,',',Y,',',Z]), atom_chars(CoordsString,CoordsChars), IX is HX, IY is HY+1, write1(IX,IY,CoordsChars,Window3,Window2).**/ write1(X1,Y,String,Window1,Window2) :- atom_length(String,Length), X2 is X1+Length, write2(X1,X2,Y,String,Window1,Window2). write2(X,X,_,[],Window,Window) :- !. write2(X1,X2,Y,[Character|String],Window1, Window2) :- delete(Window1,[X1,Y,_],Window3), append(Window3,[[X1,Y,Character]],Window4), X3 is X1+1, write2(X3,X2,Y,String,Window4,Window2).**/ print(_X, Y, Y, _Window) :- !. print(X,Y1, Y2, Window) :- print_row(0, X, Y1, Window), Y3 is Y1-1, writeln(''), print(X, Y3,Y2,Window). print_row(X,X,_Y,_Window). print_row(X1, X2,Y1,Window) :- member([X1,Y1,Character],Window), write(Character), X3 is X1+1, print_row(X3,X2,Y1,Window). print_row(X1, X2,Y1,Window) :- write(' '), X3 is X1+1, print_row(X3,X2,Y1,Window).