Documentation ¶
Index ¶
- Variables
- func SerializationErrorQuark() glib.Quark
- type BlendMode
- type BlendNode
- type BlurNode
- type BorderNode
- type CairoNode
- type CairoRenderer
- type ClipNode
- type ColorMatrixNode
- type ColorNode
- type ColorStop
- type ConicGradientNode
- type ContainerNode
- type Corner
- type CrossFadeNode
- type DebugNode
- type GLShader
- func (shader *GLShader) ArgBool(args *glib.Bytes, idx int) bool
- func (shader *GLShader) ArgFloat(args *glib.Bytes, idx int) float32
- func (shader *GLShader) ArgInt(args *glib.Bytes, idx int) int32
- func (shader *GLShader) ArgUint(args *glib.Bytes, idx int) uint32
- func (shader *GLShader) ArgVec2(args *glib.Bytes, idx int, outValue *graphene.Vec2)
- func (shader *GLShader) ArgVec3(args *glib.Bytes, idx int, outValue *graphene.Vec3)
- func (shader *GLShader) ArgVec4(args *glib.Bytes, idx int, outValue *graphene.Vec4)
- func (shader *GLShader) ArgsSize() uint
- func (shader *GLShader) Compile(renderer Rendererer) error
- func (shader *GLShader) FindUniformByName(name string) int
- func (shader *GLShader) NTextures() int
- func (shader *GLShader) NUniforms() int
- func (shader *GLShader) Resource() string
- func (shader *GLShader) Source() *glib.Bytes
- func (shader *GLShader) UniformName(idx int) string
- func (shader *GLShader) UniformOffset(idx int) int
- func (shader *GLShader) UniformType(idx int) GLUniformType
- type GLShaderClass
- type GLShaderNode
- type GLShaderOverrides
- type GLUniformType
- type InsetShadowNode
- type LinearGradientNode
- type OpacityNode
- type OutsetShadowNode
- type ParseErrorFunc
- type ParseLocation
- func (p *ParseLocation) Bytes() uint
- func (p *ParseLocation) Chars() uint
- func (p *ParseLocation) LineBytes() uint
- func (p *ParseLocation) LineChars() uint
- func (p *ParseLocation) Lines() uint
- func (p *ParseLocation) SetBytes(bytes uint)
- func (p *ParseLocation) SetChars(chars uint)
- func (p *ParseLocation) SetLineBytes(lineBytes uint)
- func (p *ParseLocation) SetLineChars(lineChars uint)
- func (p *ParseLocation) SetLines(lines uint)
- type RadialGradientNode
- func (node *RadialGradientNode) Center() *graphene.Point
- func (node *RadialGradientNode) ColorStops() []ColorStop
- func (node *RadialGradientNode) End() float32
- func (node *RadialGradientNode) Hradius() float32
- func (node *RadialGradientNode) NColorStops() uint
- func (node *RadialGradientNode) Start() float32
- func (node *RadialGradientNode) Vradius() float32
- type RenderNode
- type RenderNodeType
- type RenderNoder
- type Renderer
- func (renderer *Renderer) IsRealized() bool
- func (renderer *Renderer) Realize(surface gdk.Surfacer) error
- func (renderer *Renderer) Render(root RenderNoder, region *cairo.Region)
- func (renderer *Renderer) RenderTexture(root RenderNoder, viewport *graphene.Rect) gdk.Texturer
- func (renderer *Renderer) Surface() gdk.Surfacer
- func (renderer *Renderer) Unrealize()
- type Rendererer
- type RepeatNode
- type RepeatingLinearGradientNode
- type RepeatingRadialGradientNode
- type RoundedClipNode
- type RoundedRect
- func (r *RoundedRect) Bounds() *graphene.Rect
- func (self *RoundedRect) ContainsPoint(point *graphene.Point) bool
- func (self *RoundedRect) ContainsRect(rect *graphene.Rect) bool
- func (r *RoundedRect) Corner() [4]graphene.Size
- func (self *RoundedRect) Init(bounds *graphene.Rect, topLeft *graphene.Size, topRight *graphene.Size, ...) *RoundedRect
- func (self *RoundedRect) InitCopy(src *RoundedRect) *RoundedRect
- func (self *RoundedRect) InitFromRect(bounds *graphene.Rect, radius float32) *RoundedRect
- func (self *RoundedRect) IntersectsRect(rect *graphene.Rect) bool
- func (self *RoundedRect) IsRectilinear() bool
- func (self *RoundedRect) Normalize() *RoundedRect
- func (self *RoundedRect) Offset(dx float32, dy float32) *RoundedRect
- func (self *RoundedRect) Shrink(top float32, right float32, bottom float32, left float32) *RoundedRect
- type ScalingFilter
- type SerializationError
- type ShaderArgsBuilder
- func (builder *ShaderArgsBuilder) SetBool(idx int, value bool)
- func (builder *ShaderArgsBuilder) SetFloat(idx int, value float32)
- func (builder *ShaderArgsBuilder) SetInt(idx int, value int32)
- func (builder *ShaderArgsBuilder) SetUint(idx int, value uint32)
- func (builder *ShaderArgsBuilder) SetVec2(idx int, value *graphene.Vec2)
- func (builder *ShaderArgsBuilder) SetVec3(idx int, value *graphene.Vec3)
- func (builder *ShaderArgsBuilder) SetVec4(idx int, value *graphene.Vec4)
- func (builder *ShaderArgsBuilder) ToArgs() *glib.Bytes
- type Shadow
- type ShadowNode
- type TextNode
- type TextureNode
- type Transform
- func (self *Transform) Category() TransformCategory
- func (first *Transform) Equal(second *Transform) bool
- func (self *Transform) Invert() *Transform
- func (next *Transform) Matrix(matrix *graphene.Matrix) *Transform
- func (next *Transform) Perspective(depth float32) *Transform
- func (next *Transform) Rotate(angle float32) *Transform
- func (next *Transform) Rotate3D(angle float32, axis *graphene.Vec3) *Transform
- func (next *Transform) Scale(factorX float32, factorY float32) *Transform
- func (next *Transform) Scale3D(factorX float32, factorY float32, factorZ float32) *Transform
- func (self *Transform) String() string
- func (self *Transform) To2D() (outXx float32, outYx float32, outXy float32, outYy float32, outDx float32, ...)
- func (self *Transform) ToAffine() (outScaleX float32, outScaleY float32, outDx float32, outDy float32)
- func (self *Transform) ToMatrix() *graphene.Matrix
- func (self *Transform) ToTranslate() (outDx float32, outDy float32)
- func (next *Transform) Transform(other *Transform) *Transform
- func (self *Transform) TransformBounds(rect *graphene.Rect) *graphene.Rect
- func (self *Transform) TransformPoint(point *graphene.Point) *graphene.Point
- func (next *Transform) Translate(point *graphene.Point) *Transform
- func (next *Transform) Translate3D(point *graphene.Point3D) *Transform
- type TransformCategory
- type TransformNode
Constants ¶
This section is empty.
Variables ¶
var ( GTypeBlendMode = coreglib.Type(C.gsk_blend_mode_get_type()) GTypeCorner = coreglib.Type(C.gsk_corner_get_type()) GTypeGLUniformType = coreglib.Type(C.gsk_gl_uniform_type_get_type()) GTypeRenderNodeType = coreglib.Type(C.gsk_render_node_type_get_type()) GTypeScalingFilter = coreglib.Type(C.gsk_scaling_filter_get_type()) GTypeSerializationError = coreglib.Type(C.gsk_serialization_error_get_type()) GTypeTransformCategory = coreglib.Type(C.gsk_transform_category_get_type()) GTypeBlendNode = coreglib.Type(C.gsk_blend_node_get_type()) GTypeBlurNode = coreglib.Type(C.gsk_blur_node_get_type()) GTypeBorderNode = coreglib.Type(C.gsk_border_node_get_type()) GTypeCairoNode = coreglib.Type(C.gsk_cairo_node_get_type()) GTypeCairoRenderer = coreglib.Type(C.gsk_cairo_renderer_get_type()) GTypeClipNode = coreglib.Type(C.gsk_clip_node_get_type()) GTypeColorMatrixNode = coreglib.Type(C.gsk_color_matrix_node_get_type()) GTypeColorNode = coreglib.Type(C.gsk_color_node_get_type()) GTypeConicGradientNode = coreglib.Type(C.gsk_conic_gradient_node_get_type()) GTypeContainerNode = coreglib.Type(C.gsk_container_node_get_type()) GTypeCrossFadeNode = coreglib.Type(C.gsk_cross_fade_node_get_type()) GTypeDebugNode = coreglib.Type(C.gsk_debug_node_get_type()) GTypeGLShader = coreglib.Type(C.gsk_gl_shader_get_type()) GTypeGLShaderNode = coreglib.Type(C.gsk_gl_shader_node_get_type()) GTypeInsetShadowNode = coreglib.Type(C.gsk_inset_shadow_node_get_type()) GTypeLinearGradientNode = coreglib.Type(C.gsk_linear_gradient_node_get_type()) GTypeOpacityNode = coreglib.Type(C.gsk_opacity_node_get_type()) GTypeOutsetShadowNode = coreglib.Type(C.gsk_outset_shadow_node_get_type()) GTypeRadialGradientNode = coreglib.Type(C.gsk_radial_gradient_node_get_type()) GTypeRenderNode = coreglib.Type(C.gsk_render_node_get_type()) GTypeRenderer = coreglib.Type(C.gsk_renderer_get_type()) GTypeRepeatNode = coreglib.Type(C.gsk_repeat_node_get_type()) GTypeRepeatingLinearGradientNode = coreglib.Type(C.gsk_repeating_linear_gradient_node_get_type()) GTypeRepeatingRadialGradientNode = coreglib.Type(C.gsk_repeating_radial_gradient_node_get_type()) GTypeRoundedClipNode = coreglib.Type(C.gsk_rounded_clip_node_get_type()) GTypeShadowNode = coreglib.Type(C.gsk_shadow_node_get_type()) GTypeTextNode = coreglib.Type(C.gsk_text_node_get_type()) GTypeTextureNode = coreglib.Type(C.gsk_texture_node_get_type()) GTypeTransformNode = coreglib.Type(C.gsk_transform_node_get_type()) GTypeShaderArgsBuilder = coreglib.Type(C.gsk_shader_args_builder_get_type()) GTypeTransform = coreglib.Type(C.gsk_transform_get_type()) )
GType values.
Functions ¶
func SerializationErrorQuark ¶
func SerializationErrorQuark() glib.Quark
The function returns the following values:
Types ¶
type BlendMode ¶
BlendMode: 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.
const ( // BlendModeDefault: default blend mode, which specifies no blending. BlendModeDefault BlendMode = iota // BlendModeMultiply: source color is multiplied by the destination and // replaces the destination. BlendModeMultiply // BlendModeScreen multiplies the complements of the destination and source // color values, then complements the result. BlendModeScreen // BlendModeOverlay multiplies or screens the colors, depending on the // destination color value. This is the inverse of hard-list. BlendModeOverlay // BlendModeDarken selects the darker of the destination and source colors. BlendModeDarken // BlendModeLighten selects the lighter of the destination and source // colors. BlendModeLighten // BlendModeColorDodge brightens the destination color to reflect the source // color. BlendModeColorDodge // BlendModeColorBurn darkens the destination color to reflect the source // color. BlendModeColorBurn // BlendModeHardLight multiplies or screens the colors, depending on the // source color value. BlendModeHardLight // BlendModeSoftLight darkens or lightens the colors, depending on the // source color value. BlendModeSoftLight // BlendModeDifference subtracts the darker of the two constituent colors // from the lighter color. BlendModeDifference // BlendModeExclusion produces an effect similar to that of the difference // mode but lower in contrast. BlendModeExclusion // BlendModeColor creates a color with the hue and saturation of the source // color and the luminosity of the destination color. BlendModeColor // BlendModeHue creates a color with the hue of the source color and the // saturation and luminosity of the destination color. BlendModeHue // BlendModeSaturation creates a color with the saturation of the source // color and the hue and luminosity of the destination color. BlendModeSaturation // BlendModeLuminosity creates a color with the luminosity of the source // color and the hue and saturation of the destination color. BlendModeLuminosity )
type BlendNode ¶
type BlendNode struct { RenderNode // contains filtered or unexported fields }
BlendNode: render node applying a blending function between its two child nodes.
func NewBlendNode ¶
func NewBlendNode(bottom, top RenderNoder, blendMode BlendMode) *BlendNode
NewBlendNode creates a GskRenderNode that will use blend_mode to blend the top node onto the bottom node.
The function takes the following parameters:
- bottom node to be drawn.
- top: node to be blended onto the bottom node.
- blendMode: blend mode to use.
The function returns the following values:
- blendNode: new GskRenderNode.
func (*BlendNode) BlendMode ¶
BlendMode retrieves the blend mode used by node.
The function returns the following values:
- blendMode: blend mode.
func (*BlendNode) BottomChild ¶
func (node *BlendNode) BottomChild() RenderNoder
BottomChild retrieves the bottom GskRenderNode child of the node.
The function returns the following values:
- renderNode: bottom child node.
func (*BlendNode) TopChild ¶
func (node *BlendNode) TopChild() RenderNoder
TopChild retrieves the top GskRenderNode child of the node.
The function returns the following values:
- renderNode: top child node.
type BlurNode ¶
type BlurNode struct { RenderNode // contains filtered or unexported fields }
BlurNode: render node applying a blur effect to its single child.
func NewBlurNode ¶
func NewBlurNode(child RenderNoder, radius float32) *BlurNode
NewBlurNode creates a render node that blurs the child.
The function takes the following parameters:
- child node to blur.
- radius: blur radius.
The function returns the following values:
- blurNode: new GskRenderNode.
func (*BlurNode) Child ¶
func (node *BlurNode) Child() RenderNoder
Child retrieves the child GskRenderNode of the blur node.
The function returns the following values:
- renderNode: blurred child node.
type BorderNode ¶
type BorderNode struct { RenderNode // contains filtered or unexported fields }
BorderNode: render node for a border.
func NewBorderNode ¶
func NewBorderNode(outline *RoundedRect, borderWidth [4]float32, borderColor [4]gdk.RGBA) *BorderNode
NewBorderNode 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.
The function takes the following parameters:
- outline describing the outline of the border.
- borderWidth: stroke width of the border on the top, right, bottom and left side respectively.
- borderColor: color used on the top, right, bottom and left side.
The function returns the following values:
- borderNode: new GskRenderNode.
func (*BorderNode) Colors ¶
func (node *BorderNode) Colors() *gdk.RGBA
Colors retrieves the colors of the border.
The function returns the following values:
- rgbA: array of 4 RGBA structs for the top, right, bottom and left color of the border.
func (*BorderNode) Outline ¶
func (node *BorderNode) Outline() *RoundedRect
Outline retrieves the outline of the border.
The function returns the following values:
- roundedRect: outline of the border.
func (*BorderNode) Widths ¶
func (node *BorderNode) Widths() [4]float32
Widths retrieves the stroke widths of the border.
The function returns the following values:
- gfloats: array of 4 floats for the top, right, bottom and left stroke width of the border, respectively.
type CairoNode ¶
type CairoNode struct { RenderNode // contains filtered or unexported fields }
CairoNode: render node for a Cairo surface.
func NewCairoNode ¶
NewCairoNode creates a GskRenderNode that will render a cairo surface into the area given by bounds.
You can draw to the cairo surface using gsk.CairoNode.GetDrawContext().
The function takes the following parameters:
- bounds: rectangle to render to.
The function returns the following values:
- cairoNode: new GskRenderNode.
func (*CairoNode) DrawContext ¶
DrawContext 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.
The function returns the following values:
- context: cairo context used for drawing; use cairo_destroy() when done drawing.
type CairoRenderer ¶
type CairoRenderer struct { Renderer // contains filtered or unexported fields }
CairoRenderer: GSK renderer that is using cairo.
Since it is using cairo, this renderer cannot support 3D transformations.
func NewCairoRenderer ¶
func NewCairoRenderer() *CairoRenderer
NewCairoRenderer 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.
The function returns the following values:
- cairoRenderer: new Cairo renderer.
type ClipNode ¶
type ClipNode struct { RenderNode // contains filtered or unexported fields }
ClipNode: render node applying a rectangular clip to its single child node.
func NewClipNode ¶
func NewClipNode(child RenderNoder, clip *graphene.Rect) *ClipNode
NewClipNode creates a GskRenderNode that will clip the child to the area given by clip.
The function takes the following parameters:
- child: node to draw.
- clip to apply.
The function returns the following values:
- clipNode: new GskRenderNode.
func (*ClipNode) Child ¶
func (node *ClipNode) Child() RenderNoder
Child gets the child node that is getting clipped by the given node.
The function returns the following values:
- renderNode: child that is getting clipped.
type ColorMatrixNode ¶
type ColorMatrixNode struct { RenderNode // contains filtered or unexported fields }
ColorMatrixNode: render node controlling the color matrix of its single child node.
func NewColorMatrixNode ¶
func NewColorMatrixNode(child RenderNoder, colorMatrix *graphene.Matrix, colorOffset *graphene.Vec4) *ColorMatrixNode
NewColorMatrixNode creates a GskRenderNode that will drawn the child with color_matrix.
In particular, the node will transform the operation
pixel = color_matrix * pixel + color_offset
for every pixel.
The function takes the following parameters:
- child: node to draw.
- colorMatrix: matrix to apply.
- colorOffset values to add to the color.
The function returns the following values:
- colorMatrixNode: new GskRenderNode.
func (*ColorMatrixNode) Child ¶
func (node *ColorMatrixNode) Child() RenderNoder
Child gets the child node that is getting its colors modified by the given node.
The function returns the following values:
- renderNode: child that is getting its colors modified.
func (*ColorMatrixNode) ColorMatrix ¶
func (node *ColorMatrixNode) ColorMatrix() *graphene.Matrix
ColorMatrix retrieves the color matrix used by the node.
The function returns the following values:
- matrix: 4x4 color matrix.
func (*ColorMatrixNode) ColorOffset ¶
func (node *ColorMatrixNode) ColorOffset() *graphene.Vec4
ColorOffset retrieves the color offset used by the node.
The function returns the following values:
- vec4: color vector.
type ColorNode ¶
type ColorNode struct { RenderNode // contains filtered or unexported fields }
ColorNode: render node for a solid color.
func NewColorNode ¶
NewColorNode creates a GskRenderNode that will render the color specified by rgba into the area given by bounds.
The function takes the following parameters:
- rgba: GdkRGBA specifying a color.
- bounds: rectangle to render the color into.
The function returns the following values:
- colorNode: new GskRenderNode.
type ColorStop ¶
type ColorStop struct {
// contains filtered or unexported fields
}
ColorStop: color stop in a gradient node.
An instance of this type is always passed by reference.
type ConicGradientNode ¶
type ConicGradientNode struct { RenderNode // contains filtered or unexported fields }
ConicGradientNode: render node for a conic gradient.
func NewConicGradientNode ¶
func NewConicGradientNode(bounds *graphene.Rect, center *graphene.Point, rotation float32, colorStops []ColorStop) *ConicGradientNode
NewConicGradientNode 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.
The function takes the following parameters:
- bounds of the node.
- center of the gradient.
- rotation of the gradient in degrees.
- colorStops: 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 function returns the following values:
- conicGradientNode: new GskRenderNode.
func (*ConicGradientNode) Angle ¶
func (node *ConicGradientNode) Angle() float32
Angle 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 function returns the following values:
- gfloat: angle for the gradient.
func (*ConicGradientNode) Center ¶
func (node *ConicGradientNode) Center() *graphene.Point
Center retrieves the center pointer for the gradient.
The function returns the following values:
- point: center point for the gradient.
func (*ConicGradientNode) ColorStops ¶
func (node *ConicGradientNode) ColorStops() []ColorStop
ColorStops retrieves the color stops in the gradient.
The function returns the following values:
- colorStops: color stops in the gradient.
func (*ConicGradientNode) NColorStops ¶
func (node *ConicGradientNode) NColorStops() uint
NColorStops retrieves the number of color stops in the gradient.
The function returns the following values:
- gsize: number of color stops.
func (*ConicGradientNode) Rotation ¶
func (node *ConicGradientNode) Rotation() float32
Rotation retrieves the rotation for the gradient in degrees.
The function returns the following values:
- gfloat: rotation for the gradient.
type ContainerNode ¶
type ContainerNode struct { RenderNode // contains filtered or unexported fields }
ContainerNode: render node that can contain other render nodes.
func NewContainerNode ¶
func NewContainerNode(children []RenderNoder) *ContainerNode
NewContainerNode creates a new GskRenderNode instance for holding the given children.
The new node will acquire a reference to each of the children.
The function takes the following parameters:
- children of the node.
The function returns the following values:
- containerNode: new GskRenderNode.
func (*ContainerNode) Child ¶
func (node *ContainerNode) Child(idx uint) RenderNoder
Child gets one of the children of container.
The function takes the following parameters:
- idx: position of the child to get.
The function returns the following values:
- renderNode: idx'th child of container.
func (*ContainerNode) NChildren ¶
func (node *ContainerNode) NChildren() uint
NChildren retrieves the number of direct children of node.
The function returns the following values:
- guint: number of children of the GskRenderNode.
type CrossFadeNode ¶
type CrossFadeNode struct { RenderNode // contains filtered or unexported fields }
CrossFadeNode: render node cross fading between two child nodes.
func NewCrossFadeNode ¶
func NewCrossFadeNode(start, end RenderNoder, progress float32) *CrossFadeNode
NewCrossFadeNode creates a GskRenderNode that will do a cross-fade between start and end.
The function takes the following parameters:
- start node to be drawn.
- end: node to be cross_fadeed onto the start node.
- progress: how far the fade has progressed from start to end. The value will be clamped to the range [0 ... 1].
The function returns the following values:
- crossFadeNode: new GskRenderNode.
func (*CrossFadeNode) EndChild ¶
func (node *CrossFadeNode) EndChild() RenderNoder
EndChild retrieves the child GskRenderNode at the end of the cross-fade.
The function returns the following values:
- renderNode: GskRenderNode.
func (*CrossFadeNode) Progress ¶
func (node *CrossFadeNode) Progress() float32
Progress retrieves the progress value of the cross fade.
The function returns the following values:
- gfloat progress value, between 0 and 1.
func (*CrossFadeNode) StartChild ¶
func (node *CrossFadeNode) StartChild() RenderNoder
StartChild retrieves the child GskRenderNode at the beginning of the cross-fade.
The function returns the following values:
- renderNode: GskRenderNode.
type DebugNode ¶
type DebugNode struct { RenderNode // contains filtered or unexported fields }
DebugNode: render node that emits a debugging message when drawing its child node.
func NewDebugNode ¶
func NewDebugNode(child RenderNoder, message string) *DebugNode
NewDebugNode creates a GskRenderNode that will add debug information about the given child.
Adding this node has no visual effect.
The function takes the following parameters:
- child to add debug info for.
- message: debug message.
The function returns the following values:
- debugNode: new GskRenderNode.
func (*DebugNode) Child ¶
func (node *DebugNode) Child() RenderNoder
Child gets the child node that is getting drawn by the given node.
The function returns the following values:
- renderNode: child GskRenderNode.
type GLShader ¶
GLShader: 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 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:
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:
uniform float u_time; uniform vec3 u_color; uniform sampler2D u_texture1; uniform sampler2D u_texture2;
GTK uses the 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:
vec4 GskTexture(sampler2D sampler, vec2 texCoords);
This samples a texture (e.g. u_texture1) at the specified coordinates, and containes some helper ifdefs to ensure that it works on all OpenGL versions.
You can compile the shader yourself using 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
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; }.
func NewGLShaderFromBytes ¶
func NewGLShaderFromBytes(sourcecode *glib.Bytes) *GLShader
NewGLShaderFromBytes creates a GskGLShader that will render pixels using the specified code.
The function takes the following parameters:
- sourcecode: GLSL sourcecode for the shader, as a GBytes.
The function returns the following values:
- glShader: new GskGLShader.
func NewGLShaderFromResource ¶
NewGLShaderFromResource creates a GskGLShader that will render pixels using the specified code.
The function takes the following parameters:
- resourcePath: path to a resource that contains the GLSL sourcecode for the shader.
The function returns the following values:
- glShader: new GskGLShader.
func (*GLShader) ArgBool ¶
ArgBool gets the value of the uniform idx in the args block.
The uniform must be of bool type.
The function takes the following parameters:
- args: uniform arguments.
- idx: index of the uniform.
The function returns the following values:
- ok: value.
func (*GLShader) ArgFloat ¶
ArgFloat gets the value of the uniform idx in the args block.
The uniform must be of float type.
The function takes the following parameters:
- args: uniform arguments.
- idx: index of the uniform.
The function returns the following values:
- gfloat: value.
func (*GLShader) ArgInt ¶
ArgInt gets the value of the uniform idx in the args block.
The uniform must be of int type.
The function takes the following parameters:
- args: uniform arguments.
- idx: index of the uniform.
The function returns the following values:
- gint32: value.
func (*GLShader) ArgUint ¶
ArgUint gets the value of the uniform idx in the args block.
The uniform must be of uint type.
The function takes the following parameters:
- args: uniform arguments.
- idx: index of the uniform.
The function returns the following values:
- guint32: value.
func (*GLShader) ArgVec2 ¶
ArgVec2 gets the value of the uniform idx in the args block.
The uniform must be of vec2 type.
The function takes the following parameters:
- args: uniform arguments.
- idx: index of the uniform.
- outValue: location to store the uniform value in.
func (*GLShader) ArgVec3 ¶
ArgVec3 gets the value of the uniform idx in the args block.
The uniform must be of vec3 type.
The function takes the following parameters:
- args: uniform arguments.
- idx: index of the uniform.
- outValue: location to store the uniform value in.
func (*GLShader) ArgVec4 ¶
ArgVec4 gets the value of the uniform idx in the args block.
The uniform must be of vec4 type.
The function takes the following parameters:
- args: uniform arguments.
- idx: index of the uniform.
- outValue: location to store set the uniform value in.
func (*GLShader) ArgsSize ¶
ArgsSize: get the size of the data block used to specify arguments for this shader.
The function returns the following values:
- gsize: size of the data block.
func (*GLShader) Compile ¶
func (shader *GLShader) Compile(renderer Rendererer) error
Compile 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.
The function takes the following parameters:
- renderer: GskRenderer.
func (*GLShader) FindUniformByName ¶
FindUniformByName looks for a uniform by the name name, and returns the index of the uniform, or -1 if it was not found.
The function takes the following parameters:
- name: uniform name.
The function returns the following values:
- gint: index of the uniform, or -1.
func (*GLShader) NTextures ¶
NTextures 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.
The function returns the following values:
- gint: number of texture inputs required by shader.
func (*GLShader) NUniforms ¶
NUniforms: get the number of declared uniforms for this shader.
The function returns the following values:
- gint: number of declared uniforms.
func (*GLShader) Resource ¶
Resource gets the resource path for the GLSL sourcecode being used to render this shader.
The function returns the following values:
- utf8: resource path for the shader, or NULL if none.
func (*GLShader) Source ¶
func (shader *GLShader) Source() *glib.Bytes
Source gets the GLSL sourcecode being used to render this shader.
The function returns the following values:
- bytes: source code for the shader.
func (*GLShader) UniformName ¶
UniformName: get the name of the declared uniform for this shader at index idx.
The function takes the following parameters:
- idx: index of the uniform.
The function returns the following values:
- utf8: name of the declared uniform.
func (*GLShader) UniformOffset ¶
UniformOffset: get the offset into the data block where data for this uniforms is stored.
The function takes the following parameters:
- idx: index of the uniform.
The function returns the following values:
- gint: data offset.
func (*GLShader) UniformType ¶
func (shader *GLShader) UniformType(idx int) GLUniformType
UniformType: get the type of the declared uniform for this shader at index idx.
The function takes the following parameters:
- idx: index of the uniform.
The function returns the following values:
- glUniformType: type of the declared uniform.
type GLShaderClass ¶ added in v0.0.5
type GLShaderClass struct {
// contains filtered or unexported fields
}
GLShaderClass: instance of this type is always passed by reference.
type GLShaderNode ¶
type GLShaderNode struct { RenderNode // contains filtered or unexported fields }
GLShaderNode: render node using a GL shader when drawing its children nodes.
func NewGLShaderNode ¶
func NewGLShaderNode(shader *GLShader, bounds *graphene.Rect, args *glib.Bytes, children []RenderNoder) *GLShaderNode
NewGLShaderNode 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 gsk.GLShader.FormatArgs() or gsk.ShaderArgsBuilder.
See 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 gsk.GLShader.Compile() to ensure the shader will work for the renderer before using it.
The function takes the following parameters:
- shader: GLShader.
- bounds: rectangle to render the shader into.
- args arguments for the uniforms.
- children: array of child nodes, these will be rendered to textures and used as input.
The function returns the following values:
- glShaderNode: new GskRenderNode.
func (*GLShaderNode) Args ¶
func (node *GLShaderNode) Args() *glib.Bytes
Args gets args for the node.
The function returns the following values:
- bytes with the uniform arguments.
func (*GLShaderNode) Child ¶
func (node *GLShaderNode) Child(idx uint) RenderNoder
Child gets one of the children.
The function takes the following parameters:
- idx: position of the child to get.
The function returns the following values:
- renderNode: idx'th child of node.
func (*GLShaderNode) NChildren ¶
func (node *GLShaderNode) NChildren() uint
NChildren returns the number of children.
The function returns the following values:
- guint: number of children.
func (*GLShaderNode) Shader ¶
func (node *GLShaderNode) Shader() *GLShader
Shader gets shader code for the node.
The function returns the following values:
- glShader: GLShader shader.
type GLShaderOverrides ¶ added in v0.0.5
type GLShaderOverrides struct { }
GLShaderOverrides contains methods that are overridable.
type GLUniformType ¶
GLUniformType: 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.
const ( // GLUniformTypeNone: no type, used for uninitialized or unspecified values. GLUniformTypeNone GLUniformType = iota // GLUniformTypeFloat: float uniform. GLUniformTypeFloat // GLUniformTypeInt: GLSL int / gint32 uniform. GLUniformTypeInt // GLUniformTypeUint: GLSL uint / guint32 uniform. GLUniformTypeUint // GLUniformTypeBool: GLSL bool / gboolean uniform. GLUniformTypeBool // GLUniformTypeVec2: GLSL vec2 / graphene_vec2_t uniform. GLUniformTypeVec2 // GLUniformTypeVec3: GLSL vec3 / graphene_vec3_t uniform. GLUniformTypeVec3 // GLUniformTypeVec4: GLSL vec4 / graphene_vec4_t uniform. GLUniformTypeVec4 )
func (GLUniformType) String ¶
func (g GLUniformType) String() string
String returns the name in string for GLUniformType.
type InsetShadowNode ¶
type InsetShadowNode struct { RenderNode // contains filtered or unexported fields }
InsetShadowNode: render node for an inset shadow.
func NewInsetShadowNode ¶
func NewInsetShadowNode(outline *RoundedRect, color *gdk.RGBA, dx, dy, spread, blurRadius float32) *InsetShadowNode
NewInsetShadowNode creates a GskRenderNode that will render an inset shadow into the box given by outline.
The function takes the following parameters:
- outline of the region containing the shadow.
- color of the shadow.
- dx: horizontal offset of shadow.
- dy: vertical offset of shadow.
- spread: how far the shadow spreads towards the inside.
- blurRadius: how much blur to apply to the shadow.
The function returns the following values:
- insetShadowNode: new GskRenderNode.
func (*InsetShadowNode) BlurRadius ¶
func (node *InsetShadowNode) BlurRadius() float32
BlurRadius retrieves the blur radius to apply to the shadow.
The function returns the following values:
- gfloat: blur radius, in pixels.
func (*InsetShadowNode) Color ¶
func (node *InsetShadowNode) Color() *gdk.RGBA
Color retrieves the color of the inset shadow.
The function returns the following values:
- rgbA: color of the shadow.
func (*InsetShadowNode) Dx ¶
func (node *InsetShadowNode) Dx() float32
Dx retrieves the horizontal offset of the inset shadow.
The function returns the following values:
- gfloat: offset, in pixels.
func (*InsetShadowNode) Dy ¶
func (node *InsetShadowNode) Dy() float32
Dy retrieves the vertical offset of the inset shadow.
The function returns the following values:
- gfloat: offset, in pixels.
func (*InsetShadowNode) Outline ¶
func (node *InsetShadowNode) Outline() *RoundedRect
Outline retrieves the outline rectangle of the inset shadow.
The function returns the following values:
- roundedRect: rounded rectangle.
func (*InsetShadowNode) Spread ¶
func (node *InsetShadowNode) Spread() float32
Spread retrieves how much the shadow spreads inwards.
The function returns the following values:
- gfloat: size of the shadow, in pixels.
type LinearGradientNode ¶
type LinearGradientNode struct { RenderNode // contains filtered or unexported fields }
LinearGradientNode: render node for a linear gradient.
func NewLinearGradientNode ¶
func NewLinearGradientNode(bounds *graphene.Rect, start, end *graphene.Point, colorStops []ColorStop) *LinearGradientNode
NewLinearGradientNode 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.
The function takes the following parameters:
- bounds: rectangle to render the linear gradient into.
- start: point at which the linear gradient will begin.
- end: point at which the linear gradient will finish.
- colorStops: 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 function returns the following values:
- linearGradientNode: new GskRenderNode.
func (*LinearGradientNode) ColorStops ¶
func (node *LinearGradientNode) ColorStops() []ColorStop
ColorStops retrieves the color stops in the gradient.
The function returns the following values:
- colorStops: color stops in the gradient.
func (*LinearGradientNode) End ¶
func (node *LinearGradientNode) End() *graphene.Point
End retrieves the final point of the linear gradient.
The function returns the following values:
- point: final point.
func (*LinearGradientNode) NColorStops ¶
func (node *LinearGradientNode) NColorStops() uint
NColorStops retrieves the number of color stops in the gradient.
The function returns the following values:
- gsize: number of color stops.
func (*LinearGradientNode) Start ¶
func (node *LinearGradientNode) Start() *graphene.Point
Start retrieves the initial point of the linear gradient.
The function returns the following values:
- point: initial point.
type OpacityNode ¶
type OpacityNode struct { RenderNode // contains filtered or unexported fields }
OpacityNode: render node controlling the opacity of its single child node.
func NewOpacityNode ¶
func NewOpacityNode(child RenderNoder, opacity float32) *OpacityNode
NewOpacityNode creates a GskRenderNode that will drawn the child with reduced opacity.
The function takes the following parameters:
- child: node to draw.
- opacity to apply.
The function returns the following values:
- opacityNode: new GskRenderNode.
func (*OpacityNode) Child ¶
func (node *OpacityNode) Child() RenderNoder
Child gets the child node that is getting opacityed by the given node.
The function returns the following values:
- renderNode: child that is getting opacityed.
func (*OpacityNode) Opacity ¶
func (node *OpacityNode) Opacity() float32
Opacity gets the transparency factor for an opacity node.
The function returns the following values:
- gfloat: opacity factor.
type OutsetShadowNode ¶
type OutsetShadowNode struct { RenderNode // contains filtered or unexported fields }
OutsetShadowNode: render node for an outset shadow.
func NewOutsetShadowNode ¶
func NewOutsetShadowNode(outline *RoundedRect, color *gdk.RGBA, dx, dy, spread, blurRadius float32) *OutsetShadowNode
NewOutsetShadowNode creates a GskRenderNode that will render an outset shadow around the box given by outline.
The function takes the following parameters:
- outline of the region surrounded by shadow.
- color of the shadow.
- dx: horizontal offset of shadow.
- dy: vertical offset of shadow.
- spread: how far the shadow spreads towards the inside.
- blurRadius: how much blur to apply to the shadow.
The function returns the following values:
- outsetShadowNode: new GskRenderNode.
func (*OutsetShadowNode) BlurRadius ¶
func (node *OutsetShadowNode) BlurRadius() float32
BlurRadius retrieves the blur radius of the shadow.
The function returns the following values:
- gfloat: blur radius, in pixels.
func (*OutsetShadowNode) Color ¶
func (node *OutsetShadowNode) Color() *gdk.RGBA
Color retrieves the color of the outset shadow.
The function returns the following values:
- rgbA: color.
func (*OutsetShadowNode) Dx ¶
func (node *OutsetShadowNode) Dx() float32
Dx retrieves the horizontal offset of the outset shadow.
The function returns the following values:
- gfloat: offset, in pixels.
func (*OutsetShadowNode) Dy ¶
func (node *OutsetShadowNode) Dy() float32
Dy retrieves the vertical offset of the outset shadow.
The function returns the following values:
- gfloat: offset, in pixels.
func (*OutsetShadowNode) Outline ¶
func (node *OutsetShadowNode) Outline() *RoundedRect
Outline retrieves the outline rectangle of the outset shadow.
The function returns the following values:
- roundedRect: rounded rectangle.
func (*OutsetShadowNode) Spread ¶
func (node *OutsetShadowNode) Spread() float32
Spread retrieves how much the shadow spreads outwards.
The function returns the following values:
- gfloat: size of the shadow, in pixels.
type ParseErrorFunc ¶
type ParseErrorFunc func(start, end *ParseLocation, err error)
ParseErrorFunc: type of callback that is called when an error occurs during node deserialization.
type ParseLocation ¶
type ParseLocation struct {
// contains filtered or unexported fields
}
ParseLocation: location in a parse buffer.
An instance of this type is always passed by reference.
func NewParseLocation ¶
func NewParseLocation(bytes, chars, lines, lineBytes, lineChars uint) ParseLocation
NewParseLocation creates a new ParseLocation instance from the given fields. Beware that this function allocates on the Go heap; be careful when using it!
func (*ParseLocation) Bytes ¶
func (p *ParseLocation) Bytes() uint
Bytes: offset of the location in the parse buffer, as bytes.
func (*ParseLocation) Chars ¶
func (p *ParseLocation) Chars() uint
Chars: offset of the location in the parse buffer, as characters.
func (*ParseLocation) LineBytes ¶
func (p *ParseLocation) LineBytes() uint
LineBytes: position in the line, as bytes.
func (*ParseLocation) LineChars ¶
func (p *ParseLocation) LineChars() uint
LineChars: position in the line, as characters.
func (*ParseLocation) Lines ¶
func (p *ParseLocation) Lines() uint
Lines: line of the location in the parse buffer.
func (*ParseLocation) SetBytes ¶
func (p *ParseLocation) SetBytes(bytes uint)
Bytes: offset of the location in the parse buffer, as bytes.
func (*ParseLocation) SetChars ¶
func (p *ParseLocation) SetChars(chars uint)
Chars: offset of the location in the parse buffer, as characters.
func (*ParseLocation) SetLineBytes ¶
func (p *ParseLocation) SetLineBytes(lineBytes uint)
LineBytes: position in the line, as bytes.
func (*ParseLocation) SetLineChars ¶
func (p *ParseLocation) SetLineChars(lineChars uint)
LineChars: position in the line, as characters.
func (*ParseLocation) SetLines ¶
func (p *ParseLocation) SetLines(lines uint)
Lines: line of the location in the parse buffer.
type RadialGradientNode ¶
type RadialGradientNode struct { RenderNode // contains filtered or unexported fields }
RadialGradientNode: render node for a radial gradient.
func NewRadialGradientNode ¶
func NewRadialGradientNode(bounds *graphene.Rect, center *graphene.Point, hradius, vradius, start, end float32, colorStops []ColorStop) *RadialGradientNode
NewRadialGradientNode 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 vertial orientation.
The function takes the following parameters:
- bounds of the node.
- center of the gradient.
- hradius: horizontal radius.
- vradius: vertical radius.
- start: percentage >= 0 that defines the start of the gradient around center.
- end: percentage >= 0 that defines the end of the gradient around center.
- colorStops: 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 function returns the following values:
- radialGradientNode: new GskRenderNode.
func (*RadialGradientNode) Center ¶
func (node *RadialGradientNode) Center() *graphene.Point
Center retrieves the center pointer for the gradient.
The function returns the following values:
- point: center point for the gradient.
func (*RadialGradientNode) ColorStops ¶
func (node *RadialGradientNode) ColorStops() []ColorStop
ColorStops retrieves the color stops in the gradient.
The function returns the following values:
- colorStops: color stops in the gradient.
func (*RadialGradientNode) End ¶
func (node *RadialGradientNode) End() float32
End retrieves the end value for the gradient.
The function returns the following values:
- gfloat: end value for the gradient.
func (*RadialGradientNode) Hradius ¶
func (node *RadialGradientNode) Hradius() float32
Hradius retrieves the horizonal radius for the gradient.
The function returns the following values:
- gfloat: horizontal radius for the gradient.
func (*RadialGradientNode) NColorStops ¶
func (node *RadialGradientNode) NColorStops() uint
NColorStops retrieves the number of color stops in the gradient.
The function returns the following values:
- gsize: number of color stops.
func (*RadialGradientNode) Start ¶
func (node *RadialGradientNode) Start() float32
Start retrieves the start value for the gradient.
The function returns the following values:
- gfloat: start value for the gradient.
func (*RadialGradientNode) Vradius ¶
func (node *RadialGradientNode) Vradius() float32
Vradius retrieves the vertical radius for the gradient.
The function returns the following values:
- gfloat: vertical radius for the gradient.
type RenderNode ¶
RenderNode: GskRenderNode is the basic block in a scene graph to be rendered using GskRenderer.
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 gsk.Renderer it's safe to release any reference you have on them. All gsk.RenderNodes are immutable, you can only specify their properties during construction.
func BaseRenderNode ¶
func BaseRenderNode(obj RenderNoder) *RenderNode
BaseRenderNode returns the underlying base object.
func (*RenderNode) Bounds ¶
func (node *RenderNode) Bounds() *graphene.Rect
Bounds retrieves the boundaries of the node.
The node will not draw outside of its boundaries.
The function returns the following values:
- bounds: return location for the boundaries.
func (*RenderNode) Draw ¶
func (node *RenderNode) Draw(cr *cairo.Context)
Draw the contents of node to the given cairo context.
Typically, you'll use this function to implement fallback rendering of GskRenderNodes on an intermediate Cairo context, instead of using the drawing context associated to a GdkSurface's rendering buffer.
For advanced nodes that cannot be supported using Cairo, in particular for nodes doing 3D operations, this function may fail.
The function takes the following parameters:
- cr: cairo context to draw to.
func (*RenderNode) NodeType ¶
func (node *RenderNode) NodeType() RenderNodeType
NodeType returns the type of the node.
The function returns the following values:
- renderNodeType: type of the GskRenderNode.
func (*RenderNode) Serialize ¶
func (node *RenderNode) Serialize() *glib.Bytes
Serialize 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.
The function returns the following values:
- bytes representing the node.
func (*RenderNode) WriteToFile ¶
func (node *RenderNode) WriteToFile(filename string) error
WriteToFile: this function is equivalent to calling gsk_render_node_serialize() followed by g_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.
The function takes the following parameters:
- filename: file to save it to.
type RenderNodeType ¶
RenderNodeType: type of a node determines what the node is rendering.
const ( // NotARenderNodeType: error type. No node will ever have this type. NotARenderNodeType RenderNodeType = iota // ContainerNodeType: node containing a stack of children. ContainerNodeType // CairoNodeType: node drawing a #cairo_surface_t. CairoNodeType // ColorNodeType: node drawing a single color rectangle. ColorNodeType // LinearGradientNodeType: node drawing a linear gradient. LinearGradientNodeType // RepeatingLinearGradientNodeType: node drawing a repeating linear // gradient. RepeatingLinearGradientNodeType // RadialGradientNodeType: node drawing a radial gradient. RadialGradientNodeType // RepeatingRadialGradientNodeType: node drawing a repeating radial // gradient. RepeatingRadialGradientNodeType // ConicGradientNodeType: node drawing a conic gradient. ConicGradientNodeType // BorderNodeType: node stroking a border around an area. BorderNodeType // TextureNodeType: node drawing a Texture. TextureNodeType // InsetShadowNodeType: node drawing an inset shadow. InsetShadowNodeType // OutsetShadowNodeType: node drawing an outset shadow. OutsetShadowNodeType // TransformNodeType: node that renders its child after applying a matrix // transform. TransformNodeType // OpacityNodeType: node that changes the opacity of its child. OpacityNodeType // ColorMatrixNodeType: node that applies a color matrix to every pixel. ColorMatrixNodeType // RepeatNodeType: node that repeats the child's contents. RepeatNodeType // ClipNodeType: node that clips its child to a rectangular area. ClipNodeType // RoundedClipNodeType: node that clips its child to a rounded rectangle. RoundedClipNodeType // ShadowNodeType: node that draws a shadow below its child. ShadowNodeType // BlendNodeType: node that blends two children together. BlendNodeType // CrossFadeNodeType: node that cross-fades between two children. CrossFadeNodeType // TextNodeType: node containing a glyph string. TextNodeType // BlurNodeType: node that applies a blur. BlurNodeType // DebugNodeType: debug information that does not affect the rendering. DebugNodeType // GLShaderNodeType: node that uses OpenGL fragment shaders to render. GLShaderNodeType )
func (RenderNodeType) String ¶
func (r RenderNodeType) String() string
String returns the name in string for RenderNodeType.
type RenderNoder ¶
RenderNoder describes types inherited from class RenderNode.
To get the original type, the caller must assert this to an interface or another type.
func RenderNodeDeserialize ¶
func RenderNodeDeserialize(bytes *glib.Bytes, errorFunc ParseErrorFunc) RenderNoder
RenderNodeDeserialize loads data previously created via gsk_render_node_serialize().
For a discussion of the supported format, see that function.
The function takes the following parameters:
- bytes containing the data.
- errorFunc (optional): callback on parsing errors or NULL.
The function returns the following values:
- renderNode (optional): new GskRenderNode or NULL on error.
type Renderer ¶
Renderer: GskRenderer is a class that renders a scene graph defined via a tree of gsk.RenderNode instances.
Typically you will use a GskRenderer instance to repeatedly call gsk.Renderer.Render() to update the contents of its associated gdk.Surface.
It is necessary to realize a GskRenderer instance using gsk.Renderer.Realize() before calling gsk.Renderer.Render(), in order to create the appropriate windowing system resources needed to render the scene.
func BaseRenderer ¶
func BaseRenderer(obj Rendererer) *Renderer
BaseRenderer returns the underlying base object.
func NewRendererForSurface ¶
func NewRendererForSurface(surface gdk.Surfacer) *Renderer
NewRendererForSurface 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.
The function takes the following parameters:
- surface: GdkSurface.
The function returns the following values:
- renderer (optional): GskRenderer.
func (*Renderer) IsRealized ¶
IsRealized checks whether the renderer is realized or not.
The function returns the following values:
- ok: TRUE if the GskRenderer was realized, and FALSE otherwise.
func (*Renderer) Realize ¶
Realize creates the resources needed by the renderer to render the scene graph.
The function takes the following parameters:
- surface: GdkSurface renderer will be used on.
func (*Renderer) Render ¶
func (renderer *Renderer) Render(root RenderNoder, region *cairo.Region)
Render renders the scene graph, described by a tree of GskRenderNode instances, ensuring that the given region gets redrawn.
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.
The function takes the following parameters:
- root: GskRenderNode.
- region (optional): cairo_region_t that must be redrawn or NULL for the whole window.
func (*Renderer) RenderTexture ¶
func (renderer *Renderer) RenderTexture(root RenderNoder, viewport *graphene.Rect) gdk.Texturer
RenderTexture 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.
The function takes the following parameters:
- root: GskRenderNode.
- viewport (optional): section to draw or NULL to use root's bounds.
The function returns the following values:
- texture: GdkTexture with the rendered contents of root.
type Rendererer ¶
Rendererer describes types inherited from class Renderer.
To get the original type, the caller must assert this to an interface or another type.
type RepeatNode ¶
type RepeatNode struct { RenderNode // contains filtered or unexported fields }
RepeatNode: render node repeating its single child node.
func NewRepeatNode ¶
func NewRepeatNode(bounds *graphene.Rect, child RenderNoder, childBounds *graphene.Rect) *RepeatNode
NewRepeatNode creates a GskRenderNode that will repeat the drawing of child across the given bounds.
The function takes the following parameters:
- bounds of the area to be painted.
- child to repeat.
- childBounds (optional): area of the child to repeat or NULL to use the child's bounds.
The function returns the following values:
- repeatNode: new GskRenderNode.
func (*RepeatNode) Child ¶
func (node *RepeatNode) Child() RenderNoder
Child retrieves the child of node.
The function returns the following values:
- renderNode: GskRenderNode.
func (*RepeatNode) ChildBounds ¶
func (node *RepeatNode) ChildBounds() *graphene.Rect
ChildBounds retrieves the bounding rectangle of the child of node.
The function returns the following values:
- rect: bounding rectangle.
type RepeatingLinearGradientNode ¶
type RepeatingLinearGradientNode struct { RenderNode // contains filtered or unexported fields }
RepeatingLinearGradientNode: render node for a repeating linear gradient.
func NewRepeatingLinearGradientNode ¶
func NewRepeatingLinearGradientNode(bounds *graphene.Rect, start, end *graphene.Point, colorStops []ColorStop) *RepeatingLinearGradientNode
NewRepeatingLinearGradientNode 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.
The function takes the following parameters:
- bounds: rectangle to render the linear gradient into.
- start: point at which the linear gradient will begin.
- end: point at which the linear gradient will finish.
- colorStops: 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 function returns the following values:
- repeatingLinearGradientNode: new GskRenderNode.
type RepeatingRadialGradientNode ¶
type RepeatingRadialGradientNode struct { RenderNode // contains filtered or unexported fields }
RepeatingRadialGradientNode: render node for a repeating radial gradient.
func NewRepeatingRadialGradientNode ¶
func NewRepeatingRadialGradientNode(bounds *graphene.Rect, center *graphene.Point, hradius, vradius, start, end float32, colorStops []ColorStop) *RepeatingRadialGradientNode
NewRepeatingRadialGradientNode 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 vertial orientation.
The function takes the following parameters:
- bounds of the node.
- center of the gradient.
- hradius: horizontal radius.
- vradius: vertical radius.
- start: percentage >= 0 that defines the start of the gradient around center.
- end: percentage >= 0 that defines the end of the gradient around center.
- colorStops: 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 function returns the following values:
- repeatingRadialGradientNode: new GskRenderNode.
type RoundedClipNode ¶
type RoundedClipNode struct { RenderNode // contains filtered or unexported fields }
RoundedClipNode: render node applying a rounded rectangle clip to its single child.
func NewRoundedClipNode ¶
func NewRoundedClipNode(child RenderNoder, clip *RoundedRect) *RoundedClipNode
NewRoundedClipNode creates a GskRenderNode that will clip the child to the area given by clip.
The function takes the following parameters:
- child: node to draw.
- clip to apply.
The function returns the following values:
- roundedClipNode: new GskRenderNode.
func (*RoundedClipNode) Child ¶
func (node *RoundedClipNode) Child() RenderNoder
Child gets the child node that is getting clipped by the given node.
The function returns the following values:
- renderNode: child that is getting clipped.
func (*RoundedClipNode) Clip ¶
func (node *RoundedClipNode) Clip() *RoundedRect
Clip retrieves the rounded rectangle used to clip the contents of the node.
The function returns the following values:
- roundedRect: rounded rectangle.
type RoundedRect ¶
type RoundedRect struct {
// contains filtered or unexported fields
}
RoundedRect: rectangular region with rounded corners.
Application code should normalize rectangles using 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).
An instance of this type is always passed by reference.
func (*RoundedRect) Bounds ¶
func (r *RoundedRect) Bounds() *graphene.Rect
Bounds bounds of the rectangle.
func (*RoundedRect) ContainsPoint ¶
func (self *RoundedRect) ContainsPoint(point *graphene.Point) bool
ContainsPoint checks if the given point is inside the rounded rectangle.
The function takes the following parameters:
- point to check.
The function returns the following values:
- ok: TRUE if the point is inside the rounded rectangle.
func (*RoundedRect) ContainsRect ¶
func (self *RoundedRect) ContainsRect(rect *graphene.Rect) bool
ContainsRect checks if the given rect is contained inside the rounded rectangle.
The function takes the following parameters:
- rect: rectangle to check.
The function returns the following values:
- ok: TRUE if the rect is fully contained inside the rounded rectangle.
func (*RoundedRect) Corner ¶
func (r *RoundedRect) Corner() [4]graphene.Size
Corner: size of the 4 rounded corners.
func (*RoundedRect) Init ¶
func (self *RoundedRect) Init(bounds *graphene.Rect, topLeft *graphene.Size, topRight *graphene.Size, bottomRight *graphene.Size, bottomLeft *graphene.Size) *RoundedRect
Init initializes the given GskRoundedRect with the given values.
This function will implicitly normalize the GskRoundedRect before returning.
The function takes the following parameters:
- bounds: graphene_rect_t describing the bounds.
- topLeft: rounding radius of the top left corner.
- topRight: rounding radius of the top right corner.
- bottomRight: rounding radius of the bottom right corner.
- bottomLeft: rounding radius of the bottom left corner.
The function returns the following values:
- roundedRect: initialized rectangle.
func (*RoundedRect) InitCopy ¶
func (self *RoundedRect) InitCopy(src *RoundedRect) *RoundedRect
InitCopy initializes self using the given src rectangle.
This function will not normalize the GskRoundedRect, so make sure the source is normalized.
The function takes the following parameters:
- src: GskRoundedRect.
The function returns the following values:
- roundedRect: initialized rectangle.
func (*RoundedRect) InitFromRect ¶
func (self *RoundedRect) InitFromRect(bounds *graphene.Rect, radius float32) *RoundedRect
InitFromRect initializes self to the given bounds and sets the radius of all four corners to radius.
The function takes the following parameters:
- bounds: graphene_rect_t.
- radius: border radius.
The function returns the following values:
- roundedRect: initialized rectangle.
func (*RoundedRect) IntersectsRect ¶
func (self *RoundedRect) IntersectsRect(rect *graphene.Rect) bool
IntersectsRect checks if part of the given rect is contained inside the rounded rectangle.
The function takes the following parameters:
- rect: rectangle to check.
The function returns the following values:
- ok: TRUE if the rect intersects with the rounded rectangle.
func (*RoundedRect) IsRectilinear ¶
func (self *RoundedRect) IsRectilinear() bool
IsRectilinear 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 gsk.ClipNode.New or gsk.RoundedClipNode.New should be called.
The function returns the following values:
- ok: TRUE if the rectangle is rectilinear.
func (*RoundedRect) Normalize ¶
func (self *RoundedRect) Normalize() *RoundedRect
Normalize 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 function returns the following values:
- roundedRect: normalized rectangle.
func (*RoundedRect) Offset ¶
func (self *RoundedRect) Offset(dx float32, dy float32) *RoundedRect
Offset offsets the bound's origin by dx and dy.
The size and corners of the rectangle are unchanged.
The function takes the following parameters:
- dx: horizontal offset.
- dy: vertical offset.
The function returns the following values:
- roundedRect: offset rectangle.
func (*RoundedRect) Shrink ¶
func (self *RoundedRect) Shrink(top float32, right float32, bottom float32, left float32) *RoundedRect
Shrink 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 function takes the following parameters:
- top: how far to move the top side downwards.
- right: how far to move the right side to the left.
- bottom: how far to move the bottom side upwards.
- left: how far to move the left side to the right.
The function returns the following values:
- roundedRect: resized GskRoundedRect.
type ScalingFilter ¶
ScalingFilter filters used when scaling texture data.
The actual implementation of each filter is deferred to the rendering pipeline.
const ( // ScalingFilterLinear: linear interpolation filter. ScalingFilterLinear ScalingFilter = iota // ScalingFilterNearest: nearest neighbor interpolation filter. ScalingFilterNearest // ScalingFilterTrilinear: linear interpolation along each axis, plus mipmap // generation, with linear interpolation along the mipmap levels. ScalingFilterTrilinear )
func (ScalingFilter) String ¶
func (s ScalingFilter) String() string
String returns the name in string for ScalingFilter.
type SerializationError ¶
SerializationError errors that can happen during (de)serialization.
const ( // SerializationUnsupportedFormat: format can not be identified. SerializationUnsupportedFormat SerializationError = iota // SerializationUnsupportedVersion: version of the data is not understood. SerializationUnsupportedVersion // SerializationInvalidData: given data may not exist in a proper // serialization. SerializationInvalidData )
func (SerializationError) String ¶
func (s SerializationError) String() string
String returns the name in string for SerializationError.
type ShaderArgsBuilder ¶
type ShaderArgsBuilder struct {
// contains filtered or unexported fields
}
ShaderArgsBuilder: object to build the uniforms data for a GLShader.
An instance of this type is always passed by reference.
func NewShaderArgsBuilder ¶
func NewShaderArgsBuilder(shader *GLShader, initialValues *glib.Bytes) *ShaderArgsBuilder
NewShaderArgsBuilder constructs a struct ShaderArgsBuilder.
func (*ShaderArgsBuilder) SetBool ¶
func (builder *ShaderArgsBuilder) SetBool(idx int, value bool)
SetBool sets the value of the uniform idx.
The uniform must be of bool type.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform to.
func (*ShaderArgsBuilder) SetFloat ¶
func (builder *ShaderArgsBuilder) SetFloat(idx int, value float32)
SetFloat sets the value of the uniform idx.
The uniform must be of float type.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform to.
func (*ShaderArgsBuilder) SetInt ¶
func (builder *ShaderArgsBuilder) SetInt(idx int, value int32)
SetInt sets the value of the uniform idx.
The uniform must be of int type.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform to.
func (*ShaderArgsBuilder) SetUint ¶
func (builder *ShaderArgsBuilder) SetUint(idx int, value uint32)
SetUint sets the value of the uniform idx.
The uniform must be of uint type.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform to.
func (*ShaderArgsBuilder) SetVec2 ¶
func (builder *ShaderArgsBuilder) SetVec2(idx int, value *graphene.Vec2)
SetVec2 sets the value of the uniform idx.
The uniform must be of vec2 type.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform too.
func (*ShaderArgsBuilder) SetVec3 ¶
func (builder *ShaderArgsBuilder) SetVec3(idx int, value *graphene.Vec3)
SetVec3 sets the value of the uniform idx.
The uniform must be of vec3 type.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform too.
func (*ShaderArgsBuilder) SetVec4 ¶
func (builder *ShaderArgsBuilder) SetVec4(idx int, value *graphene.Vec4)
SetVec4 sets the value of the uniform idx.
The uniform must be of vec4 type.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform too.
func (*ShaderArgsBuilder) ToArgs ¶
func (builder *ShaderArgsBuilder) ToArgs() *glib.Bytes
ToArgs 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 gsk.ShaderArgsBuilder.FreeToArgs().
The function returns the following values:
- bytes: newly allocated buffer with all the args added to builder.
type Shadow ¶
type Shadow struct {
// contains filtered or unexported fields
}
Shadow: shadow parameters in a shadow node.
An instance of this type is always passed by reference.
type ShadowNode ¶
type ShadowNode struct { RenderNode // contains filtered or unexported fields }
ShadowNode: render node drawing one or more shadows behind its single child node.
func NewShadowNode ¶
func NewShadowNode(child RenderNoder, shadows []Shadow) *ShadowNode
NewShadowNode creates a GskRenderNode that will draw a child with the given shadows below it.
The function takes the following parameters:
- child: node to draw.
- shadows to apply.
The function returns the following values:
- shadowNode: new GskRenderNode.
func (*ShadowNode) Child ¶
func (node *ShadowNode) Child() RenderNoder
Child retrieves the child GskRenderNode of the shadow node.
The function returns the following values:
- renderNode: child render node.
func (*ShadowNode) NShadows ¶
func (node *ShadowNode) NShadows() uint
NShadows retrieves the number of shadows in the node.
The function returns the following values:
- gsize: number of shadows.
func (*ShadowNode) Shadow ¶
func (node *ShadowNode) Shadow(i uint) *Shadow
Shadow retrieves the shadow data at the given index i.
The function takes the following parameters:
- i: given index.
The function returns the following values:
- shadow data.
type TextNode ¶
type TextNode struct { RenderNode // contains filtered or unexported fields }
TextNode: render node drawing a set of glyphs.
func NewTextNode ¶
func NewTextNode(font pango.Fonter, glyphs *pango.GlyphString, color *gdk.RGBA, offset *graphene.Point) *TextNode
NewTextNode creates a render node that renders the given glyphs.
Note that color may not be used if the font contains color glyphs.
The function takes the following parameters:
- font containing the glyphs.
- glyphs to render.
- color: foreground color to render with.
- offset of the baseline.
The function returns the following values:
- textNode (optional): new GskRenderNode.
func (*TextNode) Color ¶
func (node *TextNode) Color() *gdk.RGBA
Color retrieves the color used by the text node.
The function returns the following values:
- rgbA: text color.
func (*TextNode) Font ¶
Font returns the font used by the text node.
The function returns the following values:
- font: font.
func (*TextNode) Glyphs ¶
Glyphs retrieves the glyph information in the node.
The function returns the following values:
- glyphInfos: glyph information.
func (*TextNode) HasColorGlyphs ¶
HasColorGlyphs checks whether the text node has color glyphs.
The function returns the following values:
- ok: TRUE if the text node has color glyphs.
type TextureNode ¶
type TextureNode struct { RenderNode // contains filtered or unexported fields }
TextureNode: render node for a Texture.
func NewTextureNode ¶
func NewTextureNode(texture gdk.Texturer, bounds *graphene.Rect) *TextureNode
NewTextureNode creates a GskRenderNode that will render the given texture into the area given by bounds.
The function takes the following parameters:
- texture: GdkTexture.
- bounds: rectangle to render the texture into.
The function returns the following values:
- textureNode: new GskRenderNode.
func (*TextureNode) Texture ¶
func (node *TextureNode) Texture() gdk.Texturer
Texture retrieves the GdkTexture used when creating this GskRenderNode.
The function returns the following values:
- texture: GdkTexture.
type Transform ¶
type Transform struct {
// contains filtered or unexported fields
}
Transform: 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.
An instance of this type is always passed by reference.
func TransformParse ¶
TransformParse parses the given string into a transform and puts it in out_transform.
Strings printed via gsk.Transform.ToString() 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.
The function takes the following parameters:
- str: string to parse.
The function returns the following values:
- outTransform: location to put the transform in.
- ok: TRUE if string described a valid transform.
func (*Transform) Category ¶
func (self *Transform) Category() TransformCategory
Category returns the category this transform belongs to.
The function returns the following values:
- transformCategory: category of the transform.
func (*Transform) Equal ¶
Equal checks two transforms for equality.
The function takes the following parameters:
- second (optional) transform.
The function returns the following values:
- ok: TRUE if the two transforms perform the same operation.
func (*Transform) Invert ¶
Invert 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.
The function returns the following values:
- transform (optional): inverted transform or NULL if the transform cannot be inverted.
func (*Transform) Matrix ¶
Matrix multiplies next with the given matrix.
The function takes the following parameters:
- matrix to multiply next with.
The function returns the following values:
- transform: new transform.
func (*Transform) Perspective ¶
Perspective 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.
The function takes the following parameters:
- depth: distance of the z=0 plane. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect.
The function returns the following values:
- transform: new transform.
func (*Transform) Rotate ¶
Rotate rotates next angle degrees in 2D - or in 3D-speak, around the z axis.
The function takes the following parameters:
- angle: rotation angle, in degrees (clockwise).
The function returns the following values:
- transform: new transform.
func (*Transform) Rotate3D ¶
Rotate3D rotates next angle degrees around axis.
For a rotation in 2D space, use gsk.Transform.Rotate().
The function takes the following parameters:
- angle: rotation angle, in degrees (clockwise).
- axis: rotation axis.
The function returns the following values:
- transform: new transform.
func (*Transform) Scale ¶
Scale scales next in 2-dimensional space by the given factors.
Use gsk.Transform.Scale3D() to scale in all 3 dimensions.
The function takes the following parameters:
- factorX: scaling factor on the X axis.
- factorY: scaling factor on the Y axis.
The function returns the following values:
- transform: new transform.
func (*Transform) Scale3D ¶
Scale3D scales next by the given factors.
The function takes the following parameters:
- factorX: scaling factor on the X axis.
- factorY: scaling factor on the Y axis.
- factorZ: scaling factor on the Z axis.
The function returns the following values:
- transform: new transform.
func (*Transform) String ¶
String converts a matrix into a string that is suitable for printing.
The resulting string can be parsed with gsk.Transform().Parse.
This is a wrapper around gsk.Transform.Print().
The function returns the following values:
- utf8: new string for self.
func (*Transform) To2D ¶
func (self *Transform) To2D() (outXx float32, outYx float32, outXy float32, outYy float32, outDx float32, outDy float32)
To2D 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.
The function returns the following values:
- outXx: return location for the xx member.
- outYx: return location for the yx member.
- outXy: return location for the xy member.
- outYy: return location for the yy member.
- outDx: return location for the x0 member.
- outDy: return location for the y0 member.
func (*Transform) ToAffine ¶
func (self *Transform) ToAffine() (outScaleX float32, outScaleY float32, outDx float32, outDy float32)
ToAffine converts a GskTransform to 2D affine transformation factors.
self must be a 2D transformation. If you are not sure, use gsk_transform_get_category() >= GSK_TRANSFORM_CATEGORY_2D_AFFINE to check.
The function returns the following values:
- outScaleX: return location for the scale factor in the x direction.
- outScaleY: return location for the scale factor in the y direction.
- outDx: return location for the translation in the x direction.
- outDy: return location for the translation in the y direction.
func (*Transform) ToMatrix ¶
ToMatrix computes the actual value of self and stores it in out_matrix.
The previous value of out_matrix will be ignored.
The function returns the following values:
- outMatrix: matrix to set.
func (*Transform) ToTranslate ¶
ToTranslate 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.
The function returns the following values:
- outDx: return location for the translation in the x direction.
- outDy: return location for the translation in the y direction.
func (*Transform) Transform ¶
Transform applies all the operations from other to next.
The function takes the following parameters:
- other (optional): transform to apply.
The function returns the following values:
- transform: new transform.
func (*Transform) TransformBounds ¶
TransformBounds transforms a graphene_rect_t using the given transform self.
The result is the bounding box containing the coplanar quad.
The function takes the following parameters:
- rect: graphene_rect_t.
The function returns the following values:
- outRect: return location for the bounds of the transformed rectangle.
func (*Transform) TransformPoint ¶
TransformPoint transforms a graphene_point_t using the given transform self.
The function takes the following parameters:
- point: graphene_point_t.
The function returns the following values:
- outPoint: return location for the transformed point.
type TransformCategory ¶
TransformCategory 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)).
const ( // TransformCategoryUnknown: category of the matrix has not been determined. TransformCategoryUnknown TransformCategory = iota // TransformCategoryAny: analyzing the matrix concluded that it does not fit // in any other category. TransformCategoryAny // TransformCategory3D: matrix is a 3D matrix. This means that the w column // (the last column) has the values (0, 0, 0, 1). TransformCategory3D // TransformCategory2D: 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. TransformCategory2D // TransformCategory2DAffine: 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. TransformCategory2DAffine // TransformCategory2DTranslate: matrix is a 2D translation. TransformCategory2DTranslate // TransformCategoryIdentity: matrix is the identity matrix. TransformCategoryIdentity )
func (TransformCategory) String ¶
func (t TransformCategory) String() string
String returns the name in string for TransformCategory.
type TransformNode ¶
type TransformNode struct { RenderNode // contains filtered or unexported fields }
TransformNode: render node applying a GskTransform to its single child node.
func NewTransformNode ¶
func NewTransformNode(child RenderNoder, transform *Transform) *TransformNode
NewTransformNode creates a GskRenderNode that will transform the given child with the given transform.
The function takes the following parameters:
- child: node to transform.
- transform to apply.
The function returns the following values:
- transformNode: new GskRenderNode.
func (*TransformNode) Child ¶
func (node *TransformNode) Child() RenderNoder
Child gets the child node that is getting transformed by the given node.
The function returns the following values:
- renderNode: child that is getting transformed.
func (*TransformNode) Transform ¶
func (node *TransformNode) Transform() *Transform
Transform retrieves the GskTransform used by the node.
The function returns the following values:
- transform: GskTransform.