The blend modes available for render nodes.
The implementation of each blend mode is deferred to the
rendering pipeline.
See <https://www.w3.org/TR/compositing-1/#blending> for more information
on blending and blend modes.
The default blend mode, which specifies no blending
The source color is multiplied by the destination
and replaces the destination
Multiplies the complements of the destination and source
color values, then complements the result.
Multiplies or screens the colors, depending on the
destination color value. This is the inverse of hard-list
Selects the darker of the destination and source colors
Selects the lighter of the destination and source colors
Brightens the destination color to reflect the source color
Darkens the destination color to reflect the source color
Multiplies or screens the colors, depending on the source color value
Darkens or lightens the colors, depending on the source color value
Subtracts the darker of the two constituent colors from the lighter color
Produces an effect similar to that of the difference mode but lower in contrast
Creates a color with the hue and saturation of the source color and the luminosity of the destination color
Creates a color with the hue of the source color and the saturation and luminosity of the destination color
Creates a color with the saturation of the source color and the hue and luminosity of the destination color
Creates a color with the luminosity of the source color and the hue and saturation of the destination color
A render node applying a blending function between its two child nodes.
Creates a `GskRenderNode` that will use @blend_mode to blend the @top
node onto the @bottom node.
A new `GskRenderNode`
The bottom node to be drawn
The node to be blended onto the @bottom node
The blend mode to use
Retrieves the blend mode used by @node.
the blend mode
a blending `GskRenderNode`
Retrieves the bottom `GskRenderNode` child of the @node.
the bottom child node
a blending `GskRenderNode`
Retrieves the top `GskRenderNode` child of the @node.
the top child node
a blending `GskRenderNode`
A render node applying a blur effect to its single child.
Creates a render node that blurs the child.
a new `GskRenderNode`
the child node to blur
the blur radius. Must be positive
Retrieves the child `GskRenderNode` of the blur @node.
the blurred child node
a blur `GskRenderNode`
Retrieves the blur radius of the @node.
the blur radius
a blur `GskRenderNode`
A render node for a border.
Creates a `GskRenderNode` that will stroke a border rectangle inside the
given @outline.
The 4 sides of the border can have different widths and colors.
A new `GskRenderNode`
a `GskRoundedRect` describing the outline of the border
the stroke width of the border on
the top, right, bottom and left side respectively.
the color used on the top, right,
bottom and left side.
Retrieves the colors of the border.
an array of 4 `GdkRGBA` structs
for the top, right, bottom and left color of the border
a `GskRenderNode` for a border
Retrieves the outline of the border.
the outline of the border
a `GskRenderNode` for a border
Retrieves the stroke widths of the border.
an array of 4 floats
for the top, right, bottom and left stroke width of the border,
respectively
a `GskRenderNode` for a border
A Broadway based renderer.
See [class@Gsk.Renderer].
Creates a new Broadway renderer.
The Broadway renderer is the default renderer for the broadway backend.
It will only work with broadway surfaces, otherwise it will fail the
call to gsk_renderer_realize().
This function is only available when GTK was compiled with Broadway
support.
a new Broadway renderer.
A render node for a Cairo surface.
Creates a `GskRenderNode` that will render a cairo surface
into the area given by @bounds.
You can draw to the cairo surface using [method@Gsk.CairoNode.get_draw_context].
A new `GskRenderNode`
the rectangle to render to
Creates a Cairo context for drawing using the surface associated
to the render node.
If no surface exists yet, a surface will be created optimized for
rendering to @renderer.
a Cairo context used for drawing; use
cairo_destroy() when done drawing
a `GskRenderNode` for a Cairo surface
Retrieves the Cairo surface used by the render node.
a Cairo surface
a `GskRenderNode` for a Cairo surface
A GSK renderer that is using cairo.
Since it is using cairo, this renderer cannot support
3D transformations.
Creates a new Cairo renderer.
The Cairo renderer is the fallback renderer drawing in ways similar
to how GTK 3 drew its content. Its primary use is as comparison tool.
The Cairo renderer is incomplete. It cannot render 3D transformed
content and will instead render an error marker. Its usage should be
avoided.
a new Cairo renderer.
A render node applying a rectangular clip to its single child node.
Creates a `GskRenderNode` that will clip the @child to the area
given by @clip.
A new `GskRenderNode`
The node to draw
The clip to apply
Gets the child node that is getting clipped by the given @node.
The child that is getting clipped
a clip @GskRenderNode
Retrieves the clip rectangle for @node.
a clip rectangle
a `GskClipNode`
A render node controlling the color matrix of its single child node.
Creates a `GskRenderNode` that will drawn the @child with
@color_matrix.
In particular, the node will transform colors 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.
A new `GskRenderNode`
The node to draw
The matrix to apply
Values to add to the color
Gets the child node that is getting its colors modified by the given @node.
The child that is getting its colors modified
a color matrix `GskRenderNode`
Retrieves the color matrix used by the @node.
a 4x4 color matrix
a color matrix `GskRenderNode`
Retrieves the color offset used by the @node.
a color vector
a color matrix `GskRenderNode`
A render node for a solid color.
Creates a `GskRenderNode` that will render the color specified by @rgba into
the area given by @bounds.
A new `GskRenderNode`
a `GdkRGBA` specifying a color
the rectangle to render the color into
Retrieves the color of the given @node.
the color of the node
a `GskRenderNode`
A color stop in a gradient node.
the offset of the color stop
the color at the given offset
A render node for a conic gradient.
Creates a `GskRenderNode` that draws a conic gradient.
The conic gradient
starts around @center in the direction of @rotation. A rotation of 0 means
that the gradient points up. Color stops are then added clockwise.
A new `GskRenderNode`
the bounds of the node
the center of the gradient
the rotation of the gradient in degrees
a pointer to an array of
`GskColorStop` defining the gradient. The offsets of all color stops
must be increasing. The first stop's offset must be >= 0 and the last
stop's offset must be <= 1.
the number of elements in @color_stops
Retrieves the angle for the gradient in radians, normalized in [0, 2 * PI].
The angle is starting at the top and going clockwise, as expressed
in the css specification:
angle = 90 - gsk_conic_gradient_node_get_rotation()
the angle for the gradient
a `GskRenderNode` for a conic gradient
Retrieves the center pointer for the gradient.
the center point for the gradient
a `GskRenderNode` for a conic gradient
Retrieves the color stops in the gradient.
the color stops in the gradient
a `GskRenderNode` for a conic gradient
the number of color stops in the returned array
Retrieves the number of color stops in the gradient.
the number of color stops
a `GskRenderNode` for a conic gradient
Retrieves the rotation for the gradient in degrees.
the rotation for the gradient
a `GskRenderNode` for a conic gradient
A render node that can contain other render nodes.
Creates a new `GskRenderNode` instance for holding the given @children.
The new node will acquire a reference to each of the children.
the new `GskRenderNode`
The children of the node
Number of children in the @children array
Gets one of the children of @container.
the @idx'th child of @container
a container `GskRenderNode`
the position of the child to get
Retrieves the number of direct children of @node.
the number of children of the `GskRenderNode`
a container `GskRenderNode`
The corner indices used by `GskRoundedRect`.
The top left corner
The top right corner
The bottom right corner
The bottom left corner
A render node cross fading between two child nodes.
Creates a `GskRenderNode` that will do a cross-fade between @start and @end.
A new `GskRenderNode`
The start node to be drawn
The node to be cross_fadeed onto the @start node
How far the fade has progressed from start to end. The value will
be clamped to the range [0 ... 1]
Retrieves the child `GskRenderNode` at the end of the cross-fade.
a `GskRenderNode`
a cross-fading `GskRenderNode`
Retrieves the progress value of the cross fade.
the progress value, between 0 and 1
a cross-fading `GskRenderNode`
Retrieves the child `GskRenderNode` at the beginning of the cross-fade.
a `GskRenderNode`
a cross-fading `GskRenderNode`
A render node that emits a debugging message when drawing its
child node.
Creates a `GskRenderNode` that will add debug information about
the given @child.
Adding this node has no visual effect.
A new `GskRenderNode`
The child to add debug info for
The debug message
Gets the child node that is getting drawn by the given @node.
the child `GskRenderNode`
a debug `GskRenderNode`
Gets the debug message that was set on this node
The debug message
a debug `GskRenderNode`
A render node filling the area given by [struct@Gsk.Path]
and [enum@Gsk.FillRule] with the child node.
Creates a `GskRenderNode` that will fill the @child in the area
given by @path and @fill_rule.
A new `GskRenderNode`
The node to fill the area with
The path describing the area to fill
The fill rule to use
Gets the child node that is getting drawn by the given @node.
The child that is getting drawn
a fill `GskRenderNode`
Retrieves the fill rule used to determine how the path is filled.
a `GskFillRule`
a fill `GskRenderNode`
Retrieves the path used to describe the area filled with the contents of
the @node.
a `GskPath`
a fill `GskRenderNode`
`GskFillRule` is used to select how paths are filled.
Whether or not a point is included in the fill is determined by taking
a ray from that point to infinity and looking at intersections with the
path. The ray can be in any direction, as long as it doesn't pass through
the end point of a segment or have a tricky intersection such as
intersecting tangent to the path.
(Note that filling is not actually implemented in this way. This
is just a description of the rule that is applied.)
New entries may be added in future versions.
If the path crosses the ray from
left-to-right, counts +1. If the path crosses the ray
from right to left, counts -1. (Left and right are determined
from the perspective of looking along the ray from the starting
point.) If the total count is non-zero, the point will be filled.
Counts the total number of
intersections, without regard to the orientation of the contour. If
the total number of intersections is odd, the point will be
filled.
A GL based renderer.
See [class@Gsk.Renderer].
Creates a new `GskRenderer` using the new OpenGL renderer.
a new GL renderer
A `GskGLShader` is a snippet of GLSL that is meant to run in the
fragment shader of the rendering pipeline.
A fragment shader gets the coordinates being rendered as input and
produces the pixel values for that particular pixel. Additionally,
the shader can declare a set of other input arguments, called
uniforms (as they are uniform over all the calls to your shader in
each instance of use). A shader can also receive up to 4
textures that it can use as input when producing the pixel data.
`GskGLShader` is usually used with gtk_snapshot_push_gl_shader()
to produce a [class@Gsk.GLShaderNode] in the rendering hierarchy,
and then its input textures are constructed by rendering the child
nodes to textures before rendering the shader node itself. (You can
pass texture nodes as children if you want to directly use a texture
as input).
The actual shader code is GLSL code that gets combined with
some other code into the fragment shader. Since the exact
capabilities of the GPU driver differs between different OpenGL
drivers and hardware, GTK adds some defines that you can use
to ensure your GLSL code runs on as many drivers as it can.
If the OpenGL driver is GLES, then the shader language version
is set to 100, and GSK_GLES will be defined in the shader.
Otherwise, if the OpenGL driver does not support the 3.2 core profile,
then the shader will run with language version 110 for GL2 and 130 for GL3,
and GSK_LEGACY will be defined in the shader.
If the OpenGL driver supports the 3.2 code profile, it will be used,
the shader language version is set to 150, and GSK_GL3 will be defined
in the shader.
The main function the shader must implement is:
```glsl
void mainImage(out vec4 fragColor,
in vec2 fragCoord,
in vec2 resolution,
in vec2 uv)
```
Where the input @fragCoord is the coordinate of the pixel we're
currently rendering, relative to the boundary rectangle that was
specified in the `GskGLShaderNode`, and @resolution is the width and
height of that rectangle. This is in the typical GTK coordinate
system with the origin in the top left. @uv contains the u and v
coordinates that can be used to index a texture at the
corresponding point. These coordinates are in the [0..1]x[0..1]
region, with 0, 0 being in the lower left corder (which is typical
for OpenGL).
The output @fragColor should be a RGBA color (with
premultiplied alpha) that will be used as the output for the
specified pixel location. Note that this output will be
automatically clipped to the clip region of the glshader node.
In addition to the function arguments the shader can define
up to 4 uniforms for textures which must be called u_textureN
(i.e. u_texture1 to u_texture4) as well as any custom uniforms
you want of types int, uint, bool, float, vec2, vec3 or vec4.
All textures sources contain premultiplied alpha colors, but if some
there are outer sources of colors there is a gsk_premultiply() helper
to compute premultiplication when needed.
Note that GTK parses the uniform declarations, so each uniform has to
be on a line by itself with no other code, like so:
```glsl
uniform float u_time;
uniform vec3 u_color;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
```
GTK uses the "gsk" namespace in the symbols it uses in the
shader, so your code should not use any symbols with the prefix gsk
or GSK. There are some helper functions declared that you can use:
```glsl
vec4 GskTexture(sampler2D sampler, vec2 texCoords);
```
This samples a texture (e.g. u_texture1) at the specified
coordinates, and contains some helper ifdefs to ensure that
it works on all OpenGL versions.
You can compile the shader yourself using [method@Gsk.GLShader.compile],
otherwise the GSK renderer will do it when it handling the glshader
node. If errors occurs, the returned @error will include the glsl
sources, so you can see what GSK was passing to the compiler. You
can also set GSK_DEBUG=shaders in the environment to see the sources
and other relevant information about all shaders that GSK is handling.
# An example shader
```glsl
uniform float position;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
void mainImage(out vec4 fragColor,
in vec2 fragCoord,
in vec2 resolution,
in vec2 uv) {
vec4 source1 = GskTexture(u_texture1, uv);
vec4 source2 = GskTexture(u_texture2, uv);
fragColor = position * source1 + (1.0 - position) * source2;
}
```
# Deprecation
This feature was deprecated in GTK 4.16 after the new rendering infrastructure
introduced in 4.14 did not support it.
The lack of Vulkan integration would have made it a very hard feature to support.
If you want to use OpenGL directly, you should look at [GtkGLArea](../gtk4/class.GLArea.html)
which uses a different approach and is still well supported.
Creates a `GskGLShader` that will render pixels using the specified code.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
A new `GskGLShader`
GLSL sourcecode for the shader, as a `GBytes`
Creates a `GskGLShader` that will render pixels using the specified code.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
A new `GskGLShader`
path to a resource that contains the GLSL sourcecode for
the shader
Tries to compile the @shader for the given @renderer.
If there is a problem, this function returns %FALSE and reports
an error. You should use this function before relying on the shader
for rendering and use a fallback with a simpler shader or without
shaders if it fails.
Note that this will modify the rendering state (for example
change the current GL context) and requires the renderer to be
set up. This means that the widget has to be realized. Commonly you
want to call this from the realize signal of a widget, or during
widget snapshot.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
%TRUE on success, %FALSE if an error occurred
a `GskGLShader`
a `GskRenderer`
Looks for a uniform by the name @name, and returns the index
of the uniform, or -1 if it was not found.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The index of the uniform, or -1
a `GskGLShader`
uniform name
Formats the uniform data as needed for feeding the named uniforms
values into the shader.
The argument list is a list of pairs of names, and values for the types
that match the declared uniforms (i.e. double/int/guint/gboolean for
primitive values and `graphene_vecN_t *` for vecN uniforms).
Any uniforms of the shader that are not included in the argument list
are zero-initialized.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
A newly allocated block of data which can be
passed to [ctor@Gsk.GLShaderNode.new].
a `GskGLShader`
name-Value pairs for the uniforms of @shader, ending with
a %NULL name
Formats the uniform data as needed for feeding the named uniforms
values into the shader.
The argument list is a list of pairs of names, and values for the
types that match the declared uniforms (i.e. double/int/guint/gboolean
for primitive values and `graphene_vecN_t *` for vecN uniforms).
It is an error to pass a uniform name that is not declared by the shader.
Any uniforms of the shader that are not included in the argument list
are zero-initialized.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
A newly allocated block of data which can be
passed to [ctor@Gsk.GLShaderNode.new].
a `GskGLShader`
name-Value pairs for the uniforms of @shader, ending
with a %NULL name
Gets the value of the uniform @idx in the @args block.
The uniform must be of bool type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The value
a `GskGLShader`
uniform arguments
index of the uniform
Gets the value of the uniform @idx in the @args block.
The uniform must be of float type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The value
a `GskGLShader`
uniform arguments
index of the uniform
Gets the value of the uniform @idx in the @args block.
The uniform must be of int type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The value
a `GskGLShader`
uniform arguments
index of the uniform
Gets the value of the uniform @idx in the @args block.
The uniform must be of uint type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The value
a `GskGLShader`
uniform arguments
index of the uniform
Gets the value of the uniform @idx in the @args block.
The uniform must be of vec2 type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskGLShader`
uniform arguments
index of the uniform
location to store the uniform value in
Gets the value of the uniform @idx in the @args block.
The uniform must be of vec3 type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskGLShader`
uniform arguments
index of the uniform
location to store the uniform value in
Gets the value of the uniform @idx in the @args block.
The uniform must be of vec4 type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskGLShader`
uniform arguments
index of the uniform
location to store set the uniform value in
Get the size of the data block used to specify arguments for this shader.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The size of the data block
a `GskGLShader`
Returns the number of textures that the shader requires.
This can be used to check that the a passed shader works
in your usecase. It is determined by looking at the highest
u_textureN value that the shader defines.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The number of texture inputs required by @shader
a `GskGLShader`
Get the number of declared uniforms for this shader.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The number of declared uniforms
a `GskGLShader`
Gets the resource path for the GLSL sourcecode being used
to render this shader.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The resource path for the shader
a `GskGLShader`
Gets the GLSL sourcecode being used to render this shader.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The source code for the shader
a `GskGLShader`
Get the name of the declared uniform for this shader at index @idx.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The name of the declared uniform
a `GskGLShader`
index of the uniform
Get the offset into the data block where data for this uniforms is stored.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The data offset
a `GskGLShader`
index of the uniform
Get the type of the declared uniform for this shader at index @idx.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The type of the declared uniform
a `GskGLShader`
index of the uniform
Resource containing the source code for the shader.
If the shader source is not coming from a resource, this
will be %NULL.
The source code for the shader, as a `GBytes`.
A render node using a GL shader when drawing its children nodes.
Creates a `GskRenderNode` that will render the given @shader into the
area given by @bounds.
The @args is a block of data to use for uniform input, as per types and
offsets defined by the @shader. Normally this is generated by
[method@Gsk.GLShader.format_args] or [struct@Gsk.ShaderArgsBuilder].
See [class@Gsk.GLShader] for details about how the shader should be written.
All the children will be rendered into textures (if they aren't already
`GskTextureNodes`, which will be used directly). These textures will be
sent as input to the shader.
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
[method@Gsk.GLShader.compile] to ensure the @shader will work for the
renderer before using it.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
A new `GskRenderNode`
the `GskGLShader`
the rectangle to render the shader into
Arguments for the uniforms
array of child nodes,
these will be rendered to textures and used as input.
Length of @children (currently the GL backend supports
up to 4 children)
Gets args for the node.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
A `GBytes` with the uniform arguments
a `GskRenderNode` for a gl shader
Gets one of the children.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
the @idx'th child of @node
a `GskRenderNode` for a gl shader
the position of the child to get
Returns the number of children
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The number of children
a `GskRenderNode` for a gl shader
Gets shader code for the node.
the `GskGLShader` shader
a `GskRenderNode` for a gl shader
This defines the types of the uniforms that `GskGLShaders`
declare.
It defines both what the type is called in the GLSL shader
code, and what the corresponding C type is on the Gtk side.
No type, used for uninitialized or unspecified values.
A float uniform
A GLSL int / gint32 uniform
A GLSL uint / guint32 uniform
A GLSL bool / gboolean uniform
A GLSL vec2 / graphene_vec2_t uniform
A GLSL vec3 / graphene_vec3_t uniform
A GLSL vec4 / graphene_vec4_t uniform
A render node for an inset shadow.
Creates a `GskRenderNode` that will render an inset shadow
into the box given by @outline.
A new `GskRenderNode`
outline of the region containing the shadow
color of the shadow
horizontal offset of shadow
vertical offset of shadow
how far the shadow spreads towards the inside
how much blur to apply to the shadow
Retrieves the blur radius to apply to the shadow.
the blur radius, in pixels
a `GskRenderNode` for an inset shadow
Retrieves the color of the inset shadow.
the color of the shadow
a `GskRenderNode` for an inset shadow
Retrieves the horizontal offset of the inset shadow.
an offset, in pixels
a `GskRenderNode` for an inset shadow
Retrieves the vertical offset of the inset shadow.
an offset, in pixels
a `GskRenderNode` for an inset shadow
Retrieves the outline rectangle of the inset shadow.
a rounded rectangle
a `GskRenderNode` for an inset shadow
Retrieves how much the shadow spreads inwards.
the size of the shadow, in pixels
a `GskRenderNode` for an inset shadow
Specifies how to render the start and end points of contours or
dashes when stroking.
The default line cap style is `GSK_LINE_CAP_BUTT`.
New entries may be added in future versions.
<figure>
<picture>
<source srcset="caps-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Line Cap Styles" src="caps-light.png">
</picture>
<figcaption>GSK_LINE_CAP_BUTT, GSK_LINE_CAP_ROUND, GSK_LINE_CAP_SQUARE</figcaption>
</figure>
Start and stop the line exactly at the start
and end point
Use a round ending, the center of the circle
is the start or end point
use squared ending, the center of the square
is the start or end point
Specifies how to render the junction of two lines when stroking.
The default line join style is `GSK_LINE_JOIN_MITER`.
New entries may be added in future versions.
<figure>
<picture>
<source srcset="join-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Line Join Styles" src="join-light.png">
</picture>
<figcaption>GSK_LINE_JOINT_MITER, GSK_LINE_JOINT_ROUND, GSK_LINE_JOIN_BEVEL</figcaption>
</figure>
Use a sharp angled corner
Use a round join, the center of the circle is
the join point
use a cut-off join, the join is cut off at half
the line width from the joint point
A render node for a linear gradient.
Creates a `GskRenderNode` that will create a linear gradient from the given
points and color stops, and render that into the area given by @bounds.
A new `GskRenderNode`
the rectangle to render the linear gradient into
the point at which the linear gradient will begin
the point at which the linear gradient will finish
a pointer to an array of
`GskColorStop` defining the gradient. The offsets of all color stops
must be increasing. The first stop's offset must be >= 0 and the last
stop's offset must be <= 1.
the number of elements in @color_stops
Retrieves the color stops in the gradient.
the color stops in the gradient
a `GskRenderNode` for a linear gradient
the number of color stops in the returned array
Retrieves the final point of the linear gradient.
the final point
a `GskRenderNode` for a linear gradient
Retrieves the number of color stops in the gradient.
the number of color stops
a `GskRenderNode` for a linear gradient
Retrieves the initial point of the linear gradient.
the initial point
a `GskRenderNode` for a linear gradient
The mask modes available for mask nodes.
Use the alpha channel of the mask
Use the inverted alpha channel of the mask
Use the luminance of the mask,
multiplied by mask alpha
Use the inverted luminance of the mask,
multiplied by mask alpha
A render node masking one child node with another.
Creates a `GskRenderNode` that will mask a given node by another.
The @mask_mode determines how the 'mask values' are derived from
the colors of the @mask. Applying the mask consists of multiplying
the 'mask value' with the alpha of the source.
A new `GskRenderNode`
The source node to be drawn
The node to be used as mask
The mask mode to use
Retrieves the mask `GskRenderNode` child of the @node.
the mask child node
a mask `GskRenderNode`
Retrieves the mask mode used by @node.
the mask mode
a blending `GskRenderNode`
Retrieves the source `GskRenderNode` child of the @node.
the source child node
a mask `GskRenderNode`
A GL based renderer.
See [class@Gsk.Renderer].
Creates an instance of the new experimental GL renderer.
a new GL renderer
A render node controlling the opacity of its single child node.
Creates a `GskRenderNode` that will drawn the @child with reduced
@opacity.
A new `GskRenderNode`
The node to draw
The opacity to apply
Gets the child node that is getting opacityed by the given @node.
The child that is getting opacityed
a `GskRenderNode` for an opacity
Gets the transparency factor for an opacity node.
the opacity factor
a `GskRenderNode` for an opacity
A render node for an outset shadow.
Creates a `GskRenderNode` that will render an outset shadow
around the box given by @outline.
A new `GskRenderNode`
outline of the region surrounded by shadow
color of the shadow
horizontal offset of shadow
vertical offset of shadow
how far the shadow spreads towards the inside
how much blur to apply to the shadow
Retrieves the blur radius of the shadow.
the blur radius, in pixels
a `GskRenderNode` for an outset shadow
Retrieves the color of the outset shadow.
a color
a `GskRenderNode` for an outset shadow
Retrieves the horizontal offset of the outset shadow.
an offset, in pixels
a `GskRenderNode` for an outset shadow
Retrieves the vertical offset of the outset shadow.
an offset, in pixels
a `GskRenderNode` for an outset shadow
Retrieves the outline rectangle of the outset shadow.
a rounded rectangle
a `GskRenderNode` for an outset shadow
Retrieves how much the shadow spreads outwards.
the size of the shadow, in pixels
a `GskRenderNode` for an outset shadow
Type of callback that is called when an error occurs
during node deserialization.
start of the error location
end of the error location
the error
user data
A location in a parse buffer.
the offset of the location in the parse buffer, as bytes
the offset of the location in the parse buffer, as characters
the line of the location in the parse buffer
the position in the line, as bytes
the position in the line, as characters
A `GskPath` describes lines and curves that are more complex
than simple rectangles.
Paths can used for rendering (filling or stroking) and for animations
(e.g. as trajectories).
`GskPath` is an immutable, opaque, reference-counted struct.
After creation, you cannot change the types it represents. Instead,
new `GskPath` objects have to be created. The [struct@Gsk.PathBuilder]
structure is meant to help in this endeavor.
Conceptually, a path consists of zero or more contours (continuous, connected
curves), each of which may or may not be closed. Contours are typically
constructed from Bézier segments.
<picture>
<source srcset="path-dark.png" media="(prefers-color-scheme: dark)">
<img alt="A Path" src="path-light.png">
</picture>
Calls @func for every operation of the path.
Note that this may only approximate @self, because paths can contain
optimizations for various specialized contours, and depending on the
@flags, the path may be decomposed into simpler curves than the ones
that it contained originally.
This function serves two purposes:
- When the @flags allow everything, it provides access to the raw,
unmodified data of the path.
- When the @flags disallow certain operations, it provides
an approximation of the path using just the allowed operations.
`FALSE` if @func returned FALSE`, `TRUE` otherwise.
a `GskPath`
flags to pass to the foreach function. See [flags@Gsk.PathForeachFlags]
for details about flags
the function to call for operations
user data passed to @func
Computes the bounds of the given path.
The returned bounds may be larger than necessary, because this
function aims to be fast, not accurate. The bounds are guaranteed
to contain the path.
It is possible that the returned rectangle has 0 width and/or height.
This can happen when the path only describes a point or an
axis-aligned line.
If the path is empty, `FALSE` is returned and @bounds are set to
graphene_rect_zero(). This is different from the case where the path
is a single point at the origin, where the @bounds will also be set to
the zero rectangle but `TRUE` will be returned.
`TRUE` if the path has bounds, `FALSE` if the path is known
to be empty and have no bounds.
a `GskPath`
the bounds of the given path
Computes the closest point on the path to the given point
and sets the @result to it.
If there is no point closer than the given threshold,
`FALSE` is returned.
`TRUE` if @point was set to the closest point
on @self, `FALSE` if no point is closer than @threshold
a `GskPath`
the point
maximum allowed distance
return location for the closest point
return location for the distance
Gets the end point of the path.
An empty path has no points, so `FALSE`
is returned in this case.
`TRUE` if @result was filled
a `GskPath`
return location for point
Gets the start point of the path.
An empty path has no points, so `FALSE`
is returned in this case.
`TRUE` if @result was filled
a `GskPath`
return location for point
Computes the bounds for stroking the given path with the
parameters in @stroke.
The returned bounds may be larger than necessary, because this
function aims to be fast, not accurate. The bounds are guaranteed
to contain the area affected by the stroke, including protrusions
like miters.
`TRUE` if the path has bounds, `FALSE` if the path is known
to be empty and have no bounds.
a #GtkPath
stroke parameters
the bounds to fill in
Returns whether the given point is inside the area
that would be affected if the path was filled according
to @fill_rule.
Note that this function assumes that filling a contour
implicitly closes it.
`TRUE` if @point is inside
a `GskPath`
the point to test
the fill rule to follow
Returns if the path represents a single closed
contour.
`TRUE` if the path is closed
a `GskPath`
Checks if the path is empty, i.e. contains no lines or curves.
`TRUE` if the path is empty
a `GskPath`
Converts @self into a human-readable string representation suitable
for printing.
The string is compatible with (a superset of)
[SVG path syntax](https://www.w3.org/TR/SVG11/paths.html#PathData),
see [func@Gsk.Path.parse] for a summary of the syntax.
a `GskPath`
The string to print into
Increases the reference count of a `GskPath` by one.
the passed in `GskPath`.
a `GskPath`
Appends the given @path to the given cairo context for drawing
with Cairo.
This may cause some suboptimal conversions to be performed as
Cairo does not support all features of `GskPath`.
This function does not clear the existing Cairo path. Call
cairo_new_path() if you want this.
a `GskPath`
a cairo context
Converts the path into a string that is suitable for printing.
You can use this function in a debugger to get a quick overview
of the path.
This is a wrapper around [method@Gsk.Path.print], see that function
for details.
A new string for @self
a `GskPath`
Decreases the reference count of a `GskPath` by one.
If the resulting reference count is zero, frees the path.
a `GskPath`
This is a convenience function that constructs a `GskPath`
from a serialized form.
The string is expected to be in (a superset of)
[SVG path syntax](https://www.w3.org/TR/SVG11/paths.html#PathData),
as e.g. produced by [method@Gsk.Path.to_string].
A high-level summary of the syntax:
- `M x y` Move to `(x, y)`
- `L x y` Add a line from the current point to `(x, y)`
- `Q x1 y1 x2 y2` Add a quadratic Bézier from the current point to `(x2, y2)`, with control point `(x1, y1)`
- `C x1 y1 x2 y2 x3 y3` Add a cubic Bézier from the current point to `(x3, y3)`, with control points `(x1, y1)` and `(x2, y2)`
- `Z` Close the contour by drawing a line back to the start point
- `H x` Add a horizontal line from the current point to the given x value
- `V y` Add a vertical line from the current point to the given y value
- `T x2 y2` Add a quadratic Bézier, using the reflection of the previous segments' control point as control point
- `S x2 y2 x3 y3` Add a cubic Bézier, using the reflection of the previous segments' second control point as first control point
- `A rx ry r l s x y` Add an elliptical arc from the current point to `(x, y)` with radii rx and ry. See the SVG documentation for how the other parameters influence the arc.
- `O x1 y1 x2 y2 w` Add a rational quadratic Bézier from the current point to `(x2, y2)` with control point `(x1, y1)` and weight `w`.
All the commands have lowercase variants that interpret coordinates
relative to the current point.
The `O` command is an extension that is not supported in SVG.
a new `GskPath`, or `NULL` if @string could not be parsed
a string
`GskPathBuilder` is an auxiliary object for constructing
`GskPath` objects.
A path is constructed like this:
|[<!-- language="C" -->
GskPath *
construct_path (void)
{
GskPathBuilder *builder;
builder = gsk_path_builder_new ();
// add contours to the path here
return gsk_path_builder_free_to_path (builder);
]|
Adding contours to the path can be done in two ways.
The easiest option is to use the `gsk_path_builder_add_*` group
of functions that add predefined contours to the current path,
either common shapes like [method@Gsk.PathBuilder.add_circle]
or by adding from other paths like [method@Gsk.PathBuilder.add_path].
The `gsk_path_builder_add_*` methods always add complete contours,
and do not use or modify the current point.
The other option is to define each line and curve manually with
the `gsk_path_builder_*_to` group of functions. You start with
a call to [method@Gsk.PathBuilder.move_to] to set the starting point
and then use multiple calls to any of the drawing functions to
move the pen along the plane. Once you are done, you can call
[method@Gsk.PathBuilder.close] to close the path by connecting it
back with a line to the starting point.
This is similar to how paths are drawn in Cairo.
Note that `GskPathBuilder` will reduce the degree of added Bézier
curves as much as possible, to simplify rendering.
Create a new `GskPathBuilder` object.
The resulting builder would create an empty `GskPath`.
Use addition functions to add types to it.
a new `GskPathBuilder`
Adds a Cairo path to the builder.
You can use cairo_copy_path() to access the path
from a Cairo context.
a `GskPathBuilder`
a path
Adds a circle with the @center and @radius.
The path is going around the circle in clockwise direction.
If @radius is zero, the contour will be a closed point.
a `GskPathBuilder`
the center of the circle
the radius of the circle
Adds the outlines for the glyphs in @layout to the builder.
a #GskPathBuilder
the pango layout to add
Appends all of @path to the builder.
a `GskPathBuilder`
the path to append
Adds @rect as a new contour to the path built by the builder.
The path is going around the rectangle in clockwise direction.
If the the width or height are 0, the path will be a closed
horizontal or vertical line. If both are 0, it'll be a closed dot.
A `GskPathBuilder`
The rectangle to create a path for
Appends all of @path to the builder, in reverse order.
a `GskPathBuilder`
the path to append
Adds @rect as a new contour to the path built in @self.
The path is going around the rectangle in clockwise direction.
a #GskPathBuilder
the rounded rect
Adds to @self the segment of @path from @start to @end.
If @start is equal to or after @end, the path will first add the
segment from @start to the end of the path, and then add the segment
from the beginning to @end. If the path is closed, these segments
will be connected.
Note that this method always adds a path with the given start point
and end point. To add a closed path, use [method@Gsk.PathBuilder.add_path].
a `GskPathBuilder`
the `GskPath` to take the segment to
the point on @path to start at
the point on @path to end at
Adds an elliptical arc from the current point to @x2, @y2
with @x1, @y1 determining the tangent directions.
After this, @x2, @y2 will be the new current point.
Note: Two points and their tangents do not determine
a unique ellipse, so GSK just picks one. If you need more
precise control, use [method@Gsk.PathBuilder.conic_to]
or [method@Gsk.PathBuilder.svg_arc_to].
<picture>
<source srcset="arc-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Arc To" src="arc-light.png">
</picture>
a `GskPathBuilder`
x coordinate of first control point
y coordinate of first control point
x coordinate of second control point
y coordinate of second control point
Ends the current contour with a line back to the start point.
Note that this is different from calling [method@Gsk.PathBuilder.line_to]
with the start point in that the contour will be closed. A closed
contour behaves differently from an open one. When stroking, its
start and end point are considered connected, so they will be
joined via the line join, and not ended with line caps.
a `GskPathBuilder`
Adds a [conic curve](https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline)
from the current point to @x2, @y2 with the given @weight and @x1, @y1 as the
control point.
The weight determines how strongly the curve is pulled towards the control point.
A conic with weight 1 is identical to a quadratic Bézier curve with the same points.
Conic curves can be used to draw ellipses and circles. They are also known as
rational quadratic Bézier curves.
After this, @x2, @y2 will be the new current point.
<picture>
<source srcset="conic-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Conic To" src="conic-light.png">
</picture>
a `GskPathBuilder`
x coordinate of control point
y coordinate of control point
x coordinate of the end of the curve
y coordinate of the end of the curve
weight of the control point, must be greater than zero
Adds a [cubic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x3, @y3 with @x1, @y1 and @x2, @y2 as the control
points.
After this, @x3, @y3 will be the new current point.
<picture>
<source srcset="cubic-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Cubic To" src="cubic-light.png">
</picture>
a `GskPathBuilder`
x coordinate of first control point
y coordinate of first control point
x coordinate of second control point
y coordinate of second control point
x coordinate of the end of the curve
y coordinate of the end of the curve
Creates a new `GskPath` from the current state of the
given builder, and unrefs the @builder instance.
the newly created `GskPath`
with all the contours added to the builder
a `GskPathBuilder`
Gets the current point.
The current point is used for relative drawing commands and
updated after every operation.
When the builder is created, the default current point is set
to `0, 0`. Note that this is different from cairo, which starts
out without a current point.
The current point
a `GskPathBuilder`
Implements arc-to according to the HTML Canvas spec.
A convenience function that implements the
[HTML arc_to](https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-arcto-dev)
functionality.
After this, the current point will be the point where
the circle with the given radius touches the line from
@x1, @y1 to @x2, @y2.
a `GskPathBuilder`
X coordinate of first control point
Y coordinate of first control point
X coordinate of second control point
Y coordinate of second control point
Radius of the circle
Draws a line from the current point to @x, @y and makes it
the new current point.
<picture>
<source srcset="line-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Line To" src="line-light.png">
</picture>
a `GskPathBuilder`
x coordinate
y coordinate
Starts a new contour by placing the pen at @x, @y.
If this function is called twice in succession, the first
call will result in a contour made up of a single point.
The second call will start a new contour.
a `GskPathBuilder`
x coordinate
y coordinate
Adds a [quadratic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x2, @y2 with @x1, @y1 as the control point.
After this, @x2, @y2 will be the new current point.
<picture>
<source srcset="quad-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Quad To" src="quad-light.png">
</picture>
a #GskPathBuilder
x coordinate of control point
y coordinate of control point
x coordinate of the end of the curve
y coordinate of the end of the curve
Acquires a reference on the given builder.
This function is intended primarily for language bindings.
`GskPathBuilder` objects should not be kept around.
the given `GskPathBuilder` with
its reference count increased
a `GskPathBuilder`
Adds an elliptical arc from the current point to @x2, @y2
with @x1, @y1 determining the tangent directions.
All coordinates are given relative to the current point.
This is the relative version of [method@Gsk.PathBuilder.arc_to].
a `GskPathBuilder`
x coordinate of first control point
y coordinate of first control point
x coordinate of second control point
y coordinate of second control point
Adds a [conic curve](https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline)
from the current point to @x2, @y2 with the given @weight and @x1, @y1 as the
control point.
All coordinates are given relative to the current point.
This is the relative version of [method@Gsk.PathBuilder.conic_to].
a `GskPathBuilder`
x offset of control point
y offset of control point
x offset of the end of the curve
y offset of the end of the curve
weight of the curve, must be greater than zero
Adds a [cubic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x3, @y3 with @x1, @y1 and @x2, @y2 as the control
points.
All coordinates are given relative to the current point.
This is the relative version of [method@Gsk.PathBuilder.cubic_to].
a `GskPathBuilder`
x offset of first control point
y offset of first control point
x offset of second control point
y offset of second control point
x offset of the end of the curve
y offset of the end of the curve
Implements arc-to according to the HTML Canvas spec.
All coordinates are given relative to the current point.
This is the relative version of [method@Gsk.PathBuilder.html_arc_to].
a `GskPathBuilder`
X coordinate of first control point
Y coordinate of first control point
X coordinate of second control point
Y coordinate of second control point
Radius of the circle
Draws a line from the current point to a point offset from it
by @x, @y and makes it the new current point.
This is the relative version of [method@Gsk.PathBuilder.line_to].
a `GskPathBuilder`
x offset
y offset
Starts a new contour by placing the pen at @x, @y
relative to the current point.
This is the relative version of [method@Gsk.PathBuilder.move_to].
a `GskPathBuilder`
x offset
y offset
Adds a [quadratic Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
from the current point to @x2, @y2 with @x1, @y1 the control point.
All coordinates are given relative to the current point.
This is the relative version of [method@Gsk.PathBuilder.quad_to].
a `GskPathBuilder`
x offset of control point
y offset of control point
x offset of the end of the curve
y offset of the end of the curve
Implements arc-to according to the SVG spec.
All coordinates are given relative to the current point.
This is the relative version of [method@Gsk.PathBuilder.svg_arc_to].
a `GskPathBuilder`
X radius
Y radius
the rotation of the ellipsis
whether to add the large arc
whether to sweep in the positive direction
the X coordinate of the endpoint
the Y coordinate of the endpoint
Implements arc-to according to the SVG spec.
A convenience function that implements the
[SVG arc_to](https://www.w3.org/TR/SVG11/paths.html#PathDataEllipticalArcCommands)
functionality.
After this, @x, @y will be the new current point.
a `GskPathBuilder`
X radius
Y radius
the rotation of the ellipsis
whether to add the large arc
whether to sweep in the positive direction
the X coordinate of the endpoint
the Y coordinate of the endpoint
Creates a new `GskPath` from the given builder.
The given `GskPathBuilder` is reset once this function returns;
you cannot call this function multiple times on the same builder
instance.
This function is intended primarily for language bindings.
C code should use [method@Gsk.PathBuilder.free_to_path].
the newly created `GskPath`
with all the contours added to the builder
a `GskPathBuilder`
Releases a reference on the given builder.
a `GskPathBuilder`
The values of the `GskPathDirection` enum are used to pick one
of the four tangents at a given point on the path.
Note that the directions for @GSK_PATH_FROM_START/@GSK_PATH_TO_END and
@GSK_PATH_TO_START/@GSK_PATH_FROM_END will coincide for smooth points.
Only sharp turns will exhibit four different directions.
<picture>
<source srcset="directions-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Path Tangents" src="directions-light.png">
</picture>
The tangent in path direction of the incoming side
of the path
The tangent against path direction of the incoming side
of the path
The tangent in path direction of the outgoing side
of the path
The tangent against path direction of the outgoing
side of the path
Flags that can be passed to gsk_path_foreach() to influence what
kinds of operations the path is decomposed into.
By default, [method@Gsk.Path.foreach] will only emit a path with all
operations flattened to straight lines to allow for maximum compatibility.
The only operations emitted will be `GSK_PATH_MOVE`, `GSK_PATH_LINE` and
`GSK_PATH_CLOSE`.
The default behavior, only allow lines.
Allow emission of `GSK_PATH_QUAD` operations
Allow emission of `GSK_PATH_CUBIC` operations.
Allow emission of `GSK_PATH_CONIC` operations.
Prototype of the callback to iterate through the operations of
a path.
For each operation, the callback is given the @op itself, the points
that the operation is applied to in @pts, and a @weight for conic
curves. The @n_pts argument is somewhat redundant, since the number
of points can be inferred from the operation.
Each contour of the path starts with a @GSK_PATH_MOVE operation.
Closed contours end with a @GSK_PATH_CLOSE operation.
%TRUE to continue iterating the path, %FALSE to
immediately abort and not call the function again.
The operation
The points of the operation
The number of points
The weight for conic curves, or unused if not a conic curve
The user data provided with the function
`GskPathMeasure` is an object that allows measurements
on `GskPath`s such as determining the length of the path.
Many measuring operations require sampling the path length
at intermediate points. Therefore, a `GskPathMeasure` has
a tolerance that determines what precision is required
for such approximations.
A `GskPathMeasure` struct is a reference counted struct
and should be treated as opaque.
Creates a measure object for the given @path with the
default tolerance.
a new `GskPathMeasure` representing @path
the path to measure
Creates a measure object for the given @path and @tolerance.
a new `GskPathMeasure` representing @path
the path to measure
the tolerance for measuring operations
Gets the length of the path being measured.
The length is cached, so this function does not do any work.
The length of the path measured by @self
a `GskPathMeasure`
Returns the path that the measure was created for.
the path of @self
a `GskPathMeasure`
Sets @result to the point at the given distance into the path.
An empty path has no points, so `FALSE` is returned in that case.
`TRUE` if @result was set
a `GskPathMeasure`
the distance
return location for the result
Returns the tolerance that the measure was created with.
the tolerance of @self
a `GskPathMeasure`
Increases the reference count of a `GskPathMeasure` by one.
the passed in `GskPathMeasure`.
a `GskPathMeasure`
Decreases the reference count of a `GskPathMeasure` by one.
If the resulting reference count is zero, frees the object.
a `GskPathMeasure`
Path operations are used to describe the segments of a `GskPath`.
More values may be added in the future.
A move-to operation, with 1 point describing the target point.
A close operation ending the current contour with a line back
to the starting point. Two points describe the start and end of the line.
A line-to operation, with 2 points describing the start and
end point of a straight line.
A curve-to operation describing a quadratic Bézier curve
with 3 points describing the start point, the control point and the end
point of the curve.
A curve-to operation describing a cubic Bézier curve with 4
points describing the start point, the two control points and the end point
of the curve.
A rational quadratic Bézier curve with 3 points describing
the start point, control point and end point of the curve. A weight for the
curve will be passed, too.
`GskPathPoint` is an opaque type representing a point on a path.
It can be queried for properties of the path at that point, such as
its tangent or its curvature.
To obtain a `GskPathPoint`, use [method@Gsk.Path.get_closest_point],
[method@Gsk.Path.get_start_point], [method@Gsk.Path.get_end_point]
or [method@Gsk.PathMeasure.get_point].
Note that `GskPathPoint` structs are meant to be stack-allocated,
and don't hold a reference to the path object they are obtained from.
It is the callers responsibility to keep a reference to the path
as long as the `GskPathPoint` is used.
Returns whether @point1 is before or after @point2.
-1 if @point1 is before @point2,
1 if @point1 is after @point2,
0 if they are equal
a `GskPathPoint`
another `GskPathPoint`
Copies a path point.
the copied point
a path point
Returns whether the two path points refer to the same
location on all paths.
Note that the start- and endpoint of a closed contour
will compare nonequal according to this definition.
Use [method@Gsk.Path.is_closed] to find out if the
start- and endpoint of a concrete path refer to the
same location.
`TRUE` if @point1 and @point2 are equal
a `GskPathPoint`
another `GskPathPoint`
Frees a path point copied by [method@Gsk.PathPoint.copy].
a path point
Calculates the curvature of the path at the point.
Optionally, returns the center of the osculating circle as well.
The curvature is the inverse of the radius of the osculating circle.
Lines have a curvature of zero (indicating an osculating circle of
infinite radius. In this case, the @center is not modified.
Circles with a radius of zero have `INFINITY` as curvature
Note that certain points on a path may not have a single curvature,
such as sharp turns. At such points, there are two curvatures --
the (limit of) the curvature of the path going into the point,
and the (limit of) the curvature of the path coming out of it.
The @direction argument lets you choose which one to get.
<picture>
<source srcset="curvature-dark.png" media="(prefers-color-scheme: dark)">
<img alt="Osculating circle" src="curvature-light.png">
</picture>
The curvature of the path at the given point
a `GskPathPoint`
the path that @point is on
the direction for which to return the curvature
Return location for
the center of the osculating circle
Returns the distance from the beginning of the path
to @point.
the distance of @point
a `GskPathPoint on the path
a `GskPathMeasure` for the path
Gets the position of the point.
a `GskPathPoint`
the path that @point is on
Return location for
the coordinates of the point
Gets the direction of the tangent at a given point.
This is a convenience variant of [method@Gsk.PathPoint.get_tangent]
that returns the angle between the tangent and the X axis. The angle
can e.g. be used in
[gtk_snapshot_rotate()](../gtk4/method.Snapshot.rotate.html).
the angle between the tangent and the X axis, in degrees
a `GskPathPoint`
the path that @point is on
the direction for which to return the rotation
Gets the tangent of the path at the point.
Note that certain points on a path may not have a single
tangent, such as sharp turns. At such points, there are
two tangents -- the direction of the path going into the
point, and the direction coming out of it. The @direction
argument lets you choose which one to get.
If the path is just a single point (e.g. a circle with
radius zero), then @tangent is set to `0, 0`.
If you want to orient something in the direction of the
path, [method@Gsk.PathPoint.get_rotation] may be more
convenient to use.
a `GskPathPoint`
the path that @point is on
the direction for which to return the tangent
Return location for
the tangent at the point
Initializes a `GskRoundedRect` when declaring it.
All corner sizes will be initialized to 0.
the X coordinate of the origin
the Y coordinate of the origin
the width
the height
A render node for a radial gradient.
Creates a `GskRenderNode` that draws a radial gradient.
The radial gradient
starts around @center. The size of the gradient is dictated by @hradius
in horizontal orientation and by @vradius in vertical orientation.
A new `GskRenderNode`
the bounds of the node
the center of the gradient
the horizontal radius
the vertical radius
a percentage >= 0 that defines the start of the gradient around @center
a percentage >= 0 that defines the end of the gradient around @center
a pointer to an array of
`GskColorStop` defining the gradient. The offsets of all color stops
must be increasing. The first stop's offset must be >= 0 and the last
stop's offset must be <= 1.
the number of elements in @color_stops
Retrieves the center pointer for the gradient.
the center point for the gradient
a `GskRenderNode` for a radial gradient
Retrieves the color stops in the gradient.
the color stops in the gradient
a `GskRenderNode` for a radial gradient
the number of color stops in the returned array
Retrieves the end value for the gradient.
the end value for the gradient
a `GskRenderNode` for a radial gradient
Retrieves the horizontal radius for the gradient.
the horizontal radius for the gradient
a `GskRenderNode` for a radial gradient
Retrieves the number of color stops in the gradient.
the number of color stops
a `GskRenderNode` for a radial gradient
Retrieves the start value for the gradient.
the start value for the gradient
a `GskRenderNode` for a radial gradient
Retrieves the vertical radius for the gradient.
the vertical radius for the gradient
a `GskRenderNode` for a radial gradient
`GskRenderNode` is the basic block in a scene graph to be
rendered using [class@Gsk.Renderer].
Each node has a parent, except the top-level node; each node may have
children nodes.
Each node has an associated drawing surface, which has the size of
the rectangle set when creating it.
Render nodes are meant to be transient; once they have been associated
to a [class@Gsk.Renderer] it's safe to release any reference you have on
them. All [class@Gsk.RenderNode]s are immutable, you can only specify their
properties during construction.
Loads data previously created via [method@Gsk.RenderNode.serialize].
For a discussion of the supported format, see that function.
a new `GskRenderNode`
the bytes containing the data
Callback on parsing errors
user_data for @error_func
Draw the contents of @node to the given cairo context.
Typically, you'll use this function to implement fallback rendering
of `GskRenderNode`s on an intermediate Cairo context, instead of using
the drawing context associated to a [class@Gdk.Surface]'s rendering buffer.
For advanced nodes that cannot be supported using Cairo, in particular
for nodes doing 3D operations, this function may fail.
a `GskRenderNode`
cairo context to draw to
Retrieves the boundaries of the @node.
The node will not draw outside of its boundaries.
a `GskRenderNode`
return location for the boundaries
Returns the type of the @node.
the type of the `GskRenderNode`
a `GskRenderNode`
Gets an opaque rectangle inside the node that GTK can determine to
be fully opaque.
There is no guarantee that this is indeed the largest opaque rectangle or
that regions outside the rectangle are not opaque. This function is a best
effort with that goal.
The rectangle will be fully contained in the bounds of the node.
%TRUE if part or all of the rendernode is opaque, %FALSE if no
opaque region could be found.
a `GskRenderNode`
Acquires a reference on the given `GskRenderNode`.
the `GskRenderNode` with an additional reference
a `GskRenderNode`
Serializes the @node for later deserialization via
gsk_render_node_deserialize(). No guarantees are made about the format
used other than that the same version of GTK will be able to deserialize
the result of a call to gsk_render_node_serialize() and
gsk_render_node_deserialize() will correctly reject files it cannot open
that were created with previous versions of GTK.
The intended use of this functions is testing, benchmarking and debugging.
The format is not meant as a permanent storage format.
a `GBytes` representing the node.
a `GskRenderNode`
Releases a reference on the given `GskRenderNode`.
If the reference was the last, the resources associated to the @node are
freed.
a `GskRenderNode`
This function is equivalent to calling [method@Gsk.RenderNode.serialize]
followed by [func@GLib.file_set_contents].
See those two functions for details on the arguments.
It is mostly intended for use inside a debugger to quickly dump a render
node to a file for later inspection.
%TRUE if saving was successful
a `GskRenderNode`
the file to save it to.
The type of a node determines what the node is rendering.
Error type. No node will ever have this type.
A node containing a stack of children
A node drawing a `cairo_surface_t`
A node drawing a single color rectangle
A node drawing a linear gradient
A node drawing a repeating linear gradient
A node drawing a radial gradient
A node drawing a repeating radial gradient
A node drawing a conic gradient
A node stroking a border around an area
A node drawing a `GdkTexture`
A node drawing an inset shadow
A node drawing an outset shadow
A node that renders its child after applying a matrix transform
A node that changes the opacity of its child
A node that applies a color matrix to every pixel
A node that repeats the child's contents
A node that clips its child to a rectangular area
A node that clips its child to a rounded rectangle
A node that draws a shadow below its child
A node that blends two children together
A node that cross-fades between two children
A node containing a glyph string
A node that applies a blur
Debug information that does not affect the rendering
A node that uses OpenGL fragment shaders to render
A node drawing a `GdkTexture` scaled and filtered.
A node that masks one child with another.
A node that fills a path.
A node that strokes a path.
A node that possibly redirects part of the scene graph to a subsurface.
`GskRenderer` is a class that renders a scene graph defined via a
tree of [class@Gsk.RenderNode] instances.
Typically you will use a `GskRenderer` instance to repeatedly call
[method@Gsk.Renderer.render] to update the contents of its associated
[class@Gdk.Surface].
It is necessary to realize a `GskRenderer` instance using
[method@Gsk.Renderer.realize] before calling [method@Gsk.Renderer.render],
in order to create the appropriate windowing system resources needed
to render the scene.
Creates an appropriate `GskRenderer` instance for the given @surface.
If the `GSK_RENDERER` environment variable is set, GSK will
try that renderer first, before trying the backend-specific
default. The ultimate fallback is the cairo renderer.
The renderer will be realized before it is returned.
a `GskRenderer`
a `GdkSurface`
Retrieves the `GdkSurface` set using gsk_enderer_realize().
If the renderer has not been realized yet, %NULL will be returned.
a `GdkSurface`
a `GskRenderer`
Checks whether the @renderer is realized or not.
%TRUE if the `GskRenderer` was realized, and %FALSE otherwise
a `GskRenderer`
Creates the resources needed by the @renderer to render the scene
graph.
Since GTK 4.6, the surface may be `NULL`, which allows using
renderers without having to create a surface.
Since GTK 4.14, it is recommended to use [method@Gsk.Renderer.realize_for_display]
instead.
Note that it is mandatory to call [method@Gsk.Renderer.unrealize] before
destroying the renderer.
Whether the renderer was successfully realized
a `GskRenderer`
the `GdkSurface` renderer will be used on
Creates the resources needed by the @renderer to render the scene
graph.
Note that it is mandatory to call [method@Gsk.Renderer.unrealize] before
destroying the renderer.
Whether the renderer was successfully realized
a `GskRenderer`
the `GdkDisplay` renderer will be used on
Renders the scene graph, described by a tree of `GskRenderNode` instances
to the renderer's surface, ensuring that the given @region gets redrawn.
If the renderer has no associated surface, this function does nothing.
Renderers must ensure that changes of the contents given by the @root
node as well as the area given by @region are redrawn. They are however
free to not redraw any pixel outside of @region if they can guarantee that
it didn't change.
The @renderer will acquire a reference on the `GskRenderNode` tree while
the rendering is in progress.
a realized `GskRenderer`
a `GskRenderNode`
the `cairo_region_t` that must be redrawn or %NULL
for the whole window
Renders the scene graph, described by a tree of `GskRenderNode` instances,
to a `GdkTexture`.
The @renderer will acquire a reference on the `GskRenderNode` tree while
the rendering is in progress.
If you want to apply any transformations to @root, you should put it into a
transform node and pass that node instead.
a `GdkTexture` with the rendered contents of @root.
a realized `GskRenderer`
a `GskRenderNode`
the section to draw or %NULL to use @root's bounds
Releases all the resources created by gsk_renderer_realize().
a `GskRenderer`
Whether the renderer has been associated with a surface or draw context.
The surface associated with renderer.
A render node repeating its single child node.
Creates a `GskRenderNode` that will repeat the drawing of @child across
the given @bounds.
A new `GskRenderNode`
The bounds of the area to be painted
The child to repeat
The area of the child to repeat or %NULL to
use the child's bounds
Retrieves the child of @node.
a `GskRenderNode`
a repeat `GskRenderNode`
Retrieves the bounding rectangle of the child of @node.
a bounding rectangle
a repeat `GskRenderNode`
A render node for a repeating linear gradient.
Creates a `GskRenderNode` that will create a repeating linear gradient
from the given points and color stops, and render that into the area
given by @bounds.
A new `GskRenderNode`
the rectangle to render the linear gradient into
the point at which the linear gradient will begin
the point at which the linear gradient will finish
a pointer to an array of
`GskColorStop` defining the gradient. The offsets of all color stops
must be increasing. The first stop's offset must be >= 0 and the last
stop's offset must be <= 1.
the number of elements in @color_stops
A render node for a repeating radial gradient.
Creates a `GskRenderNode` that draws a repeating radial gradient.
The radial gradient starts around @center. The size of the gradient
is dictated by @hradius in horizontal orientation and by @vradius
in vertical orientation.
A new `GskRenderNode`
the bounds of the node
the center of the gradient
the horizontal radius
the vertical radius
a percentage >= 0 that defines the start of the gradient around @center
a percentage >= 0 that defines the end of the gradient around @center
a pointer to an array of
`GskColorStop` defining the gradient. The offsets of all color stops
must be increasing. The first stop's offset must be >= 0 and the last
stop's offset must be <= 1.
the number of elements in @color_stops
A render node applying a rounded rectangle clip to its single child.
Creates a `GskRenderNode` that will clip the @child to the area
given by @clip.
A new `GskRenderNode`
The node to draw
The clip to apply
Gets the child node that is getting clipped by the given @node.
The child that is getting clipped
a rounded clip `GskRenderNode`
Retrieves the rounded rectangle used to clip the contents of the @node.
a rounded rectangle
a rounded clip `GskRenderNode`
A rectangular region with rounded corners.
Application code should normalize rectangles using
[method@Gsk.RoundedRect.normalize]; this function will ensure that
the bounds of the rectangle are normalized and ensure that the corner
values are positive and the corners do not overlap.
All functions taking a `GskRoundedRect` as an argument will internally
operate on a normalized copy; all functions returning a `GskRoundedRect`
will always return a normalized one.
The algorithm used for normalizing corner sizes is described in
[the CSS specification](https://drafts.csswg.org/css-backgrounds-3/#border-radius).
the bounds of the rectangle
the size of the 4 rounded corners
Checks if the given @point is inside the rounded rectangle.
%TRUE if the @point is inside the rounded rectangle
a `GskRoundedRect`
the point to check
Checks if the given @rect is contained inside the rounded rectangle.
%TRUE if the @rect is fully contained inside the rounded rectangle
a `GskRoundedRect`
the rectangle to check
Initializes the given `GskRoundedRect` with the given values.
This function will implicitly normalize the `GskRoundedRect`
before returning.
the initialized rectangle
The `GskRoundedRect` to initialize
a `graphene_rect_t` describing the bounds
the rounding radius of the top left corner
the rounding radius of the top right corner
the rounding radius of the bottom right corner
the rounding radius of the bottom left corner
Initializes @self using the given @src rectangle.
This function will not normalize the `GskRoundedRect`,
so make sure the source is normalized.
the initialized rectangle
a `GskRoundedRect`
a `GskRoundedRect`
Initializes @self to the given @bounds and sets the radius
of all four corners to @radius.
the initialized rectangle
a `GskRoundedRect`
a `graphene_rect_t`
the border radius
Checks if part of the given @rect is contained inside the rounded rectangle.
%TRUE if the @rect intersects with the rounded rectangle
a `GskRoundedRect`
the rectangle to check
Checks if all corners of @self are right angles and the
rectangle covers all of its bounds.
This information can be used to decide if [ctor@Gsk.ClipNode.new]
or [ctor@Gsk.RoundedClipNode.new] should be called.
%TRUE if the rectangle is rectilinear
the `GskRoundedRect` to check
Normalizes the passed rectangle.
This function will ensure that the bounds of the rectangle
are normalized and ensure that the corner values are positive
and the corners do not overlap.
the normalized rectangle
a `GskRoundedRect`
Offsets the bound's origin by @dx and @dy.
The size and corners of the rectangle are unchanged.
the offset rectangle
a `GskRoundedRect`
the horizontal offset
the vertical offset
Shrinks (or grows) the given rectangle by moving the 4 sides
according to the offsets given.
The corner radii will be changed in a way that tries to keep
the center of the corner circle intact. This emulates CSS behavior.
This function also works for growing rectangles if you pass
negative values for the @top, @right, @bottom or @left.
the resized `GskRoundedRect`
The `GskRoundedRect` to shrink or grow
How far to move the top side downwards
How far to move the right side to the left
How far to move the bottom side upwards
How far to move the left side to the right
The filters used when scaling texture data.
The actual implementation of each filter is deferred to the
rendering pipeline.
linear interpolation filter
nearest neighbor interpolation filter
linear interpolation along each axis,
plus mipmap generation, with linear interpolation along the mipmap
levels
Errors that can happen during (de)serialization.
The format can not be identified
The version of the data is not
understood
The given data may not exist in
a proper serialization
Registers an error quark for [class@Gsk.RenderNode] errors.
the error quark
An object to build the uniforms data for a `GskGLShader`.
Allocates a builder that can be used to construct a new uniform data
chunk.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
The newly allocated builder, free with
[method@Gsk.ShaderArgsBuilder.unref]
a `GskGLShader`
optional `GBytes` with initial values
Creates a new `GBytes` args from the current state of the
given @builder, and frees the @builder instance.
Any uniforms of the shader that have not been explicitly set
on the @builder are zero-initialized.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
the newly allocated buffer with
all the args added to @builder
a `GskShaderArgsBuilder`
Increases the reference count of a `GskShaderArgsBuilder` by one.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
the passed in `GskShaderArgsBuilder`
a `GskShaderArgsBuilder`
Sets the value of the uniform @idx.
The uniform must be of bool type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskShaderArgsBuilder`
index of the uniform
value to set the uniform to
Sets the value of the uniform @idx.
The uniform must be of float type.
a `GskShaderArgsBuilder`
index of the uniform
value to set the uniform to
Sets the value of the uniform @idx.
The uniform must be of int type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskShaderArgsBuilder`
index of the uniform
value to set the uniform to
Sets the value of the uniform @idx.
The uniform must be of uint type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskShaderArgsBuilder`
index of the uniform
value to set the uniform to
Sets the value of the uniform @idx.
The uniform must be of vec2 type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
A `GskShaderArgsBuilder`
index of the uniform
value to set the uniform too
Sets the value of the uniform @idx.
The uniform must be of vec3 type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskShaderArgsBuilder`
index of the uniform
value to set the uniform too
Sets the value of the uniform @idx.
The uniform must be of vec4 type.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskShaderArgsBuilder`
index of the uniform
value to set the uniform too
Creates a new `GBytes` args from the current state of the
given @builder.
Any uniforms of the shader that have not been explicitly set on
the @builder are zero-initialized.
The given `GskShaderArgsBuilder` is reset once this function returns;
you cannot call this function multiple times on the same @builder instance.
This function is intended primarily for bindings. C code should use
[method@Gsk.ShaderArgsBuilder.free_to_args].
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
the newly allocated buffer with
all the args added to @builder
a `GskShaderArgsBuilder`
Decreases the reference count of a `GskShaderArgBuilder` by one.
If the resulting reference count is zero, frees the builder.
GTK's new Vulkan-focused rendering
does not support this feature. Use [GtkGLArea](../gtk4/class.GLArea.html)
for OpenGL rendering.
a `GskShaderArgsBuilder`
The shadow parameters in a shadow node.
the color of the shadow
the horizontal offset of the shadow
the vertical offset of the shadow
the radius of the shadow
A render node drawing one or more shadows behind its single child node.
Creates a `GskRenderNode` that will draw a @child with the given
@shadows below it.
A new `GskRenderNode`
The node to draw
The shadows to apply
number of entries in the @shadows array
Retrieves the child `GskRenderNode` of the shadow @node.
the child render node
a shadow `GskRenderNode`
Retrieves the number of shadows in the @node.
the number of shadows.
a shadow `GskRenderNode`
Retrieves the shadow data at the given index @i.
the shadow data
a shadow `GskRenderNode`
the given index
A `GskStroke` struct collects the parameters that influence
the operation of stroking a path.
Creates a new `GskStroke` with the given @line_width.
a new `GskStroke`
line width of the stroke. Must be > 0
Creates a copy of the given @other stroke.
a new `GskStroke`. Use [method@Gsk.Stroke.free] to free it
`GskStroke` to copy
Frees a `GskStroke`.
a `GskStroke`
Gets the dash array in use or `NULL` if dashing is disabled.
The dash array or `NULL` if the dash array is empty.
a `GskStroke`
number of elements in the array returned
Returns the dash_offset of a `GskStroke`.
the dash_offset
a `GskStroke`
Gets the line cap used.
See [enum@Gsk.LineCap] for details.
The line cap
a `GskStroke`
Gets the line join used.
See [enum@Gsk.LineJoin] for details.
The line join
a `GskStroke`
Gets the line width used.
The line width
a `GskStroke`
Returns the miter limit of a `GskStroke`.
the miter limit
a `GskStroke`
Sets the dash pattern to use by this stroke.
A dash pattern is specified by an array of alternating non-negative
values. Each value provides the length of alternate "on" and "off"
portions of the stroke.
Each "on" segment will have caps applied as if the segment were a
separate contour. In particular, it is valid to use an "on" length
of 0 with `GSK_LINE_CAP_ROUND` or `GSK_LINE_CAP_SQUARE` to draw dots
or squares along a path.
If @n_dash is 0, if all elements in @dash are 0, or if there are
negative values in @dash, then dashing is disabled.
If @n_dash is 1, an alternating "on" and "off" pattern with the
single dash length provided is assumed.
If @n_dash is uneven, the dash array will be used with the first
element in @dash defining an "on" or "off" in alternating passes
through the array.
You can specify a starting offset into the dash with
[method@Gsk.Stroke.set_dash_offset].
a `GskStroke`
the array of dashes
number of elements in @dash
Sets the offset into the dash pattern where dashing should begin.
This is an offset into the length of the path, not an index into
the array values of the dash array.
See [method@Gsk.Stroke.set_dash] for more details on dashing.
a `GskStroke`
offset into the dash pattern
Sets the line cap to be used when stroking.
See [enum@Gsk.LineCap] for details.
a`GskStroke`
the `GskLineCap`
Sets the line join to be used when stroking.
See [enum@Gsk.LineJoin] for details.
a `GskStroke`
The line join to use
Sets the line width to be used when stroking.
The line width must be > 0.
a `GskStroke`
width of the line in pixels
Sets the limit for the distance from the corner where sharp
turns of joins get cut off.
The miter limit is in units of line width and must be non-negative.
For joins of type `GSK_LINE_JOIN_MITER` that exceed the miter
limit, the join gets rendered as if it was of type
`GSK_LINE_JOIN_BEVEL`.
a `GskStroke`
the miter limit
A helper function that sets the stroke parameters
of @cr from the values found in @self.
a `GskStroke`
the cairo context to configure
Checks if 2 strokes are identical.
`TRUE` if the 2 strokes are equal, `FALSE` otherwise
the first `GskStroke`
the second `GskStroke`
A render node that will fill the area determined by stroking the the given
[struct@Gsk.Path] using the [struct@Gsk.Stroke] attributes.
Creates a #GskRenderNode that will fill the outline generated by stroking
the given @path using the attributes defined in @stroke.
The area is filled with @child.
A new #GskRenderNode
The node to stroke the area with
The path describing the area to stroke
The stroke attributes to use
Gets the child node that is getting drawn by the given @node.
The child that is getting drawn
a stroke #GskRenderNode
Retrieves the path that will be stroked with the contents of
the @node.
a #GskPath
a stroke #GskRenderNode
Retrieves the stroke attributes used in this @node.
a #GskStroke
a stroke #GskRenderNode
A render node that potentially diverts a part of the scene graph to a subsurface.
Creates a `GskRenderNode` that will possibly divert the child
node to a subsurface.
Note: Since subsurfaces are currently private, these nodes cannot
currently be created outside of GTK. See
[GtkGraphicsOffload](../gtk4/class.GraphicsOffload.html).
A new `GskRenderNode`
The child to divert to a subsurface
the subsurface to use
Gets the subsurface that was set on this node
the subsurface
a debug `GskRenderNode`
Gets the child node that is getting drawn by the given @node.
the child `GskRenderNode`
a debug `GskRenderNode`
A render node drawing a set of glyphs.
Creates a render node that renders the given glyphs.
Note that @color may not be used if the font contains
color glyphs.
a new `GskRenderNode`
the `PangoFont` containing the glyphs
the `PangoGlyphString` to render
the foreground color to render with
offset of the baseline
Retrieves the color used by the text @node.
the text color
a text `GskRenderNode`
Returns the font used by the text @node.
the font
The `GskRenderNode`
Retrieves the glyph information in the @node.
the glyph information
a text `GskRenderNode`
the number of glyphs returned
Retrieves the number of glyphs in the text node.
the number of glyphs
a text `GskRenderNode`
Retrieves the offset applied to the text.
a point with the horizontal and vertical offsets
a text `GskRenderNode`
Checks whether the text @node has color glyphs.
%TRUE if the text node has color glyphs
a text `GskRenderNode`
A render node for a `GdkTexture`.
Creates a `GskRenderNode` that will render the given
@texture into the area given by @bounds.
Note that GSK applies linear filtering when textures are
scaled and transformed. See [class@Gsk.TextureScaleNode]
for a way to influence filtering.
A new `GskRenderNode`
the `GdkTexture`
the rectangle to render the texture into
Retrieves the `GdkTexture` used when creating this `GskRenderNode`.
the `GdkTexture`
a `GskRenderNode` of type %GSK_TEXTURE_NODE
A render node for a `GdkTexture`.
Creates a node that scales the texture to the size given by the
bounds using the filter and then places it at the bounds' position.
Note that further scaling and other transformations which are
applied to the node will apply linear filtering to the resulting
texture, as usual.
This node is intended for tight control over scaling applied
to a texture, such as in image editors and requires the
application to be aware of the whole render tree as further
transforms may be applied that conflict with the desired effect
of this node.
A new `GskRenderNode`
the texture to scale
the size of the texture to scale to
how to scale the texture
Retrieves the `GskScalingFilter` used when creating this `GskRenderNode`.
the `GskScalingFilter`
a `GskRenderNode` of type %GSK_TEXTURE_SCALE_NODE
Retrieves the `GdkTexture` used when creating this `GskRenderNode`.
the `GdkTexture`
a `GskRenderNode` of type %GSK_TEXTURE_SCALE_NODE
`GskTransform` is an object to describe transform matrices.
Unlike `graphene_matrix_t`, `GskTransform` retains the steps in how
a transform was constructed, and allows inspecting them. It is modeled
after the way CSS describes transforms.
`GskTransform` objects are immutable and cannot be changed after creation.
This means code can safely expose them as properties of objects without
having to worry about others changing them.
Creates a new identity transform.
This function is meant to be used by language
bindings. For C code, this is equivalent to using %NULL.
A new identity transform
Checks two transforms for equality.
%TRUE if the two transforms perform the same operation
the first transform
the second transform
Returns the category this transform belongs to.
The category of the transform
A `GskTransform`
Inverts the given transform.
If @self is not invertible, %NULL is returned.
Note that inverting %NULL also returns %NULL, which is
the correct inverse of %NULL. If you need to differentiate
between those cases, you should check @self is not %NULL
before calling this function.
This function consumes @self. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The inverted transform
Transform to invert
Multiplies @next with the given @matrix.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
the matrix to multiply @next with
Applies a perspective projection transform.
This transform scales points in X and Y based on their Z value,
scaling points with positive Z values away from the origin, and
those with negative Z values towards the origin. Points
on the z=0 plane are unchanged.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
distance of the z=0 plane. Lower values give a more
flattened pyramid and therefore a more pronounced
perspective effect.
Converts @self into a human-readable string representation suitable
for printing.
The result of this function can later be parsed with
[func@Gsk.Transform.parse].
a `GskTransform`
The string to print into
Acquires a reference on the given `GskTransform`.
the `GskTransform` with an additional reference
a `GskTransform`
Rotates @next @angle degrees in 2D - or in 3D-speak, around the Z axis.
The rotation happens around the origin point of (0, 0).
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
the rotation angle, in degrees (clockwise)
Rotates @next @angle degrees around @axis.
For a rotation in 2D space, use [method@Gsk.Transform.rotate]
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
the rotation angle, in degrees (clockwise)
The rotation axis
Scales @next in 2-dimensional space by the given factors.
Use [method@Gsk.Transform.scale_3d] to scale in all 3 dimensions.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
scaling factor on the X axis
scaling factor on the Y axis
Scales @next by the given factors.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
scaling factor on the X axis
scaling factor on the Y axis
scaling factor on the Z axis
Applies a skew transform.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
skew factor, in degrees, on the X axis
skew factor, in degrees, on the Y axis
Converts a `GskTransform` to a 2D transformation matrix.
@self must be a 2D transformation. If you are not
sure, use gsk_transform_get_category() >=
%GSK_TRANSFORM_CATEGORY_2D to check.
The returned values have the following layout:
```
| xx yx | | a b 0 |
| xy yy | = | c d 0 |
| dx dy | | tx ty 1 |
```
This function can be used to convert between a `GskTransform`
and a matrix type from other 2D drawing libraries, in particular
Cairo.
a 2D `GskTransform`
return location for the xx member
return location for the yx member
return location for the xy member
return location for the yy member
return location for the x0 member
return location for the y0 member
Converts a `GskTransform` to 2D transformation factors.
To recreate an equivalent transform from the factors returned
by this function, use
gsk_transform_skew (
gsk_transform_scale (
gsk_transform_rotate (
gsk_transform_translate (NULL, &GRAPHENE_POINT_T (dx, dy)),
angle),
scale_x, scale_y),
skew_x, skew_y)
@self must be a 2D transformation. If you are not sure, use
gsk_transform_get_category() >= %GSK_TRANSFORM_CATEGORY_2D
to check.
a `GskTransform`
return location for the skew factor
in the x direction
return location for the skew factor
in the y direction
return location for the scale
factor in the x direction
return location for the scale
factor in the y direction
return location for the rotation angle
return location for the translation
in the x direction
return location for the translation
in the y direction
Converts a `GskTransform` to 2D affine transformation factors.
To recreate an equivalent transform from the factors returned
by this function, use
gsk_transform_scale (gsk_transform_translate (NULL,
&GRAPHENE_POINT_T (dx, dy)),
sx, sy)
@self must be a 2D affine transformation. If you are not
sure, use
gsk_transform_get_category() >= %GSK_TRANSFORM_CATEGORY_2D_AFFINE
to check.
a `GskTransform`
return location for the scale
factor in the x direction
return location for the scale
factor in the y direction
return location for the translation
in the x direction
return location for the translation
in the y direction
Computes the actual value of @self and stores it in @out_matrix.
The previous value of @out_matrix will be ignored.
a `GskTransform`
The matrix to set
Converts a matrix into a string that is suitable for printing.
The resulting string can be parsed with [func@Gsk.Transform.parse].
This is a wrapper around [method@Gsk.Transform.print].
A new string for @self
a `GskTransform`
Converts a `GskTransform` to a translation operation.
@self must be a 2D transformation. If you are not
sure, use
gsk_transform_get_category() >= %GSK_TRANSFORM_CATEGORY_2D_TRANSLATE
to check.
a `GskTransform`
return location for the translation
in the x direction
return location for the translation
in the y direction
Applies all the operations from @other to @next.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
Transform to apply @other to
Transform to apply
Transforms a `graphene_rect_t` using the given transform @self.
The result is the bounding box containing the coplanar quad.
a `GskTransform`
a `graphene_rect_t`
return location for the bounds
of the transformed rectangle
Transforms a `graphene_point_t` using the given transform @self.
a `GskTransform`
a `graphene_point_t`
return location for
the transformed point
Translates @next in 2-dimensional space by @point.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
the point to translate the transform by
Translates @next by @point.
This function consumes @next. Use [method@Gsk.Transform.ref] first
if you want to keep it around.
The new transform
the next transform
the point to translate the transform by
Releases a reference on the given `GskTransform`.
If the reference was the last, the resources associated to the @self are
freed.
a `GskTransform`
Parses the given @string into a transform and puts it in
@out_transform.
Strings printed via [method@Gsk.Transform.to_string]
can be read in again successfully using this function.
If @string does not describe a valid transform, %FALSE is
returned and %NULL is put in @out_transform.
%TRUE if @string described a valid transform.
the string to parse
The location to put the transform in
The categories of matrices relevant for GSK and GTK.
Note that any category includes matrices of all later categories.
So if you want to for example check if a matrix is a 2D matrix,
`category >= GSK_TRANSFORM_CATEGORY_2D` is the way to do this.
Also keep in mind that rounding errors may cause matrices to not
conform to their categories. Otherwise, matrix operations done via
multiplication will not worsen categories. So for the matrix
multiplication `C = A * B`, `category(C) = MIN (category(A), category(B))`.
The category of the matrix has not been
determined.
Analyzing the matrix concluded that it does
not fit in any other category.
The matrix is a 3D matrix. This means that
the w column (the last column) has the values (0, 0, 0, 1).
The matrix is a 2D matrix. This is equivalent
to graphene_matrix_is_2d() returning %TRUE. In particular, this
means that Cairo can deal with the matrix.
The matrix is a combination of 2D scale
and 2D translation operations. In particular, this means that any
rectangle can be transformed exactly using this matrix.
The matrix is a 2D translation.
The matrix is the identity matrix.
A render node applying a `GskTransform` to its single child node.
Creates a `GskRenderNode` that will transform the given @child
with the given @transform.
A new `GskRenderNode`
The node to transform
The transform to apply
Gets the child node that is getting transformed by the given @node.
The child that is getting transformed
a `GskRenderNode` for a transform
Retrieves the `GskTransform` used by the @node.
a `GskTransform`
a `GskRenderNode` for a transform
Evaluates to %TRUE if @value was initialized with %GSK_TYPE_RENDER_NODE.
a `GValue`
A GSK renderer that is using Vulkan.
This renderer will fail to realize if Vulkan is not supported.
Creates a new Vulkan renderer.
The Vulkan renderer is a renderer that uses the Vulkan library for
rendering.
This renderer will fail to realize when GTK was not compiled with
Vulkan support.
a new Vulkan renderer
This is a convenience function that constructs a `GskPath`
from a serialized form.
The string is expected to be in (a superset of)
[SVG path syntax](https://www.w3.org/TR/SVG11/paths.html#PathData),
as e.g. produced by [method@Gsk.Path.to_string].
A high-level summary of the syntax:
- `M x y` Move to `(x, y)`
- `L x y` Add a line from the current point to `(x, y)`
- `Q x1 y1 x2 y2` Add a quadratic Bézier from the current point to `(x2, y2)`, with control point `(x1, y1)`
- `C x1 y1 x2 y2 x3 y3` Add a cubic Bézier from the current point to `(x3, y3)`, with control points `(x1, y1)` and `(x2, y2)`
- `Z` Close the contour by drawing a line back to the start point
- `H x` Add a horizontal line from the current point to the given x value
- `V y` Add a vertical line from the current point to the given y value
- `T x2 y2` Add a quadratic Bézier, using the reflection of the previous segments' control point as control point
- `S x2 y2 x3 y3` Add a cubic Bézier, using the reflection of the previous segments' second control point as first control point
- `A rx ry r l s x y` Add an elliptical arc from the current point to `(x, y)` with radii rx and ry. See the SVG documentation for how the other parameters influence the arc.
- `O x1 y1 x2 y2 w` Add a rational quadratic Bézier from the current point to `(x2, y2)` with control point `(x1, y1)` and weight `w`.
All the commands have lowercase variants that interpret coordinates
relative to the current point.
The `O` command is an extension that is not supported in SVG.
a new `GskPath`, or `NULL` if @string could not be parsed
a string
Registers an error quark for [class@Gsk.RenderNode] errors.
the error quark
Checks if 2 strokes are identical.
`TRUE` if the 2 strokes are equal, `FALSE` otherwise
the first `GskStroke`
the second `GskStroke`
Parses the given @string into a transform and puts it in
@out_transform.
Strings printed via [method@Gsk.Transform.to_string]
can be read in again successfully using this function.
If @string does not describe a valid transform, %FALSE is
returned and %NULL is put in @out_transform.
%TRUE if @string described a valid transform.
the string to parse
The location to put the transform in
Retrieves the `GskRenderNode` stored inside the given `value`, and acquires
a reference to it.
a `GskRenderNode`
a [struct@GObject.Value] initialized with type `GSK_TYPE_RENDER_NODE`
Retrieves the `GskRenderNode` stored inside the given `value`.
a `GskRenderNode`
a `GValue` initialized with type `GSK_TYPE_RENDER_NODE`
Stores the given `GskRenderNode` inside `value`.
The [struct@GObject.Value] will acquire a reference to the `node`.
a [struct@GObject.Value] initialized with type `GSK_TYPE_RENDER_NODE`
a `GskRenderNode`
Stores the given `GskRenderNode` inside `value`.
This function transfers the ownership of the `node` to the `GValue`.
a [struct@GObject.Value] initialized with type `GSK_TYPE_RENDER_NODE`
a `GskRenderNode`