Repository navigation
View Graphics
Home › Screen Functions › View (Graphics)
Sets the rectangle that drawing is clipped to, or resets it to the whole screen.
View
View ( x1, y1 )-( x2, y2 ) [ [, fill_color ] [, border_color ] ]
View Screen ( x1, y1 )-( x2, y2 ) [ [, fill_color ] [, border_color ] ]x1y1x2y2fill_colorborder_color
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 (Graphics) or 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:
- QBASIC preserves the
WINDOWcoordinate mapping after subsequent calls toVIEW. FreeBASIC's current behavior is to preserve theWINDOWcoordinates after calls toVIEW, or when working on images, meaning that the coordinate mapping may undergo scaling/translations if the viewport changes. (If aWINDOWhasn't been set, there is no coordinate mapping, and so it doesn't change after calls toVIEW.) The behavior may change in future, but consistent behavior can be assured over inconstent viewport coordinates by re-callingWINDOWwhenever you change theVIEW.
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)Category: Screen Functions
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing