Chapter 5. Graphics Primitives

2 views
Skip to first unread message

Pterodactyl

unread,
Apr 30, 2007, 2:34:09 AM4/30/07
to Dive Into PHP 5: The Graphics
Chapter 5. Graphics Primitives

Table of Contents

Pixels and Segments
Shapes
Text

This chapter talks about common shapes and fonts.

Pixels and Segments

Pixels are atoms of an bitmap image. Usually we need to get and set a
color of a certain pixel of the image. Pixels are defined by their
coordinates and colors.

Figure 5.1. Colored Pixels
[http://pterodactyl.l2p.net/images/Pixels.png]
Colored Pixels

Segments of straight lines are defined by coordinates of their ends
and their colors.

Segments of curves need more complex definition. An example of curved
segments is an arc.

Figure 5.2. Line and Curve Segments
[http://pterodactyl.l2p.net/images/Segments.png]
Line and Curve Segments

Shapes

Some shapes, such as rectangles and polygons, are composed of straight
line segments.

Figure 5.3. Rectangles and Polygons
[http://pterodactyl.l2p.net/images/StraightedShapes.png]
Rectangles and Polygons

Some shapes, however, such as circles and ellipses, are curved.

Figure 5.4. Circles and Ellipses
[http://pterodactyl.l2p.net/images/CurvedShapes.png]
Circles and Ellipses

As far as you can see, shapes can be filled with color. Other fillers
are gradients and patterns.
Text

In addition to pixels, segments (see the section called "Pixels and
Segments"), and shapes (see the section called "Shapes") you can add
text to the image as well playing with its position, color, font, etc.

Figure 5.5. Text Samples
[http://pterodactyl.l2p.net/images/Text.png]
Text Samples

Reply all
Reply to author
Forward
0 new messages