Class: Wx::SVGFileDC
- Inherits:
-
DC
- Object
- Object
- ReadOnlyDC
- DC
- Wx::SVGFileDC
- Defined in:
- lib/wx/doc/gen/svg_file_dc.rb,
lib/wx/doc/svg_file_dc.rb
Overview
This class is untracked and should not be derived from nor instances extended!
A SVGFileDC is a device context onto which graphics and text can be drawn, and the output produced as a vector file, in SVG format.
This format can be read by a range of programs, including most web browsers and the open source Inkscape program (https://inkscape.org/). Full details are given in the W3C SVG recommendation (https://www.w3.org/TR/SVG/). The intention behind SVGFileDC is that it can be used to produce a file corresponding to the screen display context, SVGFileDC, by passing the SVGFileDC as a parameter instead of a DC. Thus the SVGFileDC is a write-only class. Starting with wxWidgets 3.3.3, SVGFileDC provides integrated support for GraphicsContext. By calling #get_graphics_context, you can access a SVGGraphicsContext which supports advanced vector features such as:
- Cubic and quadratic Bézier curves via GraphicsPath.
- Linear and radial gradient brushes.
- Semi-transparent colors and alpha blending.
- Arbitrary affine transformations.
As the SVGFileDC is a vector format, raster operations like DC#get_pixel are unlikely to be supported. However, the SVG specification allows for raster files to be embedded in the SVG, and so bitmaps, icons and blit operations in SVGFileDC are supported. By default only PNG format bitmaps are supported and these are saved as separate files in the same folder as the SVG file, however it is possible to change this behaviour by replacing the built in bitmap handler using #set_bitmap_handler. More substantial SVG libraries (for reading and writing) are available at Art2D and SVG.
Category: Device Contexts
Class Method Summary collapse
-
.draw_on(filename, width = 320, height = 240, dpi = 72, title = '') {|dc| ... } ⇒ ::Object
Executes the given block providing a temporary dc as it's single argument.
Instance Method Summary collapse
-
#begin_accessible_group(attributes, title = (''), desc = ('')) ⇒ void
Opens an accessible group wrapping all subsequent drawing until the matching #end_accessible_group call.
-
#begin_layer(opacity) ⇒ void
Opens a new layer with the given opacity.
-
#clear ⇒ void
Draws a rectangle the size of the SVG using the DC#set_background brush.
-
#end_accessible_group ⇒ void
Closes the accessible group opened by the most recent #begin_accessible_group call.
-
#end_layer ⇒ void
Closes the layer opened by the most recent #begin_layer call.
-
#get_graphics_context ⇒ Wx::GraphicsContext
(also: #graphics_context)
Returns the graphics context associated with this DC.
-
#get_svg_document ⇒ String
(also: #svg_document)
Returns the SVG document as a string.
-
#save ⇒ Boolean
Saves the SVG document to the file specified in the constructor.
-
#set_bitmap_handler(handler) ⇒ void
(also: #bitmap_handler=)
Replaces the default bitmap handler with handler.
-
#set_shape_rendering_mode(renderingMode) ⇒ void
(also: #shape_rendering_mode=)
Set the shape rendering mode of the generated SVG.
Methods inherited from DC
#are_automatic_bounding_box_updates_enabled, #blit, #calc_bounding_box, #copy_attributes, #cross_hair, #destroy_clipping_region, #disable_automatic_bounding_box_updates, #draw_arc, #draw_bitmap, #draw_check_mark, #draw_circle, #draw_ellipse, #draw_elliptic_arc, #draw_icon, #draw_label, #draw_line, #draw_lines, #draw_point, #draw_poly_polygon, #draw_polygon, #draw_rectangle, #draw_rotated_text, #draw_rounded_rectangle, #draw_spline, #draw_text, #end_doc, #end_page, #flood_fill, #get_as_bitmap, #get_background, #get_background_mode, #get_brush, #get_clipping_box, #get_logical_function, #get_pen, #get_pixel, #get_text_background, #get_text_foreground, #gradient_fill_concentric, #gradient_fill_linear, #max_x, #max_y, #min_x, #min_y, #reset_bounding_box, #set_background, #set_background_mode, #set_brush, #set_clipping_region, #set_device_clipping_region, #set_graphics_context, #set_logical_function, #set_palette, #set_pen, #set_text_background, #set_text_foreground, #start_doc, #start_page, #stretch_blit, #with_background_mode, #with_brush, #with_font, #with_pen, #with_text_background, #with_text_foreground
Methods inherited from ReadOnlyDC
#can_draw_bitmap, #can_get_text_extent, #can_use_transform_matrix, #device_to_logical, #device_to_logical_rel, #device_to_logical_x, #device_to_logical_x_rel, #device_to_logical_y, #device_to_logical_y_rel, #from_dip, #get_char_height, #get_char_width, #get_content_scale_factor, #get_depth, #get_device_origin, #get_dimensions, #get_dimensions_mm, #get_font, #get_font_metrics, #get_layout_direction, #get_logical_origin, #get_logical_scale, #get_map_mode, #get_multi_line_text_extent, #get_multi_line_text_size, #get_ppi, #get_size, #get_size_mm, #get_text_extent, #get_text_size, #get_transform_matrix, #get_user_scale, #is_ok, #logical_to_device, #logical_to_device_rel, #logical_to_device_x, #logical_to_device_x_rel, #logical_to_device_y, #logical_to_device_y_rel, #reset_transform_matrix, #set_axis_orientation, #set_device_origin, #set_font, #set_layout_direction, #set_logical_origin, #set_logical_scale, #set_map_mode, #set_transform_matrix, #set_user_scale, #to_dip
Methods inherited from Object
#clone, #dup, #initialize, #is_same_as, #un_share
Constructor Details
This class inherits a constructor from Wx::Object
Class Method Details
.draw_on(filename, width = 320, height = 240, dpi = 72, title = '') {|dc| ... } ⇒ ::Object
Executes the given block providing a temporary dc as it's single argument. Initializes a wxSVGFileDC with the given filename, width and height at dpi resolution, and an optional title. The title provides a readable name for the SVG document.
22 |
# File 'lib/wx/doc/svg_file_dc.rb', line 22 def self.draw_on(filename, width=320, height=240, dpi=72, title='') end |
Instance Method Details
#begin_accessible_group(attributes, title = (''), desc = ('')) ⇒ void
This method returns an undefined value.
Opens an accessible group wrapping all subsequent drawing until the matching #end_accessible_group call.
The group is emitted as an SVG element carrying the given attributes, optionally followed by and children supplying an accessible name and long description.
Prefer Wx::SVGAccessibleGroup for RAII-style scoping, which guarantees #end_accessible_group is called on scope exit.
97 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 97 def begin_accessible_group(attributes, title=(''), desc=('')) end |
#begin_layer(opacity) ⇒ void
This method returns an undefined value.
Opens a new layer with the given opacity.
All drawing commands until the matching #end_layer call will be composited with this opacity. Layers can be nested.
108 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 108 def begin_layer(opacity) end |
#clear ⇒ void
This method returns an undefined value.
Draws a rectangle the size of the SVG using the DC#set_background brush.
65 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 65 def clear; end |
#end_accessible_group ⇒ void
This method returns an undefined value.
Closes the accessible group opened by the most recent #begin_accessible_group call.
101 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 101 def end_accessible_group; end |
#end_layer ⇒ void
This method returns an undefined value.
Closes the layer opened by the most recent #begin_layer call.
112 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 112 def end_layer; end |
#get_graphics_context ⇒ Wx::GraphicsContext Also known as: graphics_context
Returns the graphics context associated with this DC.
The returned object is a Wx::SVGGraphicsContext instance. While Wx::SVGFileDC provides standard DC drawing methods, retrieving the GraphicsContext allows using more advanced drawing features that are not available in the base DC API, such as:
- Complex paths including cubic and quadratic Bézier curves.
- Linear and radial gradient brushes.
- Transparency and alpha blending for all drawing operations.
- Advanced coordinate transformations (scaling, rotation, skewing) applied to groups of objects.
Note that any state changes (pen, brush, font) made to the returned context are mirrored back to the DC, and vice versa.
139 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 139 def get_graphics_context; end |
#get_svg_document ⇒ String Also known as: svg_document
Returns the SVG document as a string.
This can be used to retrieve the generated SVG content regardless of whether it was also written to a file. This can be called after all drawing commands to get the current SVG content.
118 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 118 def get_svg_document; end |
#save ⇒ Boolean
Saves the SVG document to the file specified in the constructor.
This is called automatically by the destructor if a filename was provided, but calling it explicitly allows checking for errors. Does nothing if no filename was provided or if the file has already been saved. true if the file was written successfully, false otherwise.
126 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 126 def save; end |
#set_bitmap_handler(handler) ⇒ void Also known as: bitmap_handler=
This method returns an undefined value.
Replaces the default bitmap handler with handler.
By default, an object of Wx::SVGBitmapFileHandler class is used as bitmap handler. You may want to replace it with an object of predefined Wx::SVGBitmapEmbedHandler class to embed the bitmaps in the generated SVG instead of storing them in separate files like this:
mySVGFileDC.set_bitmap_handler(Wx::SVGBitmapEmbedHandler.new)
or derive your own bitmap handler class and use it if you need to customize the bitmap handling further.
77 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 77 def set_bitmap_handler(handler) end |
#set_shape_rendering_mode(renderingMode) ⇒ void Also known as: shape_rendering_mode=
This method returns an undefined value.
Set the shape rendering mode of the generated SVG.
All subsequent drawing calls will have this rendering mode set in the SVG file. The default mode is Wx::SVGShapeRenderingMode::SVG_SHAPE_RENDERING_AUTO.
86 |
# File 'lib/wx/doc/gen/svg_file_dc.rb', line 86 def set_shape_rendering_mode(renderingMode) end |