pdf:colors
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
pdf:colors [2015/03/28 17:14] – dokuadmin | pdf:colors [2016/05/12 12:37] (current) – [Special colorspaces] christian | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Colours in PDF ====== | ||
+ | |||
PDF distinguishes between filling (paint the interior of a closed path) and stroking (paint the outline of a path) when painting. Each mode has its own color and is used with the appropriate paint operators. | PDF distinguishes between filling (paint the interior of a closed path) and stroking (paint the outline of a path) when painting. Each mode has its own color and is used with the appropriate paint operators. | ||
Line 4: | Line 6: | ||
In order to set a color, first the colorspace and then the actual color has to be set with the right parameters for that colorspace. For example setting the stroking color to red in RGB: | In order to set a color, first the colorspace and then the actual color has to be set with the right parameters for that colorspace. For example setting the stroking color to red in RGB: | ||
- | /DeviceRGB CS % set colorspace for stroking | + | |
- | 1 0 0 SC % set stroking color | + | 1 0 0 SC % set stroking color |
For the device colorspaces, | For the device colorspaces, | ||
- | 1 0 0 RG % set RGB colorspace and color for stroking | + | |
There are 11 distinct colorspaces available in PDF: | There are 11 distinct colorspaces available in PDF: | ||
- | === Device colorspaces === | + | ===== Device colorspaces |
Device dependent, Not reproducable. | Device dependent, Not reproducable. | ||
* **DeviceGray** 1 components [0..1]; `0` is black, `1` is white. | * **DeviceGray** 1 components [0..1]; `0` is black, `1` is white. | ||
- | |||
* **DeviceRGB** additive (for screens); 3 components [0..1]; `0 0 0` is black, `1 1 1` is white. | * **DeviceRGB** additive (for screens); 3 components [0..1]; `0 0 0` is black, `1 1 1` is white. | ||
- | |||
* **DeviceCMYK** subtractive (for printing); 4 components [0..1]; `0 0 0 1` is black, `0 0 0 0` is white. | * **DeviceCMYK** subtractive (for printing); 4 components [0..1]; `0 0 0 1` is black, `0 0 0 0` is white. | ||
- | === CIE-based colorspaces === | + | ===== CIE-based colorspaces |
Calibrated: device independent, | Calibrated: device independent, | ||
* **CalGray** | * **CalGray** | ||
- | |||
* **CalRGB** | * **CalRGB** | ||
- | |||
* **Lab** | * **Lab** | ||
- | |||
* **ICCBased** | * **ICCBased** | ||
- | === Special colorspaces === | + | ===== Special colorspaces ===== |
* **Indexed** | * **Indexed** | ||
- | |||
* **Pattern** | * **Pattern** | ||
- | |||
* **Separation** | * **Separation** | ||
- | |||
* **DeviceN** | * **DeviceN** | ||
Most commonly used and easiest are the device colorspaces. Setting black is done like this in the different colorspaces: | Most commonly used and easiest are the device colorspaces. Setting black is done like this in the different colorspaces: | ||
- | % DeviceGray | + | |
- | 0 G % stroking | + | 0 G % stroking |
- | 0 g % filling | + | 0 g % filling |
- | % DeviceRGB | + | % DeviceRGB |
- | 0 0 0 RG % stroking | + | 0 0 0 RG % stroking |
- | 0 0 0 rg % filling | + | 0 0 0 rg % filling |
- | % DeviceCMYK | + | % DeviceCMYK |
- | 0 0 0 1 K % stroking | + | 0 0 0 1 K % stroking |
- | 0 0 0 1 k % filling | + | 0 0 0 1 k % filling |
+ | |||
+ | The renderer supports the device color spaces. If you need other color spaces, you need to work directly with the color operators. | ||
- | The PDF4Smalltalk library supports these variations by initializing the renderer | + | <code smalltalk> |
+ | renderer | ||
+ | renderer | ||
+ | </ | ||
- | " | + | The renderer |
- | renderer | + | |
- | renderer fillColor: < | + | |
- | " | + | |
- | renderer strokeColor: | + | |
- | renderer fillColor: < | + | |
- | " | + | |
- | renderer strokeColor: | + | |
- | renderer fillColor: < | + | |
Example: | Example: | ||
- | page := Page newInBounds: | + | <code smalltalk> |
- | renderer fillColor: ColorValue red. | + | page := Page newInBounds: |
- | renderer addRectangleLeft: | + | renderer fillColor: ColorValue red. |
- | renderer fill. | + | renderer addRectangleLeft: |
- | renderer strokeColor: | + | renderer fill. |
- | renderer linewidth: 5. | + | renderer strokeColor: |
- | renderer addRectangleLeft: | + | renderer linewidth: 5. |
- | renderer stroke]. | + | renderer addRectangleLeft: |
+ | renderer stroke]. | ||
+ | </ |
/var/www/virtual/code4hl/html/dokuwiki/data/pages/pdf/colors.txt · Last modified: 2016/05/12 12:37 by christian