{{fbdoc item="title" value="VIEW (GRAPHICS)"}}----
Sets new physical coordinate mapping and clipping region for graphics keywords

{{fbdoc item="syntax"}}##
	**View**
	**View** ( //x1//, //y1// )-( //x2//, //y2// ) [ [, //fill_color// ] [, //border_color// ] ]
	**View Screen** ( //x1//, //y1// )-( //x2//, //y2// ) [ [, //fill_color// ] [, //border_color// ] ]
##
{{fbdoc item="param"}}
	##//x1//## ##[[KeyPgAs|as]] [[KeyPgInteger|Integer]]##, ##//y1//## ##[[KeyPgAs|as]] [[KeyPgInteger|Integer]]##
		The horizontal and vertical offsets, in pixels, of one corner of the viewport relative to the top-left corner of the screen.
	##//x2//## ##[[KeyPgAs|as]] [[KeyPgInteger|Integer]]##, ##//y2//## ##[[KeyPgAs|as]] [[KeyPgInteger|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//## ##[[KeyPgAs|as]] [[KeyPgUlong|ULong]]##
		The color to fill the new viewport.
	##//border_color//## ##[[KeyPgAs|as]] [[KeyPgUlong|ULong]]##
		The color of the border to draw around the new viewport.

{{fbdoc item="desc"}}
	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 ##[[KeyPgScreengraphics|Screen (Graphics)]]## or ##[[KeyPgScreenres|ScreenRes]]## before calling ##**View**## or ##**View Screen**##.
	
	The first statement (##**View**##) sets the viewport to encompass the entire screen, which is the default viewport for a new graphics screen.
	
	The second and third statements (##**View**## ##//parameters//## and ##**View** Screen## ##//parameters//##) both allow a new viewport to be defined. The indicated effects for each parameter only occur if that parameter is specified:
		- The corners of the viewport are specified by the ##//x1//##, ##//y1//##, ##//x2//## and ##//y2//## parameters.
		- ##//fill_color//## and ##//border_color//## are both in the format accepted by ##[[KeyPgColor|Color]]##.
		- The second 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 third statement (##**View** Screen## ##//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 screen.
		- In both cases no new scale factor is applied (see ##[[KeyPgWindow|Window]]## for that).

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/gfx/view.bas"}}%%(freebasic)
screen 12
dim ip as any ptr
dim as integer 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
  screenlock
  
  'clear viewport and put image
  cls 1
  put (x, y), ip, pset
	
  screenunlock

loop while inkey = ""

imagedestroy(ip)
%%

{{fbdoc item="diff"}}
	- QBASIC preserves the ##WINDOW## coordinate mapping after subsequent calls to ##VIEW##.
	- ""FreeBASIC's"" current behavior is to preserve the ##WINDOW## coordinates after calls to ##VIEW##, or when working on images, meaning that the coordinate mapping may undergo scaling/translations if the viewport changes. (If a ##WINDOW## hasn't been set, there is no coordinate mapping, and so it doesn't change after calls to ##VIEW##.)  The behavior may change in future, but consistent behavior can be assured over inconstent viewport coordinates by re-calling ##WINDOW## whenever you change the ##VIEW##.

{{fbdoc item="see"}}
	- ##[[KeyPgViewtext|View Print]]##
	- ##[[KeyPgScreengraphics|Screen (Graphics)]]##
	- ##[[KeyPgWindow|Window]]##
	- ##[[KeyPgPmap|Pmap]]##

{{fbdoc item="back" value="CatPgGfxScreen|Screen Functions"}}