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

📄 boxlayout.pl

📁 PRl教学程序 PRl教学程序 PRl教学程序
💻 PL
字号:
/********************************************************************
    Constraint-based Graphical Programming in B-Prolog
    %
    pack boxes in a rectangle (takes loooong time if the layout is not given)
*********************************************************************/
go:-
    cgRectangle(Area),Area^width #= 330, Area^height #= 240,
    findall(box(W,H,X,Y,C),box(W,H,X,Y,C),Boxes),
    createRects(Boxes,Rects),
    cgNotOverlap(Rects),
    %
    insideArea(Rects,Area),
    cgJava(boxLayout,Rects).

createRects([],[]).
createRects([box(W,H,X,Y,C)|Boxes],[Rect|Rects]):-
    cgRectangle(Rect),
    Rect^width #= W,
    Rect^height #= H,
    Rect^x #= X,
    Rect^y #= Y,
    Rect^color #= C,
    createRects(Boxes,Rects).

insideArea([],_Area).
insideArea([Rect|Rects],Area):-
    cgInside(Rect,Area),
    insideArea(Rects,Area).

box(30,90,270,120,darkGray).
box(60,60,270,60,blue).
box(90,60,180,150,cyan).
box(90,30,240,30,orange).
box(120,30,180,210,lightGray).
box(120,60,30,60,pink).
box(30,120,300,120,magenta).
box(60,90,90,120,gray).
box(60,120,30,120,green).
box(60,30,90,210,red).
box(210,30,30,30,black).
box(90,90,180,60,white).  
box(30,180,150,60,yellow).


⌨️ 快捷键说明

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