-
Notifications
You must be signed in to change notification settings - Fork 2
Graphics
In the default coordinate system of PDF, shown below, the lower-left corner is at coordinates (0, 0), and the upper-right corner is at coordinates (width, height). The default resolution is 72dpi.
http://libharu.org/figures/figure3.png
An application can change the coordinate system by invoking HPDF_Page_Concat ().
For example, if an application invokes HPDF_Page_Concat (page, 0.5, 0, 0, 0.5, 100, 100) in the default state,
the coordinate system shown above is transformed to the new system shown in the figure below.
http://libharu.org/figures/figure4.png
In libHaru, each page object maintains a flag named "graphics mode". The graphics mode corresponds to the graphics-object of the PDF specification.
The graphics mode is changed by invoking particular functions. The functions that can be invoked are decided by the value of the graphics mode.
The following figure shows the relationships of the graphics mode.
http://libharu.org/figures/figure6.png
A path is composed of straight and curved line segments. Paths define shapes and regions.
Vector graphics are drawn by the following steps:
- Set graphics states (such as line-width, dash-pattern, color...) using "Graphics State Operators" or "Color Operators".
- Start new path using HPDF_Page_MoveTo(), HPDF_Page_Rectangle(), HPDF_Page_Arc(), or HPDF_Page_Circle().
- Append to path using "Path Construction Operators".
- Stroke or paint the path using "Path Painting Operators".
- HPDF_Page_Concat
- HPDF_Page_SetDash
- HPDF_Page_SetFlat
- HPDF_Page_SetLineCap
- HPDF_Page_SetLineJoin
- HPDF_Page_SetLineWidth
- HPDF_Page_SetMiterLimit
- HPDF_Page_SetCMYKFill
- HPDF_Page_SetCMYKStroke
- HPDF_Page_SetGrayFill
- HPDF_Page_SetGrayStroke
- HPDF_Page_SetRGBFill
- HPDF_Page_SetRGBStroke
- HPDF_Page_Arc()
- HPDF_Page_Circle()
- HPDF_Page_CurveTo()
- HPDF_Page_CurveTo2()
- HPDF_Page_CurveTo3()
- HPDF_Page_LineTo()
- HPDF_Page_MoveTo()
- HPDF_Page_Rectangle()
- HPDF_Page_ClosePathFillStroke
- HPDF_Page_ClosePathEofillStroke
- HPDF_Page_ClosePathStroke
- HPDF_Page_Eofill
- HPDF_Page_EofillStroke
- HPDF_Page_EndPath
- HPDF_Page_Fill
- HPDF_Page_FillStroke
- HPDF_Page_Stroke
Text is drawn by the following steps:
- Start drawing text by invoking HPDF_Page_BeginText().
- Set text states (such as font, filling-color...) using "Text State Operators" or "Color Operators". At least HPDF_Page_SetFontAndSize() must be invoked once before invoking "Text Showing Operators".
- Set text positioning by invoking "Text Positioning Operators".
- Show text by invoking "Text Showing Operators".
- Repeat steps 2 to 4 if necessary.
- Finish drawing text by invoking HPDF_Page_EndText().
http://libharu.org/figures/figure5.png
- HPDF_Page_SetCharSpace
- HPDF_Page_SetFontAndSize
- HPDF_Page_SetHorizontalScalling
- HPDF_Page_SetTextLeading
- HPDF_Page_SetTextRenderingMode
- HPDF_Page_SetTextRise
- HPDF_Page_SetWordSpace
- HPDF_Page_MoveTextPos
- HPDF_Page_MoveTextPos2
- HPDF_Page_SetTextMatrix
- HPDF_Page_ShowText
- HPDF_Page_ShowTextNextLine
- HPDF_Page_ShowTextNextLineEx
- HPDF_Page_TextOut
- HPDF_Page_TextRect
Colors are specified using three real numbers (ie ones with a decimal point) in the form R G B where each number defines the amount of red (R), green (G) and blue (B) in a color. The valid numbers are from 0.0 to 1.0 inclusive.
Below is a table showing 216 example colors and their real notations:
0.0, 0.0, 0.0 | 0.0, 0.0, 0.2 | 0.0, 0.0, 0.4 | 0.0, 0.0, 0.6 | 0.0, 0.0, 0.8 | 0.0, 0.0, 1.0 |
0.0, 0.2, 0.0 | 0.0, 0.2, 0.2 | 0.0, 0.2, 0.4 | 0.0, 0.2, 0.6 | 0.0, 0.2, 0.8 | 0.0, 0.2, 1.0 |
0.0, 0.4, 0.0 | 0.0, 0.4, 0.2 | 0.0, 0.4, 0.4 | 0.0, 0.4, 0.6 | 0.0, 0.4, 0.8 | 0.0, 0.4, 1.0 |
0.0, 0.6, 0.0 | 0.0, 0.6, 0.2 | 0.0, 0.6, 0.4 | 0.0, 0.6, 0.6 | 0.0, 0.6, 0.8 | 0.0, 0.6, 1.0 |
0.0, 0.8, 0.0 | 0.0, 0.8, 0.2 | 0.0, 0.8, 0.4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 | 0.8, 0.2, 1.0 |
0.8, 0.4, 0.0 | 0.8, 0.4, 0.2 | 0.8, 0.4, 0.4 | 0.8, 0.4, 0.6 | 0.8, 0.4, 0.8 | 0.8, 0.4, 1.0 |
0.8, 0.6, 0.0 | 0.8, 0.6, 0.2 | 0.8, 0.6, 0.4 | 0.8, 0.6, 0.6 | 0.8, 0.6, 0.8 | 0.8, 0.6, 1.0 |
0.8, 0.8, 0.0 | 0.8, 0.8, 0.2 | 0.8, 0.8, 0.4 | 0.8, 0.8, 0.6 | 0.8, 0.8, 0.8 | 0.8, 0.8, 1.0 |
0.8, 1.0, 0.0 | 0.8, 1.0, 0.2 | 0.8, 1.0, 0.4 | 0.8, 1.0, 0.6 | 0.8, 1.0, 0.8 | 0.8, 1.0, 1.0 |
1.0, 0.0, 0.0 | 1.0, 0.0, 0.2 | 1.0, 0.0, 0.4 | 1.0, 0.0, 0.6 | 1.0, 0.0, 0.8 | 1.0, 0.0, 1.0 |
1.0, 0.2, 0.0 | 1.0, 0.2, 0.2 | 1.0, 0.2, 0.4 | 1.0, 0.2, 0.6 | 1.0, 0.2, 0.8 | 1.0, 0.2, 1.0 |
1.0, 0.4, 0.0 | 1.0, 0.4, 0.2 | 1.0, 0.4, 0.4 | 1.0, 0.4, 0.6 | 1.0, 0.4, 0.8 | 1.0, 0.4, 1.0 |
1.0, 0.6, 0.0 | 1.0, 0.6, 0.2 | 1.0, 0.6, 0.4 | 1.0, 0.6, 0.6 | 1.0, 0.6, 0.8 | 1.0, 0.6, 1.0 |
1.0, 0.8, 0.0 | 1.0, 0.8, 0.2 | 1.0, 0.8, 0.4 | 1.0, 0.8, 0.6 | 1.0, 0.8, 0.8 | 1.0, 0.8, 1.0 |
1.0, 1.0, 0.0 | 1.0, 1.0, 0.2 | 1.0, 1.0, 0.4 | 1.0, 1.0, 0.6 | 1.0, 1.0, 0.8 | 1.0, 1.0, 1.0 |
The reason that 216 colors were used out of the possible palette of 256 colors is that this allowed an even sampling of color throughout the color space that can be realised on most displays by dividing it up into areas which represent one-sixth of the possible values of all color components of red, green and blue - hence we get a cube which has 6 possible areas of red, 6 of green and 6 of blue which together make up 6x6x6 = 216 combinations.
Today most screens are viewed in True color which uses 24-bits and uses the full range of 256 possible values for each red, green and blue color component which give 256x256x256 = 16777216 colors.
However, this can be quite daunting for non-artists to work with and the web safe palette is a useful starting point when considering color schemes.