8. Примеры

8.1. 2D-графика

Данный пример иллюстрирует использование различных GML-элементов с переключением графического контекста и носит чисто демонстрационный характер.

gml [ w 800 h 600 color "lightgray"
    pixmap "ftp://localhost/pub/purple_marble.png"
    grid [ color "pink" ]
    pen [ w 2 color "green"
	ellipse [ x 300 y 10 w 200 h 150 width 3 color "red" ]
	fillellipse [ x 330 y 50 w 150 h 100 color "pink" ]
	arc [ x 200 y 450 w 200 h 100 start 30 extent -300 ]
	fillarc [ x 210 y 460 w 180 h 80 start 30 extent -300 color "red"]
	blend [ alpha 0.5
	    fillarc [ x 210 y 470 w 180 h 80 start 30 extent -300 color "blue"]
	]
	shear [ sx 0.01 sy 0.01
	    rect [ x 600 y 100 w 100 h 100 color "black"]
	]
	scale [ sx 1.2 sy 0.7
	    translate [ x 200 y 100
	        rotate [ a 20
		    pen [ w 4 color "blue"
	                font [ name "Serif" style "bolditalic" size 24
		            text [ str "Hello Word!" x 200 y 100 ]
		            line [ x1 200 y1 200 x2 300 y2 300 ]
		            text [ str "Привет!" x 400 y 100 ]
	                ]
	                rect [ x 150 y 150 w 200 h 200 ]
	            ]
	        ]
	    ]
	]
	brush [ color1 "white" y1 300 color2 "red" x2 300
	    fillrect [ x 50 y 300 w 100 h 200 ]
            line [ x1 500 y1 100 x2 400 y2 400 ]
	    brush [ color1 "blue" x2 50 y2 50 color2 "white" x2 200 y2 200
		clip [ x 60 y 60 w 80 h 80
		    fillrect [ x 55 y 55 w 100 h 100 ]
		]
		pen [ color "red"
		    rect [ x 55 y 55 w 100 h 100 ]
		]
		rect [ x 50 y 50 w 110 h 110 ]
	    ]
	]
	blend [ alpha 0.7
	    fillrect [ x 550 y 300  w 100 h 200 ]
#	    image [ name "ftp://localhost/pub/vova.jpg" x 210 y 210 w 100 h 100 ]
	]
    ]
    translate [ x 180 y 40
	axis [ len 650 zero 100 step 30 width 2 color "darkgray"]
	rotate [ x 0 y 0 a 90
	    axis [ len 500 zero 20 step 20 width 2 color "darkgray"]
	]
    ]
]

Графическая интерпретация