官术网_书友最值得收藏!

Drawing basics

The screens of modern computers consist of a number of small squares, called pixels (picture elements). Each pixel can light in one color. You create pictures on the screen by changing the colors of the pixels.

Note

Graphics based on pixels is called raster graphics. Another kind of graphics is vector graphics, which is based on primitives such as lines and circles. Today, most computer screens are arrays of pixels and represent raster graphics. But images based on vector graphics (vector images) are still used in computer graphics (for details, see the Images basics section in Chapter 4, Images and Textures). Vector images are drawn on raster screens using the rasterization procedure.

The openFrameworks project can draw on the whole screen (when it is in fullscreen mode) or only in a window (when fullscreen mode is disabled). See how to set screen modes in the main.cpp and setup() sections in Chapter 1, openFrameworks Basics. For simplicity, we will call the area where openFrameworks can draw, the screen. The current width and height of the screen in pixels may be obtained using the ofGetWidth() and ofGetHeight() functions.

For pointing the pixels, openFrameworks uses the screen's coordinate system. This coordinate system has its origin on the top-left corner of the screen. The measurement unit is a pixel. So, each pixel on the screen with width w and height h pixels can be pointed by its coordinates (x, y), where x and y are integer values lying in the range 0 to w-1 and from 0 to h-1 respectively.

In this chapter, we will deal with two-dimensional (2D) graphics, which is a number of methods and algorithms for drawing objects on the screen by specifying the two coordinates (x, y) in pixels.

Tip

The other kind of graphics is three-dimensional (3D) graphics, which represents objects in 3D space using three coordinates (x, y, z) and performs rendering on the screen using some kind of projection of space (3D) to the screen (2D). For details on 3D graphics, go through Chapter 7, Drawing in 3D.

主站蜘蛛池模板: 福州市| 望谟县| 娄烦县| 德州市| 泗洪县| 花莲县| 唐山市| 乌恰县| 江油市| 江安县| 鄱阳县| 营口市| 罗平县| 文登市| 尉犁县| 霞浦县| 色达县| 高淳县| 台江县| 湘西| 玉山县| 邛崃市| 和林格尔县| 布尔津县| 德阳市| 洛川县| 衢州市| 永胜县| 安西县| 吉木乃县| 北票市| 邯郸县| 峡江县| 灵寿县| 昭苏县| 临泽县| 奎屯市| 吉木乃县| 汉中市| 辉县市| 五莲县|