Working diary -- graphics state in PS

Source: Internet
Author: User
Working diary -- graphics state in PS
Working diary -- graphics state in PS

Graph state in PS)
The PS interpreter maintains an internal data structure, which is called "Graph state" and stores the current graph control parameters. These parameters define the execution of graphical operators in the global framework. For example, the stroke operator implicitly uses the parameter of the current line width in the "graphic State", and the fill operator implicitly uses the current color. The vast majority of "graphics state" parameters are common PS objects and can be read and modified by appropriate "graphics state" operators. For example, the setlinewidth operator changes the current linewidth parameter, and currentlinewidth reads the linewidth parameter from the "Graph state. Generally, the parameter setting operator sets the value to the "graphic state" parameter without changing it for subsequent operators. However, there are exceptions:
1. Most parameters must have the correct data type or their values must be within a specific range;
2. numeric parameters, such as color, line width, And miter limit, must be in a valid range. If necessary, they are stored as real data. If they are read later, they are still real numbers, no matter what they are. Of course, they will not be adjusted to reflect the capacity of the grating output device, such as the resolution, or the number of recognizable colors. The graphic rendering operator will make such adjustments, however, the adjusted value is not saved back to the "Graph status ";
3. Some parameters are composite objects, such as dictionaries and arrays. Graphical operators can reference these values at any time or cache them for later use. Therefore, changing them will cause unpredictable results. A ps program uses this value (including the saved "Graph status") as a read-only value.
The current path, cropping path, and device parameters are internal objects and cannot be directly accessed by PS programs.
Table 1 lists device-independent parameters. Table 2 lists parameters that control the rendering process details. They are device-related. If a page description is defined as device-independent, you cannot change these parameters.
Table 1 "graphic status" device-independent parameters
Parameter type value
CTM array current transformation matrix, which maps user coordinates into device coordinates, which can be modified by coordinate system operators. Initial Value: a matrix that converts the Default User coordinates into device coordinates.

Position two-numbers coordinates of the current point of the user space, the last element of the current path. Initial Value: Not Defined.

PATH (internal) path build operator to create the current path. It is generally used as an implicit parameter of similar operators such as fill, stroke, and clip. Initial Value: null.

Clipping Path (internal) defines all output cropped areas. Initial Value: all areas on the current page that can be painted.

Clipping Path stack (internal) (applicable to PS level3) is a stack used to store all the cropping paths saved using the clipsave operator but not restored using cliprestore.

Color-space array (applicable to PS level 2) is used to explain the color value. Initial Value: devicegray.

Color (various) is the color value used for plotting. The type and interpretation of this parameter depend on the current color space. For most color spaces, the color value consists of 1-4 digits. Initial Value: black.

Font Dictionary describes a collection of font characters in the current font. Initial Value: An invalid font dictionary.

Line-Width Number is the line width defined by the user coordinate unit. Initial Value: 1.0.

Line-cap integer indicates the shape code of the vertex end when any open path is stroke. The initial value is 0, which indicates the right corner head (Square Butt ).

Line-join integer the link between the connected line segments when a shape is stroke. The initial value is 0, indicating the mitered joins ).

Miter-Limit number the maximum length of mitered line joins for the stroke operator. this limits the length of "Spikes" produced when line segments join at sharp angles. initial Values: 10.0 for a miter cutoff below 11 degrees.

The dotted line description parameter used when the dash-pattern array and number stroke operators depict the line. Initial Value: solid line.

Stroke-adjustment Boolean (applicable to PS level 2) whether compensation is required when the width is small. Initial Value: false.

Table 2 "graphic status" device-related parameters
Parameter type value
Color-rendering Dictionary (applicable to PS level 2) is a set of parameters used to determine how to convert CIE-based color encoding to device color values. Initial Value: Installation-dependent.

Overprint Boolean (applicable to PS level 2) whether to retain existing colors when plotting. Erased (false), not changed (true), initial value: false.

Black-generation procedure (applicable to PS level 2) is a process used to calculate the total amount of black when converting from RGB to CMYK. Initial Value: Installation-dependent.

Undercolor-removal procedure (applicable to PS level 2) is a process used to calculate the total amount reduced when the blue, magenta, and yellow channels compensate for the black. Initial Value: Installation-dependent.

Transfer Procedure adjusts the gray or color channel value of the device on a specific device to correct a conversion function of the nonlinear response. In PS level 2, four conversion functions are supported. Initial Value: Installation-dependent.

Halftone (various) a halftone screen for gray and color rendering, specified either as frequency, angle, and spot function or as a halftone dictionary. halftone dictionaries, as well as support for four halftone screens, are using agelevel 2 features. initial Value: Installation-dependent.

The accuracy of the flatness number curve depicted on the output device. This number gives the maximum allowable error (unit: Device pixel ). Smaller numbers give smoother curves at the expense of more computation and memory use. The initial value is 1.0.

Smoothness number (applicable to PS level 3) specifies the color difference when rendering on the output device. This number provides the maximum error between the shading described using piecewise linear interpolation and the shading real color value described by the function. Smaller numbers give smoother color transitions at the expense of more computation and memory use. Initial Value: Installation-dependent.

Device (internal) describes the internal data structure of the current output device. Initial Value: Installation-dependent.

Although the graphic State contains many objects, it is not a PS object and cannot be directly accessed by PS programs. However, there are two mechanisms for saving and restoring the entire graph State later. One is the graph state stack, which is managed using the following two operators:
Gsave pushes a copy of the entire graph state to the stack.
Grestore uses pop from the stack to restore the entire graph state.
The graphical status stack is in the FIFO order, serving the needs of the PS program described on the page. A typical well-structured document should contain many graphic elements that do not interfere with each other and sometimes contain multi-layer nesting. The gsave and grestore operators can encapsulate these elements, so that they only affect their own graphics, without interfering with other graphics states.
In some interactive applications, however, a program must switch its attention among multiple, more-or-less independent imaging contexts in an unpredictable order. the second mechanism is applicable only to PS level 2 and 3. It is implemented by using a gstate object containing the saved graph state in the virtual memory.
? Create a new gstate object.
? Currentgstate copies the state of the current image to a gstate object.
? Setgstate replaces the current graph state with a gstate object.
The interactive program uses these operators to create a separate gstate object for each graphic content, and dynamically switches as needed.
Note: To save a graphical state, whether gsave or currentgstate is used, all parameters, including the current path and current cropping path, are saved. For example, if the current path is not empty when gsave, gstate, or currentgstate is executed, the path will be restored when the corresponding grestore or setgstate is executed. Unless you want this effect, it is best to save the image status when the current path is empty and the current crop path is the default value to minimize the space requirement.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.