# Documentation/Graphics

### From libHaru.org wiki

< Documentation

# Coordinate system

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.

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.

# Graphics mode

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.

# Path Painting

A path is composed of straight and curved line segments. Paths define shapes and regions.

Vector graphics are drawn by the following steps:

1. Set graphics states (such as line-width, dash-pattern, color...) using "Graphics State Operators" or "Color Operators".
2. Start new path using HPDF_Page_MoveTo(), HPDF_Page_Rectangle(), HPDF_Page_Arc(), or HPDF_Page_Circle().
3. Append to path using "Path Construction Operators".
4. Stroke or paint the path using "Path Painting Operators".

## List of Graphics State Operators

1. HPDF_Page_Concat
2. HPDF_Page_SetDash
3. HPDF_Page_SetFlat
4. HPDF_Page_SetLineCap
5. HPDF_Page_SetLineJoin
6. HPDF_Page_SetLineWidth
7. HPDF_Page_SetMiterLimit

## List of Color Operators

1. HPDF_Page_SetCMYKFill
2. HPDF_Page_SetCMYKStroke
3. HPDF_Page_SetGrayFill
4. HPDF_Page_SetGrayStroke
5. HPDF_Page_SetRGBFill
6. HPDF_Page_SetRGBStroke

## List of Path Construction Operators

1. HPDF_Page_Arc()
2. HPDF_Page_Circle()
3. HPDF_Page_CurveTo()
4. HPDF_Page_CurveTo2()
5. HPDF_Page_CurveTo3()
6. HPDF_Page_LineTo()
7. HPDF_Page_MoveTo()
8. HPDF_Page_Rectangle()

## List of Path Painting Operators

1. HPDF_Page_ClosePathFillStroke
2. HPDF_Page_ClosePathEofillStroke
3. HPDF_Page_ClosePathStroke
4. HPDF_Page_Eofill
5. HPDF_Page_EofillStroke
6. HPDF_Page_EndPath
7. HPDF_Page_Fill
8. HPDF_Page_FillStroke
9. HPDF_Page_Stroke

# Text Showing

Text is drawn by the following steps:

1. Start drawing text by invoking HPDF_Page_BeginText().
2. 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".
3. Set text positioning by invoking "Text Positioning Operators".
4. Show text by invoking "Text Showing Operators".
5. Repeat steps 2 to 4 if necessary.
6. Finish drawing text by invoking HPDF_Page_EndText().

The figure below explains text positioning (needs more explanation).

## List of Text State Operator

1. HPDF_Page_SetCharSpace
2. HPDF_Page_SetFontAndSize
3. HPDF_Page_SetHorizontalScalling
4. HPDF_Page_SetTextLeading
5. HPDF_Page_SetTextRenderingMode
6. HPDF_Page_SetTextRise
7. HPDF_Page_SetWordSpace

## List of Text Positioning Operators

1. HPDF_Page_MoveTextPos
2. HPDF_Page_MoveTextPos2
3. HPDF_Page_SetTextMatrix

## List of Text Showing Operators

1. HPDF_Page_ShowText
2. HPDF_Page_ShowTextNextLine
3. HPDF_Page_ShowTextNextLineEx
4. HPDF_Page_TextOut
5. HPDF_Page_TextRect

# Colors

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 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Note:
The above table contains what is known as the "web safe" color palette, it is also known by the following names: browser-safe palette, Netscape palette, 216 color palette, Web palette or 6x6x6 color cube. Its purpose was to provide a consistent palette of colors for a wide variety of browsers and operating systems which at the time usually had 256 colors (8-bit).

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.

Retrieved from "http://daylessday../../../../articles/d/o/c/Documentation_Graphics_d60b.html"

##### Views

- Page
- Discussion
- View source
- History

##### Personal tools

- Log in

##### Search

##### Toolbox

- What links here
- Related changes
- Special pages
- Printable version
- Permanent link