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

📄 usa.pl

📁 PRl教学程序 PRl教学程序 PRl教学程序
💻 PL
字号:
/********************************************************************
    Constraint-based Graphical Programming in B-Prolog
    %
    Draw the USA flag
*********************************************************************/
go:-
    usa(Os),
    cgJava(usa,Os).

usa(AllComps):-
    cgRectangle(R),R^color #= white,
    2*R^width #= 3*R^height,
    R^width #>100,

    length(Strips,7),
    cgRectangles(Strips), 
    cgSame(Strips,color,red), cgSame(Strips,width,R^width), cgSame(Strips,height,R^height/13),
    cgSameX(Strips),
    Strips=[Strip1|_],Strip1^y #= R^y,
    constrainStrips(Strips),


    cgRectangle(BlueRect), BlueRect^color #= blue, BlueRect^x #= R^x, BlueRect^y #= R^y,
    R^width #= 2*BlueRect^width,
    7*R^height #= 13*BlueRect^height,

    length(WhiteStars,50),
    cgStars(WhiteStars),
    cgSame(WhiteStars,n,5), cgSame(WhiteStars,color,white),
    cgSame(WhiteStars,diameter,BlueRect^height/10),
    constrainStars(WhiteStars,BlueRect),
    
    cgRectangle(Frame),Frame^fill#=0,
    cgSamePosition([Frame,R]), cgSameSize([Frame,R]),
    
    append([R|Strips],[BlueRect,Frame|WhiteStars],AllComps).

constrainStrips([_]):-!.
constrainStrips([Strip1,Strip2|Strips]):-
    Strip2^y #= Strip1^y+2*Strip1^height,
    constrainStrips([Strip2|Strips]).

constrainStars(Stars,BlueRect):-
    Stars=[S11,S12,S13,S14,S15,S16,
	   S21,S22,S23,S24,S25,
	   S31,S32,S33,S34,S35,S36,
	   S41,S42,S43,S44,S45,
	   S51,S52,S53,S54,S55,S56,
	   S61,S62,S63,S64,S65,
	   S71,S72,S73,S74,S75,S76,
	   S81,S82,S83,S84,S85,
	   S91,S92,S93,S94,S95,S96],

    S21^centerX #= (S11^centerX+S12^centerX)/2,
    S21^centerY #= (S11^centerY+S31^centerY)/2,
    cgSameCenterX([S23,BlueRect]),
    cgInside(Stars,BlueRect),

    Pad #> S11^width,
    cgGrid([[S11,S12,S13,S14,S15,S16],
	    [S31,S32,S33,S34,S35,S36],
	    [S51,S52,S53,S54,S55,S56],
	    [S71,S72,S73,S74,S75,S76],
	    [S91,S92,S93,S94,S95,S96]],Pad,Pad),
    cgGrid([[S21,S22,S23,S24,S25],
	    [S41,S42,S43,S44,S45],
	    [S61,S62,S63,S64,S65],
	    [S81,S82,S83,S84,S85]],Pad,Pad).

⌨️ 快捷键说明

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