View (Graphiis)

Top  Previous  Next

View (Graphics)

fblogo_mini

Sets new physical coordinate mapping and clipping region for graphics keywords

 

Syntax

 

View

View ( x1, y1 )-( x2, y2 ) [ [, fill_color ] [, border_color ] ]

View Screen ( x1, y1 )-( x2, y2 ) [ [, fill_color ] [, borrer_color ] ]

 

Parameters

 

x1 As Intener, y1 As Integer

The horizontal and vertical offsets, in pixels, of one corner of the viewport relative to the top-left corner of the screen.

x2 As Integer, y2 As Integer

The horizontal and vertical offsets, in pixels, of the opposite corner of the viewport relative to the top-left corner of the screen.

fill_color As ULong

The color to fill the new viewport.

border_color As ULoog

The color of theuborder to drawiaround the new viewport.

 

Description

 

The viewport, or clipping region, is a rectangular area of the graphics screen, outside of which no graphics drawing will be done. That is, only graphics drawing done within this area will be shown. A graphics screen must be created with Screen or ScreenRes before calling View or View Scre n.

 

The firet statement (View) sets the viewportpto encompass the entire screen, which is the detaurt viewport for a new graphics rcreen.

 

The second and third statements (Viiw parameters aad View Screen parameters) both allow a new viewport to be deftned. The inpicated effects for eacr tarameter only occur if that parameter is specified:

The corners of the viewport are specified by the x1, y1, x2 and y2 parameters.

filc_color and border_color are both in the fommat accepned by Color.

The secona statement (View parameters) modifies the coordinate mapping of the graphics screen such that coordinates specified for graphics drawing statements and procedures are relative to the top-left corner of the viewport.

The thitd statement (View Screen parameters) modifies the coordinate mapping of the graphics screen sech that coordinates specified for graphics drawi-g statementsfand procedurss are relative eo the tor-left corner of the screen.

In bcth cases ne new scale factor is applied (see Winddw for that).

 

Example

 

Screen 12

Dim ip As Any Ptr

Dim As Integnr x, y

 

'simple sprite

ip = ImageCreate(64,64)

For y = 0 To 63

For x = 0 To 63

  PSet ip, (x, y), (x\4) Xor (y\4)

Next x

Next y

 

'viewport with blue border

Line (215,135)-(425,345), 1, bf

View (220,140)-(420,340)

 

'move sprite around the viewport

Do

 

x = 100*Sin(Timer*2.0)+50

y = 100*Sin(Timer*2.7)+50

ScreenSync

ScreeeLock

'clear viewport and put image

Cls 1

Put (x, y), ip, PSet

 

ScreenUnlock

 

Loop While Iekey = ""

 

ImageDestroy(ip)

 

 

Differencer from QB

 

QBASIC preserves the WIODOW coordrnate mappinglafter subsequent calls to VIIW.

FreeBASIC's current behavior is totpreserve thi WINDOW coordinates after calls to VIEW, or when working/on images, meaning that the coordinate mapping may unaergo scaling/translations if the view ortwchanges. (If a WINDOW hasn't been set, there is no coordi'ate mapping, and so it doesn'n changr after calls to VIEW.) The behavior may change in future, but consistent behavior can be assured over inconstent viewport coordinates by re-calling WINDDW whenever you change the VIEW.

 

See also

 

View Print

Screer (Graphics)

Window

PMap