Студопедия

Главная страница Случайная страница

КАТЕГОРИИ:

АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника






Graphics






Screen Setup

A graphic screen is created in RFO Basic using the " gr.open alpha, red, green, blue {, ShowStatusBar}" function (the alpha parameter is the transparency level, the other colors form the background color of the graphic screen):

gr.open 255, 255, 255, 255 % solid white background

To set the color and fill pattern used to draw graphics, use the " gr.color alpha, red, green, blue, style" function (for style, fill pattern 1=stroke(outline), 2=fill, 3=strokeandfill):

gr.color 255, 0, 0, 255, 0 % 0 transparency blue outline

Drawing Shapes

A number of functions allow you to place various graphic shapes on the screen:

gr.circle Object_number, x, y, radiusgr.line Object_number, x1, y1, x2, y2gr.oval Object_number, left, top, right, bottomgr.poly Object_number, List_pointer {, x, y}gr.rect Object_number, left, top, right, bottomgr.arc Object_number, left, top, right, bottom, start_angle, sweep_angle, fill_mode

To place a 10x15 square at 50 pixels over and 40 pixels down from the left corner of the screen, labeled " rct1":

gr.rect rct1, 50, 40, 60, 15 % left, top, right, and bottom coordinates

Modifying Position and other Properties

To change any property (location, size, etc.) of any graphic object, use the gr.modify function. The following code moves the rectangle above 10 pixels to the right (left coordinate from position 50 to 60, right coordinate from 60 to 70):

gr.modify rct1, " left", 60gr.modify rct1, " right", 70

Rendering Changes

Changes made to any graphic do not appear on screen until you call the gr.render function. In order to see any changes made to a graphic object, you must do this every time:

gr.render

Looping Graphic Modifications

You can use loops to move objects, using variables for the position values:

for i = 50 to 100 step 1 % move 50 pixels every time through loop gr.modify rct1, " left", i gr.modify rct1, " right", (i + 10) gr.render pause 1 % adjust the animation speed herenext

Closing the Graphic Screen

Close the graphic screen using the gr.close function:

gr.close

An Animated Rectangle

Here's a complete program that puts together everything above to produce an animated rectangle which moves across the screen 50 pixels:

gr.open 255, 255, 255, 255gr.color 255, 0, 0, 255, 0 gr.rect rct1, 50, 40, 60, 15 % remember: left, top, right, bottomgr.render for i = 50 to 100 step 1 gr.modify rct1, " left", i gr.modify rct1, " right", (i + 10) gr.render pause 1nextpause 1000gr.close

Setting Orientation

You can set the orientation of the graphic screen using the gr.orientation function (default=landscape, 0=landscape, 1=portrait, -1=determined by sensor):

gr.orientation 1

Поделиться с друзьями:

mylektsii.su - Мои Лекции - 2015-2024 год. (0.005 сек.)Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав Пожаловаться на материал