⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hexagons.pl

📁 PRl教学程序 PRl教学程序 PRl教学程序
💻 PL
字号:
/********************************************************************
    Constraint-based Graphical Programming in B-Prolog
    %
    draw a pattern of hexagons
*********************************************************************/
go:-
    cgSquare(S),
    S^fill #= 0,
    cgPack(S),
    hexagon(S,H),
    cgShow([S,H]).

/*

go:-
    Width = 50,
    Pad is round(Width*1.14/3.14),
    Pad2 is round(Width*2.14/3.14),
    %%
    length(Squares1,42), % 7*6 squares
    Squares1=[Sq1|_],
    cgSquares(Squares1),
    %%       
    list2ListList(Squares1,6,Board1),
    cgSame(Squares1,width,Width),
    cgSame(Squares1,fill,0),
    cgTable(Board1,Pad,0),
    cgPack(Squares1),
    %%
    length(Squares2,36), % 6*6 squares
    Squares2=[Sq2|_],
    cgSquares(Squares2),
    %%
    list2ListList(Squares2,6,Board2),
    cgSame(Squares2,width,Width),
    cgSame(Squares2,fill,0),
    cgTable(Board2,Pad,0),
    Sq2^x #= Sq1^x+Pad2,
    Sq2^y #= Sq1^y+Sq1^width//2,
    cgPack(Squares2),
    %%
    hexagons(Squares1,Hexagons1),
    hexagons(Squares2,Hexagons2),
    cgShow(Hexagons1),
    cgShow(Hexagons2).

list2ListList([],N,Board).
list2ListList(Squares,N,[Row|Board]):-
    length(Row,N),
    append(Row,Rest,Squares),
    list2ListList(Rest,N,Board).
*/

hexagons([],[]).
hexagons([S|Ss],[H|Hs]):-
    hexagon(S,H),
    hexagons(Ss,Hs).

hexagon(S,H):-
    cgPolygon(H),
    H^n #= 6,
    H^fill #= 0,
    H^x(0) #= S^x+S^width*1000//4538,
    H^y(0) #= S^y,

    H^x(1) #= S^x,
    H^y(1) #= S^y+S^height//2,

    H^x(2) #= H^x(0),
    H^y(2) #= S^y+S^height,

    H^x(3) #= S^x+S^width*3538//4538,
    H^y(3) #= S^y+S^height,

    H^x(4) #= S^x+S^width,
    H^y(4) #= H^y(1),

    H^x(5) #= H^x(3),
    H^y(5) #= S^y.
    



    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -