ip_image_polarity
ip_image_polarity ¶
Wrapper for image polarity token.
ImagePolarityEnum ¶
Bases: GerberCodeEnum
Image polarity.
Image Polarity (IP)¶
Note: The IP command is deprecated.
The IP
command is responsible for setting the polarity for the entire image. It is
designed to be used only once, preferably at the very beginning of the file.
7.1.3.1 Positive Image Polarity¶
Under the positive image polarity: - The image is generated in accordance with the specifications provided elsewhere in this document. - It's worth noting that, by default, image generation has always assumed a positive image polarity.
7.1.3.2 Negative Image Polarity¶
When the negative image polarity is in use: - The intent is to produce an image that portrays clear areas against a dark backdrop. - The initial state of the entire image plane is dark, as opposed to being clear. - The polarity effects between dark and clear regions are interchanged. Essentially, what was dark becomes white and vice-versa. - For negative image polarity, the very first graphics object that gets produced must possess a dark polarity. As a result, it takes on the role of clearing the dark backdrop.
Source code in src/pygerber/gerberx3/state_enums.py
ExtendedCommandToken ¶
Bases: Token
3.3 Commands.¶
Commands are the core syntactic element of the Gerber format. A Gerber file is a stream of commands. Commands define the graphics state, create graphical objects, defines apertures, manage attributes and so on.
Commands are built with words, the basic syntactic building block of a Gerber file. A word is a non-empty character string, excluding the reserved characters '' and '%', terminated with an ''
For historic reasons, there are two command syntax styles: word commands and extended commands.
command =
| extended_command
| word_command
;
word_command = word;
extended_command = '%' {word}+ '%';
Word commands are identified by a command code, the letter G, D or M followed by a positive
integer, e.g. G02
. Most word commands only consist of the command code, some also contain
coordinates.
Extended commands are identified by a two-character command code that is followed by parameters specific to the code. An extended command is enclosed by a pair of "%" delimiters
An overview of all commands is in section 2.8, a full description in chapters 3.5 and 5.
Example 1¶
The example below shows a stream of Gerber commands.
G04 Different command styles*
G75*
G02*
D10*
X0Y0D02*
X2000000Y0I1000000J0D01*
D11*
X0Y2000000D03*
M02*
Example 2¶
The example below shows a stream of Gerber extended commands.
%FSLAX26Y26*%
%MOMM*%
%AMDonut*
1,1,$1,$2,$3*
$4=$1x0.75*
1,0,$4,$2,$3*
%
%ADD11Donut,0.30X0X0*%
%ADD10C,0.1*%
See section 3.3 of The Gerber Layer Format Specification
Source code in src/pygerber/gerberx3/tokenizer/tokens/bases/extended_command.py
get_gerber_code_one_line_pretty_display ¶
Backend ¶
Bases: ABC
Drawing backend interface.
Source code in src/pygerber/backend/abstract/backend_cls.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
__init__ ¶
create_aperture_handle ¶
Create new aperture handle.
Source code in src/pygerber/backend/abstract/backend_cls.py
get_private_aperture_handle ¶
get_private_aperture_handle(
public_aperture_handle: PublicApertureHandle,
) -> PrivateApertureHandle
Get private aperture handle.
draw ¶
Execute all draw actions to create visualization.
Source code in src/pygerber/backend/abstract/backend_cls.py
finalize_aperture_creation ¶
get_result_handle
abstractmethod
¶
get_aperture_handle_cls
abstractmethod
¶
get_draw_circle_cls
abstractmethod
¶
get_draw_rectangle_cls
abstractmethod
¶
get_draw_polygon_cls
abstractmethod
¶
get_draw_commands_handle_cls
abstractmethod
¶
get_draw_paste_cls
abstractmethod
¶
get_draw_region_cls
abstractmethod
¶
get_draw_vector_line_cls
abstractmethod
¶
get_draw_arc_cls
abstractmethod
¶
DrawCommand ¶
Bases: ABC
Description of aperture component.
Source code in src/pygerber/backend/abstract/draw_commands/draw_command.py
State ¶
Bases: FrozenGeneralModel
GerberX3 interpreter state.
Source code in src/pygerber/gerberx3/parser/state.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
region_boundary_points
class-attribute
instance-attribute
¶
Points defining the shape of the region.
is_output_image_negation_required
class-attribute
instance-attribute
¶
In Gerber specification deprecated IP command is mentioned. It can set image polarity to either positive, the usual one, or to negative. Under negative image polarity, image generation is different. Its purpose is to create a negative image, clear areas in a dark background. The entire image plane in the background is initially dark instead of clear. The effect of dark and clear polarity is toggled. The entire image is simply reversed, dark becomes white and vice versa. This effect can be achieved by simply inverting colors of output image.
apertures
class-attribute
instance-attribute
¶
Collection of all apertures defined until given point in code.
macros
class-attribute
instance-attribute
¶
Collection of all macros defined until given point in code.
get_units ¶
get_coordinate_parser ¶
Get coordinate parser or raise CoordinateFormatNotSetError.
get_current_aperture ¶
Get current aperture or raise ApertureNotSelectedError.
parse_coordinate ¶
Parse, include substitution with current and conversion to Offset.
Source code in src/pygerber/gerberx3/parser/state.py
ImagePolarity ¶
Bases: ExtendedCommandToken
Wrapper for image polarity token.
The IP command is deprecated.
IP sets positive or negative polarity for the entire image. It can only be used once, at the beginning of the file.
See section 8.1.4 of The Gerber Layer Format Specification Revision 2023.03 - https://argmaster.github.io/pygerber/latest/gerber_specification/revision_2023_03.html
Source code in src/pygerber/gerberx3/tokenizer/tokens/ip_image_polarity.py
new
classmethod
¶
Create instance of this class.
Created to be used as callback in ParserElement.set_parse_action()
.
Source code in src/pygerber/gerberx3/tokenizer/tokens/ip_image_polarity.py
update_drawing_state ¶
Set drawing polarity.
Source code in src/pygerber/gerberx3/tokenizer/tokens/ip_image_polarity.py
get_gerber_code ¶
Get gerber code represented by this token.
warn_deprecated_code ¶
Display warning about deprecated code.