Class: Gtk::Snapshot
- Inherits:
-
Gdk::Snapshot
- Object
- Gdk::Snapshot
- Gtk::Snapshot
- Defined in:
- lib/gtk4/snapshot.rb
Instance Method Summary collapse
-
#append_border(outline, border_width, border_color) ⇒ nil
Appends a stroked border rectangle inside the given outline.
-
#append_cairo(bounds) ⇒ cairo::Context
Creates a new [classGsk.CairoNode] and appends it to the current render node of snapshot, without changing the current node.
-
#append_color(color, bounds) ⇒ nil
Creates a new render node drawing the color into the given bounds and appends it to the current render node of snapshot.
-
#append_conic_gradient(bounds, center, rotation, stops, n_stops) ⇒ nil
Appends a conic gradient node with the given stops to snapshot.
-
#append_fill(path, fill_rule, color) ⇒ nil
A convenience method to fill a path with a color.
-
#append_inset_shadow(outline, color, dx, dy, spread, blur_radius) ⇒ nil
Appends an inset shadow into the box given by outline.
- #append_layout(layout, color) ⇒ nil
-
#append_linear_gradient(bounds, start_point, end_point, stops, n_stops) ⇒ nil
Appends a linear gradient node with the given stops to snapshot.
-
#append_node(node) ⇒ nil
Appends node to the current render node of snapshot, without changing the current node.
-
#append_outset_shadow(outline, color, dx, dy, spread, blur_radius) ⇒ nil
Appends an outset shadow node around the box given by outline.
-
#append_radial_gradient(bounds, center, hradius, vradius, start, end, stops, n_stops) ⇒ nil
Appends a radial gradient node with the given stops to snapshot.
-
#append_repeating_linear_gradient(bounds, start_point, end_point, stops, n_stops) ⇒ nil
Appends a repeating linear gradient node with the given stops to snapshot.
-
#append_repeating_radial_gradient(bounds, center, hradius, vradius, start, end, stops, n_stops) ⇒ nil
Appends a repeating radial gradient node with the given stops to snapshot.
-
#append_scaled_texture(texture, filter, bounds) ⇒ nil
Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot.
-
#append_stroke(path, stroke, color) ⇒ nil
A convenience method to stroke a path with a color.
-
#append_texture(texture, bounds) ⇒ nil
Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot.
-
#free_to_node ⇒ Gsk::RenderNode
Returns the node that was constructed by snapshot and frees snapshot.
-
#free_to_paintable(size) ⇒ Gdk::Paintable
Returns a paintable for the node that was constructed by snapshot and frees snapshot.
-
#gl_shader_pop_texture ⇒ nil
Removes the top element from the stack of render nodes and adds it to the nearest [classGsk.GLShaderNode] below it.
-
#initialize ⇒ Gtk::Snapshot
constructor
Creates a new
GtkSnapshot. -
#perspective(depth) ⇒ nil
Applies a perspective projection transform.
-
#pop ⇒ nil
Removes the top element from the stack of render nodes, and appends it to the node underneath it.
-
#push_blend(blend_mode) ⇒ nil
Blends together two images with the given blend mode.
-
#push_blur(radius) ⇒ nil
Blurs an image.
-
#push_clip(bounds) ⇒ nil
Clips an image to a rectangle.
-
#push_color_matrix(color_matrix, color_offset) ⇒ nil
Modifies the colors of an image by applying an affine transformation in RGB space.
-
#push_cross_fade(progress) ⇒ nil
Snapshots a cross-fade operation between two images with the given progress.
-
#push_debug(message, array) ⇒ nil
Inserts a debug node with a message.
-
#push_fill(path, fill_rule) ⇒ nil
Fills the area given by path and fill_rule with an image and discards everything outside of it.
-
#push_gl_shader(shader, bounds, take_args) ⇒ nil
Push a [classGsk.GLShaderNode].
-
#push_mask(mask_mode) ⇒ nil
Until the first call to [methodGtk.Snapshot.pop], the mask image for the mask operation will be recorded.
-
#push_opacity(opacity) ⇒ nil
Modifies the opacity of an image.
-
#push_repeat(bounds, child_bounds) ⇒ nil
Creates a node that repeats the child node.
-
#push_rounded_clip(bounds) ⇒ nil
Clips an image to a rounded rectangle.
-
#push_shadow(shadow, n_shadows) ⇒ nil
Applies a shadow to an image.
-
#push_stroke(path, stroke) ⇒ nil
Strokes the given path with the attributes given by stroke and an image.
-
#render_background(context, x, y, width, height) ⇒ nil
Creates a render node for the CSS background according to context, and appends it to the current node of snapshot, without changing the current node.
-
#render_focus(context, x, y, width, height) ⇒ nil
Creates a render node for the focus outline according to context, and appends it to the current node of snapshot, without changing the current node.
-
#render_frame(context, x, y, width, height) ⇒ nil
Creates a render node for the CSS border according to context, and appends it to the current node of snapshot, without changing the current node.
-
#render_insertion_cursor(context, x, y, layout, index, direction) ⇒ nil
Draws a text caret using snapshot at the specified index of layout.
-
#render_layout(context, x, y, layout) ⇒ nil
Creates a render node for rendering layout according to the style information in context, and appends it to the current node of snapshot, without changing the current node.
-
#restore ⇒ nil
Restores snapshot to the state saved by a preceding call to [methodSnapshot.save] and removes that state from the stack of saved states.
-
#rotate(angle) ⇒ nil
Rotates @snapshot's coordinate system by angle degrees in 2D space - or in 3D speak, rotates around the Z axis.
-
#rotate_3d(angle, axis) ⇒ nil
Rotates snapshot's coordinate system by angle degrees around axis.
-
#save ⇒ nil
Makes a copy of the current state of snapshot and saves it on an internal stack.
-
#save_raw ⇒ nil
Makes a copy of the current state of snapshot and saves it on an internal stack.
-
#scale(factor_x, factor_y) ⇒ nil
Scales snapshot's coordinate system in 2-dimensional space by the given factors.
-
#scale_3d(factor_x, factor_y, factor_z) ⇒ nil
Scales snapshot's coordinate system by the given factors.
-
#to_node ⇒ Gsk::RenderNode
Returns the render node that was constructed by snapshot.
-
#to_paintable(size) ⇒ Gdk::Paintable
Returns a paintable encapsulating the render node that was constructed by snapshot.
-
#transform(transform) ⇒ nil
Transforms snapshot's coordinate system with the given transform.
-
#transform_matrix(matrix) ⇒ nil
Transforms snapshot's coordinate system with the given matrix.
-
#translate(point) ⇒ nil
Translates snapshot's coordinate system by point in 2-dimensional space.
-
#translate_3d(point) ⇒ nil
Translates snapshot's coordinate system by point.
Constructor Details
#initialize ⇒ Gtk::Snapshot
Creates a new GtkSnapshot.
Instance Method Details
#append_border(outline, border_width, border_color) ⇒ nil
Appends a stroked border rectangle inside the given outline.
The four sides of the border can have different widths and colors.
#append_cairo(bounds) ⇒ cairo::Context
Creates a new [classGsk.CairoNode] and appends it to the current render node of snapshot, without changing the current node.
#append_color(color, bounds) ⇒ nil
Creates a new render node drawing the color into the given bounds and appends it to the current render node of snapshot.
You should try to avoid calling this function if color is transparent.
#append_conic_gradient(bounds, center, rotation, stops, n_stops) ⇒ nil
Appends a conic gradient node with the given stops to snapshot.
#append_fill(path, fill_rule, color) ⇒ nil
A convenience method to fill a path with a color.
See [methodGtk.Snapshot.push_fill] if you need to fill a path with more complex content than a color.
#append_inset_shadow(outline, color, dx, dy, spread, blur_radius) ⇒ nil
Appends an inset shadow into the box given by outline.
#append_layout(layout, color) ⇒ nil
#append_linear_gradient(bounds, start_point, end_point, stops, n_stops) ⇒ nil
Appends a linear gradient node with the given stops to snapshot.
#append_node(node) ⇒ nil
Appends node to the current render node of snapshot, without changing the current node.
If snapshot does not have a current node yet, node will become the initial node.
#append_outset_shadow(outline, color, dx, dy, spread, blur_radius) ⇒ nil
Appends an outset shadow node around the box given by outline.
#append_radial_gradient(bounds, center, hradius, vradius, start, end, stops, n_stops) ⇒ nil
Appends a radial gradient node with the given stops to snapshot.
#append_repeating_linear_gradient(bounds, start_point, end_point, stops, n_stops) ⇒ nil
Appends a repeating linear gradient node with the given stops to snapshot.
#append_repeating_radial_gradient(bounds, center, hradius, vradius, start, end, stops, n_stops) ⇒ nil
Appends a repeating radial gradient node with the given stops to snapshot.
#append_scaled_texture(texture, filter, bounds) ⇒ nil
Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot.
In contrast to [methodGtk.Snapshot.append_texture], this function provides control about how the filter that is used when scaling.
#append_stroke(path, stroke, color) ⇒ nil
A convenience method to stroke a path with a color.
See [methodGtk.Snapshot.push_stroke] if you need to stroke a path with more complex content than a color.
#append_texture(texture, bounds) ⇒ nil
Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot.
If the texture needs to be scaled to fill bounds, linear filtering is used. See [methodGtk.Snapshot.append_scaled_texture] if you need other filtering, such as nearest-neighbour.
#free_to_node ⇒ Gsk::RenderNode
Returns the node that was constructed by snapshot and frees snapshot.
See also [methodGtk.Snapshot.to_node].
#free_to_paintable(size) ⇒ Gdk::Paintable
Returns a paintable for the node that was constructed by snapshot and frees snapshot.
#gl_shader_pop_texture ⇒ nil
Removes the top element from the stack of render nodes and adds it to the nearest [classGsk.GLShaderNode] below it.
This must be called the same number of times as the number of textures is needed for the shader in [methodGtk.Snapshot.push_gl_shader].
#perspective(depth) ⇒ nil
Applies a perspective projection transform.
See [methodGsk.Transform.perspective] for a discussion on the details.
#pop ⇒ nil
Removes the top element from the stack of render nodes, and appends it to the node underneath it.
#push_blend(blend_mode) ⇒ nil
Blends together two images with the given blend mode.
Until the first call to [methodGtk.Snapshot.pop], the bottom image for the blend operation will be recorded. After that call, the top image to be blended will be recorded until the second call to [methodGtk.Snapshot.pop].
Calling this function requires two subsequent calls to [methodGtk.Snapshot.pop].
#push_blur(radius) ⇒ nil
Blurs an image.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
#push_clip(bounds) ⇒ nil
Clips an image to a rectangle.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
#push_color_matrix(color_matrix, color_offset) ⇒ nil
Modifies the colors of an image by applying an affine transformation in RGB space.
In particular, the colors will be transformed by applying
pixel = transpose(color_matrix) * pixel + color_offset
for every pixel. The transformation operates on unpremultiplied colors, with color components ordered R, G, B, A.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
#push_cross_fade(progress) ⇒ nil
Snapshots a cross-fade operation between two images with the given progress.
Until the first call to [methodGtk.Snapshot.pop], the start image will be snapshot. After that call, the end image will be recorded until the second call to [methodGtk.Snapshot.pop].
Calling this function requires two subsequent calls to [methodGtk.Snapshot.pop].
#push_debug(message, array) ⇒ nil
Inserts a debug node with a message.
Debug nodes don't affect the rendering at all, but can be helpful in identifying parts of a render node tree dump, for example in the GTK inspector.
#push_fill(path, fill_rule) ⇒ nil
Fills the area given by path and fill_rule with an image and discards everything outside of it.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
If you want to fill the path with a color, [methodGtk.Snapshot.append_fill] may be more convenient.
#push_gl_shader(shader, bounds, take_args) ⇒ nil
Push a [classGsk.GLShaderNode].
The node uses the given [classGsk.GLShader] and uniform values Additionally this takes a list of n_children other nodes which will be passed to the [classGsk.GLShaderNode].
The take_args argument is a block of data to use for uniform arguments, as per types and offsets defined by the shader. Normally this is generated by [methodGsk.GLShader.format_args] or [structGsk.ShaderArgsBuilder].
The snapshotter takes ownership of take_args, so the caller should not free it after this.
If the renderer doesn't support GL shaders, or if there is any problem when compiling the shader, then the node will draw pink. You should use [methodGsk.GLShader.compile] to ensure the shader will work for the renderer before using it.
If the shader requires textures (see [methodGsk.GLShader.get_n_textures]),
then it is expected that you call [methodGtk.Snapshot.gl_shader_pop_texture]
the number of times that are required. Each of these calls will generate
a node that is added as a child to the GskGLShaderNode, which in turn
will render these offscreen and pass as a texture to the shader.
Once all textures (if any) are pop:ed, you must call the regular [methodGtk.Snapshot.pop].
If you want to use pre-existing textures as input to the shader rather than rendering new ones, use [methodGtk.Snapshot.append_texture] to push a texture node. These will be used directly rather than being re-rendered.
For details on how to write shaders, see [classGsk.GLShader].
#push_mask(mask_mode) ⇒ nil
Until the first call to [methodGtk.Snapshot.pop], the mask image for the mask operation will be recorded.
After that call, the source image will be recorded until the second call to [methodGtk.Snapshot.pop].
Calling this function requires 2 subsequent calls to gtk_snapshot_pop().
#push_opacity(opacity) ⇒ nil
Modifies the opacity of an image.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
#push_repeat(bounds, child_bounds) ⇒ nil
Creates a node that repeats the child node.
The child is recorded until the next call to [methodGtk.Snapshot.pop].
#push_rounded_clip(bounds) ⇒ nil
Clips an image to a rounded rectangle.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
#push_shadow(shadow, n_shadows) ⇒ nil
Applies a shadow to an image.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
#push_stroke(path, stroke) ⇒ nil
Strokes the given path with the attributes given by stroke and an image.
The image is recorded until the next call to [methodGtk.Snapshot.pop].
Note that the strokes are subject to the same transformation as everything else, so uneven scaling will cause horizontal and vertical strokes to have different widths.
If you want to stroke the path with a color, [methodGtk.Snapshot.append_stroke] may be more convenient.
#render_background(context, x, y, width, height) ⇒ nil
Creates a render node for the CSS background according to context, and appends it to the current node of snapshot, without changing the current node.
#render_focus(context, x, y, width, height) ⇒ nil
Creates a render node for the focus outline according to context, and appends it to the current node of snapshot, without changing the current node.
#render_frame(context, x, y, width, height) ⇒ nil
Creates a render node for the CSS border according to context, and appends it to the current node of snapshot, without changing the current node.
#render_insertion_cursor(context, x, y, layout, index, direction) ⇒ nil
Draws a text caret using snapshot at the specified index of layout.
#render_layout(context, x, y, layout) ⇒ nil
Creates a render node for rendering layout according to the style information in context, and appends it to the current node of snapshot, without changing the current node.
#restore ⇒ nil
Restores snapshot to the state saved by a preceding call to [methodSnapshot.save] and removes that state from the stack of saved states.
#rotate(angle) ⇒ nil
Rotates @snapshot's coordinate system by angle degrees in 2D space - or in 3D speak, rotates around the Z axis. The rotation happens around the origin point of (0, 0) in the snapshot's current coordinate system.
To rotate around axes other than the Z axis, use [methodGsk.Transform.rotate_3d].
#rotate_3d(angle, axis) ⇒ nil
Rotates snapshot's coordinate system by angle degrees around axis.
For a rotation in 2D space, use [methodGsk.Transform.rotate].
#save ⇒ nil
Makes a copy of the current state of snapshot and saves it on an internal stack.
When [methodGtk.Snapshot.restore] is called, snapshot will be restored to the saved state.
Multiple calls to [methodGtk.Snapshot.save] and [methodGtk.Snapshot.restore]
can be nested; each call to gtk_snapshot_restore() restores the state from
the matching paired gtk_snapshot_save().
It is necessary to clear all saved states with corresponding
calls to gtk_snapshot_restore().
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gtk4/snapshot.rb', line 20 def save save_raw if block_given? begin yield ensure restore end end end |
#save_raw ⇒ nil
Makes a copy of the current state of snapshot and saves it on an internal stack.
When [methodGtk.Snapshot.restore] is called, snapshot will be restored to the saved state.
Multiple calls to [methodGtk.Snapshot.save] and [methodGtk.Snapshot.restore]
can be nested; each call to gtk_snapshot_restore() restores the state from
the matching paired gtk_snapshot_save().
It is necessary to clear all saved states with corresponding
calls to gtk_snapshot_restore().
|
|
# File 'lib/gtk4/snapshot.rb', line 19
|
#scale(factor_x, factor_y) ⇒ nil
Scales snapshot's coordinate system in 2-dimensional space by the given factors.
Use [methodGtk.Snapshot.scale_3d] to scale in all 3 dimensions.
#scale_3d(factor_x, factor_y, factor_z) ⇒ nil
Scales snapshot's coordinate system by the given factors.
#to_node ⇒ Gsk::RenderNode
Returns the render node that was constructed by snapshot.
Note that this function may return nil if nothing has been added to the snapshot or if its content does not produce pixels to be rendered.
After calling this function, it is no longer possible to add more nodes to snapshot. The only function that should be called after this is [methodGObject.Object.unref].
#to_paintable(size) ⇒ Gdk::Paintable
Returns a paintable encapsulating the render node that was constructed by snapshot.
After calling this function, it is no longer possible to add more nodes to snapshot. The only function that should be called after this is [methodGObject.Object.unref].
#transform(transform) ⇒ nil
Transforms snapshot's coordinate system with the given transform.
#transform_matrix(matrix) ⇒ nil
Transforms snapshot's coordinate system with the given matrix.
#translate(point) ⇒ nil
Translates snapshot's coordinate system by point in 2-dimensional space.
#translate_3d(point) ⇒ nil
Translates snapshot's coordinate system by point.