Documentation
¶
Index ¶
- Variables
- func SerializationErrorQuark() glib.Quark
- func StrokeEqual(stroke1, stroke2 unsafe.Pointer) bool
- func ValueSetRenderNode(value *coreglib.Value, node RenderNoder)
- func ValueTakeRenderNode(value *coreglib.Value, node RenderNoder)
- 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 FillNode
- type FillRule
- type GLShaderdeprecated
- func (shader *GLShader) ArgBool(args *glib.Bytes, idx int) booldeprecated
- func (shader *GLShader) ArgFloat(args *glib.Bytes, idx int) float32deprecated
- func (shader *GLShader) ArgInt(args *glib.Bytes, idx int) int32deprecated
- func (shader *GLShader) ArgUint(args *glib.Bytes, idx int) uint32deprecated
- func (shader *GLShader) ArgVec2(args *glib.Bytes, idx int, outValue *graphene.Vec2)deprecated
- func (shader *GLShader) ArgVec3(args *glib.Bytes, idx int, outValue *graphene.Vec3)deprecated
- func (shader *GLShader) ArgVec4(args *glib.Bytes, idx int, outValue *graphene.Vec4)deprecated
- func (shader *GLShader) ArgsSize() uintdeprecated
- func (shader *GLShader) Compile(renderer Rendererer) errordeprecated
- func (shader *GLShader) FindUniformByName(name string) intdeprecated
- func (shader *GLShader) NTextures() intdeprecated
- func (shader *GLShader) NUniforms() intdeprecated
- func (shader *GLShader) Resource() stringdeprecated
- func (shader *GLShader) Source() *glib.Bytesdeprecated
- func (shader *GLShader) UniformName(idx int) stringdeprecated
- func (shader *GLShader) UniformOffset(idx int) intdeprecated
- func (shader *GLShader) UniformType(idx int) GLUniformTypedeprecated
- type GLShaderClass
- type GLShaderNode
- type GLShaderOverrides
- type GLUniformTypedeprecated
- type InsetShadowNode
- type LineCap
- type LineJoin
- type LinearGradientNode
- type MaskMode
- type MaskNode
- 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 Path
- func (self *Path) Bounds() (*graphene.Rect, bool)
- func (self *Path) ClosestPoint(point *graphene.Point, threshold float32) (*PathPoint, float32, bool)
- func (self *Path) EndPoint() (*PathPoint, bool)
- func (self *Path) ForEach(flags PathForEachFlags, fn PathForEachFunc) bool
- func (self *Path) InFill(point *graphene.Point, fillRule FillRule) bool
- func (self *Path) IsClosed() bool
- func (self *Path) IsEmpty() bool
- func (self *Path) StartPoint() (*PathPoint, bool)
- func (self *Path) String() string
- func (self *Path) StrokeBounds(stroke *Stroke) (*graphene.Rect, bool)
- func (self *Path) ToCairo(cr *cairo.Context)
- type PathBuilder
- func (self *PathBuilder) AddCircle(center *graphene.Point, radius float32)
- func (self *PathBuilder) AddLayout(layout *pango.Layout)
- func (self *PathBuilder) AddPath(path *Path)
- func (self *PathBuilder) AddRect(rect *graphene.Rect)
- func (self *PathBuilder) AddReversePath(path *Path)
- func (self *PathBuilder) AddRoundedRect(rect *RoundedRect)
- func (self *PathBuilder) AddSegment(path *Path, start *PathPoint, end *PathPoint)
- func (self *PathBuilder) ArcTo(x1 float32, y1 float32, x2 float32, y2 float32)
- func (self *PathBuilder) Close()
- func (self *PathBuilder) ConicTo(x1 float32, y1 float32, x2 float32, y2 float32, weight float32)
- func (self *PathBuilder) CubicTo(x1 float32, y1 float32, x2 float32, y2 float32, x3 float32, y3 float32)
- func (self *PathBuilder) CurrentPoint() *graphene.Point
- func (self *PathBuilder) HtmlArcTo(x1 float32, y1 float32, x2 float32, y2 float32, radius float32)
- func (self *PathBuilder) LineTo(x float32, y float32)
- func (self *PathBuilder) MoveTo(x float32, y float32)
- func (self *PathBuilder) QuadTo(x1 float32, y1 float32, x2 float32, y2 float32)
- func (self *PathBuilder) RelArcTo(x1 float32, y1 float32, x2 float32, y2 float32)
- func (self *PathBuilder) RelConicTo(x1 float32, y1 float32, x2 float32, y2 float32, weight float32)
- func (self *PathBuilder) RelCubicTo(x1 float32, y1 float32, x2 float32, y2 float32, x3 float32, y3 float32)
- func (self *PathBuilder) RelHtmlArcTo(x1 float32, y1 float32, x2 float32, y2 float32, radius float32)
- func (self *PathBuilder) RelLineTo(x float32, y float32)
- func (self *PathBuilder) RelMoveTo(x float32, y float32)
- func (self *PathBuilder) RelQuadTo(x1 float32, y1 float32, x2 float32, y2 float32)
- func (self *PathBuilder) RelSVGArcTo(rx float32, ry float32, xAxisRotation float32, largeArc bool, ...)
- func (self *PathBuilder) SVGArcTo(rx float32, ry float32, xAxisRotation float32, largeArc bool, ...)
- func (self *PathBuilder) ToPath() *Path
- type PathDirection
- type PathForEachFlags
- type PathForEachFunc
- type PathMeasure
- type PathOperation
- type PathPoint
- func (point1 *PathPoint) Compare(point2 *PathPoint) int
- func (point *PathPoint) Copy() *PathPoint
- func (point *PathPoint) Curvature(path *Path, direction PathDirection) (*graphene.Point, float32)
- func (point *PathPoint) Distance(measure *PathMeasure) float32
- func (point1 *PathPoint) Equal(point2 *PathPoint) bool
- func (point *PathPoint) Position(path *Path) *graphene.Point
- func (point *PathPoint) Rotation(path *Path, direction PathDirection) float32
- func (point *PathPoint) Tangent(path *Path, direction PathDirection) *graphene.Vec2
- 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
- func (node *RenderNode) Bounds() *graphene.Rect
- func (node *RenderNode) Draw(cr *cairo.Context)
- func (node *RenderNode) NodeType() RenderNodeType
- func (self *RenderNode) OpaqueRect() (*graphene.Rect, bool)
- func (node *RenderNode) Serialize() *glib.Bytes
- func (node *RenderNode) WriteToFile(filename string) error
- type RenderNodeType
- type RenderNoder
- type Renderer
- func (renderer *Renderer) IsRealized() bool
- func (renderer *Renderer) Realize(surface gdk.Surfacer) error
- func (renderer *Renderer) RealizeForDisplay(display *gdk.Display) 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 ShaderArgsBuilderdeprecated
- func (builder *ShaderArgsBuilder) SetBool(idx int, value bool)deprecated
- func (builder *ShaderArgsBuilder) SetFloat(idx int, value float32)
- func (builder *ShaderArgsBuilder) SetInt(idx int, value int32)deprecated
- func (builder *ShaderArgsBuilder) SetUint(idx int, value uint32)deprecated
- func (builder *ShaderArgsBuilder) SetVec2(idx int, value *graphene.Vec2)deprecated
- func (builder *ShaderArgsBuilder) SetVec3(idx int, value *graphene.Vec3)deprecated
- func (builder *ShaderArgsBuilder) SetVec4(idx int, value *graphene.Vec4)deprecated
- func (builder *ShaderArgsBuilder) ToArgs() *glib.Bytesdeprecated
- type Shadow
- type ShadowNode
- type Stroke
- func (other *Stroke) Copy() *Stroke
- func (self *Stroke) Dash() []float32
- func (self *Stroke) DashOffset() float32
- func (self *Stroke) LineCap() LineCap
- func (self *Stroke) LineJoin() LineJoin
- func (self *Stroke) LineWidth() float32
- func (self *Stroke) MiterLimit() float32
- func (self *Stroke) SetDash(dash []float32)
- func (self *Stroke) SetDashOffset(offset float32)
- func (self *Stroke) SetLineCap(lineCap LineCap)
- func (self *Stroke) SetLineJoin(lineJoin LineJoin)
- func (self *Stroke) SetLineWidth(lineWidth float32)
- func (self *Stroke) SetMiterLimit(limit float32)
- func (self *Stroke) ToCairo(cr *cairo.Context)
- type StrokeNode
- type SubsurfaceNode
- type TextNode
- type TextureNode
- type TextureScaleNode
- 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 (next *Transform) Skew(skewX float32, skewY float32) *Transform
- func (self *Transform) String() string
- func (self *Transform) To2D() (outXx float32, outYx float32, outXy float32, outYy float32, outDx float32, ...)
- func (self *Transform) To2DComponents() (outSkewX float32, outSkewY float32, outScaleX float32, outScaleY 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()) GTypeFillRule = coreglib.Type(C.gsk_fill_rule_get_type()) GTypeGLUniformType = coreglib.Type(C.gsk_gl_uniform_type_get_type()) GTypeLineCap = coreglib.Type(C.gsk_line_cap_get_type()) GTypeLineJoin = coreglib.Type(C.gsk_line_join_get_type()) GTypeMaskMode = coreglib.Type(C.gsk_mask_mode_get_type()) GTypePathDirection = coreglib.Type(C.gsk_path_direction_get_type()) GTypePathOperation = coreglib.Type(C.gsk_path_operation_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()) GTypePathForEachFlags = coreglib.Type(C.gsk_path_foreach_flags_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()) GTypeFillNode = coreglib.Type(C.gsk_fill_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()) GTypeMaskNode = coreglib.Type(C.gsk_mask_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()) GTypeStrokeNode = coreglib.Type(C.gsk_stroke_node_get_type()) GTypeSubsurfaceNode = coreglib.Type(C.gsk_subsurface_node_get_type()) GTypeTextNode = coreglib.Type(C.gsk_text_node_get_type()) GTypeTextureNode = coreglib.Type(C.gsk_texture_node_get_type()) GTypeTextureScaleNode = coreglib.Type(C.gsk_texture_scale_node_get_type()) GTypeTransformNode = coreglib.Type(C.gsk_transform_node_get_type()) GTypePath = coreglib.Type(C.gsk_path_get_type()) GTypePathBuilder = coreglib.Type(C.gsk_path_builder_get_type()) GTypePathMeasure = coreglib.Type(C.gsk_path_measure_get_type()) GTypePathPoint = coreglib.Type(C.gsk_path_point_get_type()) GTypeShaderArgsBuilder = coreglib.Type(C.gsk_shader_args_builder_get_type()) GTypeStroke = coreglib.Type(C.gsk_stroke_get_type()) GTypeTransform = coreglib.Type(C.gsk_transform_get_type()) )
GType values.
Functions ¶
func SerializationErrorQuark ¶
SerializationErrorQuark registers an error quark for gsk.RenderNode errors.
The function returns the following values:
- quark: error quark.
func StrokeEqual ¶
StrokeEqual checks if two strokes are identical.
The function takes the following parameters:
- stroke1 (optional): first stroke.
- stroke2 (optional): second stroke.
The function returns the following values:
- ok: true if the two strokes are equal, false otherwise.
func ValueSetRenderNode ¶
func ValueSetRenderNode(value *coreglib.Value, node RenderNoder)
ValueSetRenderNode stores the given render node inside a GValue.
The gobject.Value will acquire a reference to the render node.
The function takes the following parameters:
- value: gobject.Value initialized with type GSK_TYPE_RENDER_NODE.
- node: render node.
func ValueTakeRenderNode ¶
func ValueTakeRenderNode(value *coreglib.Value, node RenderNoder)
ValueTakeRenderNode stores the given render node inside a GValue.
This function transfers the ownership of the render node to the GValue.
The function takes the following parameters:
- value: gobject.Value initialized with type GSK_TYPE_RENDER_NODE.
- node (optional): render node.
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. Must be positive.
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: GskRoundedRect 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() [4]gdk.RGBA
Colors retrieves the colors of the border.
The function returns the following values:
- rgbAs: array of 4 GdkRGBA 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 renders a GSK rendernode tree with 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 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.
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 FillNode ¶
type FillNode struct {
RenderNode
// contains filtered or unexported fields
}
FillNode: render node filling the area given by gsk.Path and gsk.FillRule with the child node.
func NewFillNode ¶
func NewFillNode(child RenderNoder, path *Path, fillRule FillRule) *FillNode
NewFillNode creates a GskRenderNode that will fill the child in the area given by path and fill_rule.
The function takes the following parameters:
- child: node to fill the area with.
- path describing the area to fill.
- fillRule: fill rule to use.
The function returns the following values:
- fillNode: new GskRenderNode.
func (*FillNode) Child ¶
func (node *FillNode) Child() RenderNoder
Child gets the child node that is getting drawn by the given node.
The function returns the following values:
- renderNode: child that is getting drawn.
type FillRule ¶
FillRule specifies 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.
const ( // FillRuleWinding: 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. FillRuleWinding FillRule = iota // FillRuleEvenOdd 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. FillRuleEvenOdd )
type GLShader
deprecated
GLShader implements a fragment shader using GLSL.
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 "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 contains 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;
}
Deprecated: 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.
func NewGLShaderFromBytes
deprecated
NewGLShaderFromBytes creates a GskGLShader that will render pixels using the specified code.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
NewGLShaderFromResource creates a GskGLShader that will render pixels using the specified code.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgBool gets the value of the uniform idx in the args block.
The uniform must be of bool type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgFloat gets the value of the uniform idx in the args block.
The uniform must be of float type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgInt gets the value of the uniform idx in the args block.
The uniform must be of int type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgUint gets the value of the uniform idx in the args block.
The uniform must be of uint type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgVec2 gets the value of the uniform idx in the args block.
The uniform must be of vec2 type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgVec3 gets the value of the uniform idx in the args block.
The uniform must be of vec3 type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgVec4 gets the value of the uniform idx in the args block.
The uniform must be of vec4 type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
ArgsSize: get the size of the data block used to specify arguments for this shader.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function returns the following values:
- gsize: size of the data block.
func (*GLShader) Compile
deprecated
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.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- renderer: GskRenderer.
func (*GLShader) FindUniformByName
deprecated
FindUniformByName looks for a uniform by the name name, and returns the index of the uniform, or -1 if it was not found.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
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.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function returns the following values:
- gint: number of texture inputs required by shader.
func (*GLShader) NUniforms
deprecated
NUniforms: get the number of declared uniforms for this shader.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function returns the following values:
- gint: number of declared uniforms.
func (*GLShader) Resource
deprecated
Resource gets the resource path for the GLSL sourcecode being used to render this shader.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function returns the following values:
- utf8 (optional): resource path for the shader.
func (*GLShader) Source
deprecated
Source gets the GLSL sourcecode being used to render this shader.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function returns the following values:
- bytes: source code for the shader.
func (*GLShader) UniformName
deprecated
UniformName: get the name of the declared uniform for this shader at index idx.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
UniformOffset: get the offset into the data block where data for this uniforms is stored.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- idx: index of the uniform.
The function returns the following values:
- gint: data offset.
func (*GLShader) UniformType
deprecated
func (shader *GLShader) UniformType(idx int) GLUniformType
UniformType: get the type of the declared uniform for this shader at index idx.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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 ¶
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
deprecated
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.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- shader: GskGLShader.
- bounds: rectangle to render the shader into.
- args arguments for the uniforms.
- children (optional): 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
deprecated
func (node *GLShaderNode) Args() *glib.Bytes
Args gets args for the node.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function returns the following values:
- bytes: GBytes with the uniform arguments.
func (*GLShaderNode) Child
deprecated
func (node *GLShaderNode) Child(idx uint) RenderNoder
Child gets one of the children.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
func (node *GLShaderNode) NChildren() uint
NChildren returns the number of children
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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: GskGLShader shader.
type GLShaderOverrides ¶
type GLShaderOverrides struct {
}
GLShaderOverrides contains methods that are overridable.
type GLUniformType
deprecated
GLUniformType 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.
Deprecated: since version 4.16.
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 value returned by this function will not be correct if the render node was created for a non-sRGB color.
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 LineCap ¶
LineCap 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>.
const ( // LineCapButt: start and stop the line exactly at the start and end point. LineCapButt LineCap = iota // LineCapRound: use a round ending, the center of the circle is the start // or end point. LineCapRound // LineCapSquare: use squared ending, the center of the square is the start // or end point. LineCapSquare )
type LineJoin ¶
LineJoin 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>.
const ( // LineJoinMiter: use a sharp angled corner. LineJoinMiter LineJoin = iota // LineJoinRound: use a round join, the center of the circle is the join // point. LineJoinRound // LineJoinBevel: use a cut-off join, the join is cut off at half the line // width from the joint point. LineJoinBevel )
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 MaskMode ¶
MaskMode: mask modes available for mask nodes.
const ( // MaskModeAlpha: use the alpha channel of the mask. MaskModeAlpha MaskMode = iota // MaskModeInvertedAlpha: use the inverted alpha channel of the mask. MaskModeInvertedAlpha // MaskModeLuminance: use the luminance of the mask, multiplied by mask // alpha. MaskModeLuminance // MaskModeInvertedLuminance: use the inverted luminance of the mask, // multiplied by mask alpha. MaskModeInvertedLuminance )
type MaskNode ¶
type MaskNode struct {
RenderNode
// contains filtered or unexported fields
}
MaskNode: render node masking one child node with another.
func NewMaskNode ¶
func NewMaskNode(source, mask RenderNoder, maskMode MaskMode) *MaskNode
NewMaskNode 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.
The function takes the following parameters:
- source node to be drawn.
- mask: node to be used as mask.
- maskMode: mask mode to use.
The function returns the following values:
- maskNode: new GskRenderNode.
func (*MaskNode) Mask ¶
func (node *MaskNode) Mask() RenderNoder
Mask retrieves the mask GskRenderNode child of the node.
The function returns the following values:
- renderNode: mask child node.
func (*MaskNode) MaskMode ¶
MaskMode retrieves the mask mode used by node.
The function returns the following values:
- maskMode: mask mode.
func (*MaskNode) Source ¶
func (node *MaskNode) Source() RenderNoder
Source retrieves the source GskRenderNode child of the node.
The function returns the following values:
- renderNode: source child node.
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 value returned by this function will not be correct if the render node was created for a non-sRGB color.
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 Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path 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 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>
An instance of this type is always passed by reference.
func PathParse ¶
PathParse constructs a path from a serialized form.
The string is expected to be in (a superset of) SVG path syntax (https://www.w3.org/TR/SVG11/paths.htmlData), as e.g. produced by gsk.Path.ToString().
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.
The function takes the following parameters:
- str: string.
The function returns the following values:
- path (optional): new GskPath, or NULL if string could not be parsed.
func (*Path) Bounds ¶
Bounds 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.
The function returns the following values:
- bounds: return location for the bounds.
- ok: true if the path has bounds, false if the path is known to be empty and have no bounds.
func (*Path) ClosestPoint ¶
func (self *Path) ClosestPoint(point *graphene.Point, threshold float32) (*PathPoint, float32, bool)
ClosestPoint computes the closest point on the path to the given point.
If there is no point closer than the given threshold, false is returned.
The function takes the following parameters:
- point: point.
- threshold: maximum allowed distance.
The function returns the following values:
- result: return location for the closest point.
- distance (optional): return location for the distance.
- ok: true if point was set to the closest point on self, false if no point is closer than threshold.
func (*Path) EndPoint ¶
EndPoint gets the end point of the path.
An empty path has no points, so false is returned in this case.
The function returns the following values:
- result: return location for point.
- ok: true if result was filled.
func (*Path) ForEach ¶
func (self *Path) ForEach(flags PathForEachFlags, fn PathForEachFunc) bool
ForEach 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.
The function takes the following parameters:
- flags to pass to the foreach function.
- fn: function to call for operations.
The function returns the following values:
- ok: false if func returned false, true otherwise.
func (*Path) InFill ¶
InFill returns whether a point is inside the fill area of a path.
Note that this function assumes that filling a contour implicitly closes it.
The function takes the following parameters:
- point to test.
- fillRule: fill rule to follow.
The function returns the following values:
- ok: true if point is inside.
func (*Path) IsClosed ¶
IsClosed returns if the path represents a single closed contour.
The function returns the following values:
- ok: true if the path is closed.
func (*Path) IsEmpty ¶
IsEmpty checks if the path is empty, i.e. contains no lines or curves.
The function returns the following values:
- ok: true if the path is empty.
func (*Path) StartPoint ¶
StartPoint gets the start point of the path.
An empty path has no points, so false is returned in this case.
The function returns the following values:
- result: return location for point.
- ok: true if result was filled.
func (*Path) String ¶
String converts the path into a human-readable string.
You can use this function in a debugger to get a quick overview of the path.
This is a wrapper around gsk.Path.Print(), see that function for details.
The function returns the following values:
- utf8: new string for self.
func (*Path) StrokeBounds ¶
StrokeBounds computes the bounds for stroking the given path with the given parameters.
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.
The function takes the following parameters:
- stroke parameters.
The function returns the following values:
- bounds to fill in.
- ok: true if the path has bounds, false if the path is known to be empty and have no bounds.
func (*Path) ToCairo ¶
ToCairo appends the path to a 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.
The function takes the following parameters:
- cr: cairo context.
type PathBuilder ¶
type PathBuilder struct {
// contains filtered or unexported fields
}
PathBuilder constructs GskPath objects.
A path is constructed like this:
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 gsk.PathBuilder.AddCircle() or by adding from other paths like gsk.PathBuilder.AddPath().
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 gsk.PathBuilder.MoveTo() 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 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.
An instance of this type is always passed by reference.
func NewPathBuilder ¶
func NewPathBuilder() *PathBuilder
NewPathBuilder constructs a struct PathBuilder.
func (*PathBuilder) AddCircle ¶
func (self *PathBuilder) AddCircle(center *graphene.Point, radius float32)
AddCircle adds a circle as a new contour.
The path is going around the circle in clockwise direction.
If radius is zero, the contour will be a closed point.
The function takes the following parameters:
- center of the circle.
- radius of the circle.
func (*PathBuilder) AddLayout ¶
func (self *PathBuilder) AddLayout(layout *pango.Layout)
AddLayout adds the outlines for the glyphs in layout to the builder.
The function takes the following parameters:
- layout: pango layout to add.
func (*PathBuilder) AddPath ¶
func (self *PathBuilder) AddPath(path *Path)
AddPath appends all of path to the builder.
The function takes the following parameters:
- path to append.
func (*PathBuilder) AddRect ¶
func (self *PathBuilder) AddRect(rect *graphene.Rect)
AddRect adds a rectangle as a new contour.
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.
The function takes the following parameters:
- rect: rectangle to create a path for.
func (*PathBuilder) AddReversePath ¶
func (self *PathBuilder) AddReversePath(path *Path)
AddReversePath appends all of path to the builder, in reverse order.
The function takes the following parameters:
- path to append.
func (*PathBuilder) AddRoundedRect ¶
func (self *PathBuilder) AddRoundedRect(rect *RoundedRect)
AddRoundedRect adds a rounded rectangle as a new contour.
The path is going around the rectangle in clockwise direction.
The function takes the following parameters:
- rect: rounded rect.
func (*PathBuilder) AddSegment ¶
func (self *PathBuilder) AddSegment(path *Path, start *PathPoint, end *PathPoint)
AddSegment adds a segment of a path to the builder.
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 gsk.PathBuilder.AddPath().
The function takes the following parameters:
- path to take the segment to.
- start: point on path to start at.
- end: point on path to end at.
func (*PathBuilder) ArcTo ¶
func (self *PathBuilder) ArcTo(x1 float32, y1 float32, x2 float32, y2 float32)
ArcTo 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 gsk.PathBuilder.ConicTo() or gsk.PathBuilder.SVGArcTo().
<picture> <source srcset="arc-dark.png" media="(prefers-color-scheme: dark)"> <img alt="Arc To" src="arc-light.png"> </picture>.
The function takes the following parameters:
- x1: x coordinate of first control point.
- y1: y coordinate of first control point.
- x2: x coordinate of second control point.
- y2: y coordinate of second control point.
func (*PathBuilder) Close ¶
func (self *PathBuilder) Close()
Close ends the current contour with a line back to the start point.
Note that this is different from calling gsk.PathBuilder.LineTo() 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.
func (*PathBuilder) ConicTo ¶
ConicTo 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>.
The function takes the following parameters:
- x1: x coordinate of control point.
- y1: y coordinate of control point.
- x2: x coordinate of the end of the curve.
- y2: y coordinate of the end of the curve.
- weight of the control point, must be greater than zero.
func (*PathBuilder) CubicTo ¶
func (self *PathBuilder) CubicTo(x1 float32, y1 float32, x2 float32, y2 float32, x3 float32, y3 float32)
CubicTo adds a cubic Bézier curve (https://en.wikipedia.org/wiki/BC3A9zier_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>.
The function takes the following parameters:
- x1: x coordinate of first control point.
- y1: y coordinate of first control point.
- x2: x coordinate of second control point.
- y2: y coordinate of second control point.
- x3: x coordinate of the end of the curve.
- y3: y coordinate of the end of the curve.
func (*PathBuilder) CurrentPoint ¶
func (self *PathBuilder) CurrentPoint() *graphene.Point
CurrentPoint 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 function returns the following values:
- point: current point.
func (*PathBuilder) HtmlArcTo ¶
HtmlArcTo 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.
The function takes the following parameters:
- x1: x coordinate of first control point.
- y1: y coordinate of first control point.
- x2: x coordinate of second control point.
- y2: y coordinate of second control point.
- radius of the circle.
func (*PathBuilder) LineTo ¶
func (self *PathBuilder) LineTo(x float32, y float32)
LineTo 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>.
The function takes the following parameters:
- x coordinate.
- y coordinate.
func (*PathBuilder) MoveTo ¶
func (self *PathBuilder) MoveTo(x float32, y float32)
MoveTo 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.
The function takes the following parameters:
- x coordinate.
- y coordinate.
func (*PathBuilder) QuadTo ¶
func (self *PathBuilder) QuadTo(x1 float32, y1 float32, x2 float32, y2 float32)
QuadTo adds a quadratic Bézier curve (https://en.wikipedia.org/wiki/BC3A9zier_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>.
The function takes the following parameters:
- x1: x coordinate of control point.
- y1: y coordinate of control point.
- x2: x coordinate of the end of the curve.
- y2: y coordinate of the end of the curve.
func (*PathBuilder) RelArcTo ¶
func (self *PathBuilder) RelArcTo(x1 float32, y1 float32, x2 float32, y2 float32)
RelArcTo 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 gsk.PathBuilder.ArcTo().
The function takes the following parameters:
- x1: x coordinate of first control point.
- y1: y coordinate of first control point.
- x2: x coordinate of second control point.
- y2: y coordinate of second control point.
func (*PathBuilder) RelConicTo ¶
RelConicTo 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 gsk.PathBuilder.ConicTo().
The function takes the following parameters:
- x1: x offset of control point.
- y1: y offset of control point.
- x2: x offset of the end of the curve.
- y2: y offset of the end of the curve.
- weight of the curve, must be greater than zero.
func (*PathBuilder) RelCubicTo ¶
func (self *PathBuilder) RelCubicTo(x1 float32, y1 float32, x2 float32, y2 float32, x3 float32, y3 float32)
RelCubicTo adds a cubic Bézier curve (https://en.wikipedia.org/wiki/BC3A9zier_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 gsk.PathBuilder.CubicTo().
The function takes the following parameters:
- x1: x offset of first control point.
- y1: y offset of first control point.
- x2: x offset of second control point.
- y2: y offset of second control point.
- x3: x offset of the end of the curve.
- y3: y offset of the end of the curve.
func (*PathBuilder) RelHtmlArcTo ¶
func (self *PathBuilder) RelHtmlArcTo(x1 float32, y1 float32, x2 float32, y2 float32, radius float32)
RelHtmlArcTo implements arc-to according to the HTML Canvas spec.
All coordinates are given relative to the current point.
This is the relative version of gsk.PathBuilder.HtmlArcTo().
The function takes the following parameters:
- x1: x coordinate of first control point.
- y1: y coordinate of first control point.
- x2: x coordinate of second control point.
- y2: y coordinate of second control point.
- radius of the circle.
func (*PathBuilder) RelLineTo ¶
func (self *PathBuilder) RelLineTo(x float32, y float32)
RelLineTo 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 gsk.PathBuilder.LineTo().
The function takes the following parameters:
- x offset.
- y offset.
func (*PathBuilder) RelMoveTo ¶
func (self *PathBuilder) RelMoveTo(x float32, y float32)
RelMoveTo starts a new contour by placing the pen at x, y relative to the current point.
This is the relative version of gsk.PathBuilder.MoveTo().
The function takes the following parameters:
- x offset.
- y offset.
func (*PathBuilder) RelQuadTo ¶
func (self *PathBuilder) RelQuadTo(x1 float32, y1 float32, x2 float32, y2 float32)
RelQuadTo adds a quadratic Bézier curve (https://en.wikipedia.org/wiki/BC3A9zier_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 gsk.PathBuilder.QuadTo().
The function takes the following parameters:
- x1: x offset of control point.
- y1: y offset of control point.
- x2: x offset of the end of the curve.
- y2: y offset of the end of the curve.
func (*PathBuilder) RelSVGArcTo ¶
func (self *PathBuilder) RelSVGArcTo(rx float32, ry float32, xAxisRotation float32, largeArc bool, positiveSweep bool, x float32, y float32)
RelSVGArcTo implements arc-to according to the SVG spec.
All coordinates are given relative to the current point.
This is the relative version of gsk.PathBuilder.SVGArcTo().
The function takes the following parameters:
- rx: x radius.
- ry: y radius.
- xAxisRotation: rotation of the ellipsis.
- largeArc: whether to add the large arc.
- positiveSweep: whether to sweep in the positive direction.
- x coordinate of the endpoint.
- y coordinate of the endpoint.
func (*PathBuilder) SVGArcTo ¶
func (self *PathBuilder) SVGArcTo(rx float32, ry float32, xAxisRotation float32, largeArc bool, positiveSweep bool, x float32, y float32)
SVGArcTo implements arc-to according to the SVG spec.
A convenience function that implements the SVG arc_to (https://www.w3.org/TR/SVG11/paths.htmlDataEllipticalArcCommands) functionality.
After this, x, y will be the new current point.
The function takes the following parameters:
- rx: x radius.
- ry: y radius.
- xAxisRotation: rotation of the ellipsis.
- largeArc: whether to add the large arc.
- positiveSweep: whether to sweep in the positive direction.
- x coordinate of the endpoint.
- y coordinate of the endpoint.
func (*PathBuilder) ToPath ¶
func (self *PathBuilder) ToPath() *Path
ToPath creates a new path 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 gsk.PathBuilder.FreeToPath().
The function returns the following values:
- path: newly created path with all the contours added to the builder.
type PathDirection ¶
PathDirection: 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>.
const ( // PathFromStart: tangent in path direction of the incoming side of the // path. PathFromStart PathDirection = iota // PathToStart: tangent against path direction of the incoming side of the // path. PathToStart // PathToEnd: tangent in path direction of the outgoing side of the path. PathToEnd // PathFromEnd: tangent against path direction of the outgoing side of the // path. PathFromEnd )
func (PathDirection) String ¶
func (p PathDirection) String() string
String returns the name in string for PathDirection.
type PathForEachFlags ¶
PathForEachFlags flags that can be passed to gsk_path_foreach() to influence what kinds of operations the path is decomposed into.
By default, 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.
const ( // PathForEachAllowOnlyLines: default behavior, only allow lines. PathForEachAllowOnlyLines PathForEachFlags = 0b0 // PathForEachAllowQuad: allow emission of GSK_PATH_QUAD operations. PathForEachAllowQuad PathForEachFlags = 0b1 // PathForEachAllowCubic: allow emission of GSK_PATH_CUBIC operations. PathForEachAllowCubic PathForEachFlags = 0b10 // PathForEachAllowConic: allow emission of GSK_PATH_CONIC operations. PathForEachAllowConic PathForEachFlags = 0b100 )
func (PathForEachFlags) Has ¶
func (p PathForEachFlags) Has(other PathForEachFlags) bool
Has returns true if p contains other.
func (PathForEachFlags) String ¶
func (p PathForEachFlags) String() string
String returns the names in string for PathForEachFlags.
type PathForEachFunc ¶
type PathForEachFunc func(op PathOperation, pts *graphene.Point, nPts uint, weight float32) (ok bool)
PathForEachFunc: type 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.
type PathMeasure ¶
type PathMeasure struct {
// contains filtered or unexported fields
}
PathMeasure performs measurements on paths 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.
An instance of this type is always passed by reference.
func NewPathMeasure ¶
func NewPathMeasure(path *Path) *PathMeasure
NewPathMeasure constructs a struct PathMeasure.
func NewPathMeasureWithTolerance ¶
func NewPathMeasureWithTolerance(path *Path, tolerance float32) *PathMeasure
NewPathMeasureWithTolerance constructs a struct PathMeasure.
func (*PathMeasure) Length ¶
func (self *PathMeasure) Length() float32
Length gets the length of the path being measured.
The length is cached, so this function does not do any work.
The function returns the following values:
- gfloat: length of the path measured by self.
func (*PathMeasure) Path ¶
func (self *PathMeasure) Path() *Path
Path returns the path that the measure was created for.
The function returns the following values:
- path of self.
func (*PathMeasure) Point ¶
func (self *PathMeasure) Point(distance float32) (*PathPoint, bool)
Point gets the point at the given distance into the path.
An empty path has no points, so false is returned in that case.
The function takes the following parameters:
- distance: distance.
The function returns the following values:
- result: return location for the point.
- ok: true if result was set.
func (*PathMeasure) Tolerance ¶
func (self *PathMeasure) Tolerance() float32
Tolerance returns the tolerance that the measure was created with.
The function returns the following values:
- gfloat: tolerance of self.
type PathOperation ¶
PathOperation describes the segments of a GskPath.
More values may be added in the future.
const ( // PathMove: move-to operation, with 1 point describing the target point. PathMove PathOperation = iota // PathClose: close operation ending the current contour with a line back to // the starting point. Two points describe the start and end of the line. PathClose // PathLine: line-to operation, with 2 points describing the start and end // point of a straight line. PathLine // PathQuad: 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. PathQuad // PathCubic: 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. PathCubic // PathConic: 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. PathConic )
func (PathOperation) String ¶
func (p PathOperation) String() string
String returns the name in string for PathOperation.
type PathPoint ¶
type PathPoint struct {
// contains filtered or unexported fields
}
PathPoint represents 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 gsk.Path.GetClosestPoint(), gsk.Path.GetStartPoint(), gsk.Path.GetEndPoint() or gsk.PathMeasure.GetPoint().
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.
An instance of this type is always passed by reference.
func (*PathPoint) Compare ¶
Compare returns whether point1 is before or after point2.
The function takes the following parameters:
- point2: another path point.
The function returns the following values:
- gint: -1 if point1 is before point2, 1 if point1 is after point2, 0 if they are equal.
func (*PathPoint) Copy ¶
Copy copies a path point.
The function returns the following values:
- pathPoint: copied point.
func (*PathPoint) Curvature ¶
Curvature 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 function takes the following parameters:
- path that point is on.
- direction for which to return the curvature.
The function returns the following values:
- center (optional): return location for the center of the osculating circle.
- gfloat: curvature of the path at the given point.
func (*PathPoint) Distance ¶
func (point *PathPoint) Distance(measure *PathMeasure) float32
Distance returns the distance from the beginning of the path to the point.
The function takes the following parameters:
- measure: path measure for the path.
The function returns the following values:
- gfloat: distance of point.
func (*PathPoint) Equal ¶
Equal 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 gsk.Path.IsClosed() to find out if the start- and endpoint of a concrete path refer to the same location.
The function takes the following parameters:
- point2: another path point.
The function returns the following values:
- ok: true if point1 and point2 are equal.
func (*PathPoint) Position ¶
Position gets the position of the point.
The function takes the following parameters:
- path that point is on.
The function returns the following values:
- position: return location for the coordinates of the point.
func (*PathPoint) Rotation ¶
func (point *PathPoint) Rotation(path *Path, direction PathDirection) float32
Rotation gets the direction of the tangent at a given point.
This is a convenience variant of gsk.PathPoint.GetTangent() 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 function takes the following parameters:
- path that point is on.
- direction for which to return the rotation.
The function returns the following values:
- gfloat: angle between the tangent and the X axis, in degrees.
func (*PathPoint) Tangent ¶
func (point *PathPoint) Tangent(path *Path, direction PathDirection) *graphene.Vec2
Tangent 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 the tangent is set to 0, 0.
If you want to orient something in the direction of the path, gsk.PathPoint.GetRotation() may be more convenient to use.
The function takes the following parameters:
- path that point is on.
- direction for which to return the tangent.
The function returns the following values:
- tangent: return location for the tangent at the point.
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 vertical 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 horizontal 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: basic block in a scene graph to be rendered using 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 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 draws the contents of a render node on a cairo context.
Typically, you'll use this function to implement fallback rendering of render nodes on an intermediate Cairo context, instead of using the drawing context associated to a 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.
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 render node.
The function returns the following values:
- renderNodeType: type of node.
func (*RenderNode) OpaqueRect ¶
func (self *RenderNode) OpaqueRect() (*graphene.Rect, bool)
OpaqueRect 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.
The function returns the following values:
- outOpaque: return location for the opaque rect.
- ok: true if part or all of the rendernode is opaque, false if no opaque region could be found.
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: GBytes representing the node.
func (*RenderNode) WriteToFile ¶
func (node *RenderNode) WriteToFile(filename string) error
WriteToFile: this function is equivalent to calling gsk.RenderNode.Serialize() followed by glib.FileSetContents().
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 GdkTexture. 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 // TextureScaleNodeType: node drawing a GdkTexture scaled and filtered. TextureScaleNodeType // MaskNodeType: node that masks one child with another. MaskNodeType // FillNodeType: node that fills a path. FillNodeType // StrokeNodeType: node that strokes a path. StrokeNodeType // SubsurfaceNodeType: node that possibly redirects part of the scene graph // to a subsurface. SubsurfaceNodeType )
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.RenderNode.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.
The function returns the following values:
- renderNode (optional): new render node.
func ValueDupRenderNode ¶
func ValueDupRenderNode(value *coreglib.Value) RenderNoder
ValueDupRenderNode retrieves the render node stored inside a GValue, and acquires a reference to it.
The function takes the following parameters:
- value: gobject.Value initialized with type GSK_TYPE_RENDER_NODE.
The function returns the following values:
- renderNode (optional): render node.
func ValueGetRenderNode ¶
func ValueGetRenderNode(value *coreglib.Value) RenderNoder
ValueGetRenderNode retrieves the render node stored inside a GValue.
The function takes the following parameters:
- value: GValue initialized with type GSK_TYPE_RENDER_NODE.
The function returns the following values:
- renderNode (optional): render node.
type Renderer ¶
Renderer 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 ¶
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: surface.
The function returns the following values:
- renderer (optional): realized renderer.
func (*Renderer) IsRealized ¶
IsRealized checks whether the renderer is realized or not.
The function returns the following values:
- ok: true if the renderer was realized, false otherwise.
func (*Renderer) Realize ¶
Realize creates the resources needed by the renderer.
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 gsk.Renderer.RealizeForDisplay() for this case.
Note that it is mandatory to call gsk.Renderer.Unrealize() before destroying the renderer.
The function takes the following parameters:
- surface (optional) that renderer will be used on.
func (*Renderer) RealizeForDisplay ¶
RealizeForDisplay creates the resources needed by the renderer.
Note that it is mandatory to call gsk.Renderer.Unrealize() before destroying the renderer.
The function takes the following parameters:
- display that the 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 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.
The function takes the following parameters:
- root: render node to render.
- region (optional): cairo_region_t that must be redrawn or NULL for the whole surface.
func (*Renderer) RenderTexture ¶
RenderTexture renders a scene graph, described by a tree of GskRenderNode instances, to a texture.
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: render node to render.
- viewport (optional): section to draw or NULL to use root's bounds.
The function returns the following values:
- texture 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 vertical 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 rectangle 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 a rounded rectangle with the given values.
This function will implicitly normalize the rounded rectangle 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 rounded rectangle.
func (*RoundedRect) InitCopy ¶
func (self *RoundedRect) InitCopy(src *RoundedRect) *RoundedRect
InitCopy initializes a rounded rectangle with a copy.
This function will not normalize the rounded rectangle, so make sure the source is normalized.
The function takes the following parameters:
- src: another rounded rectangle.
The function returns the following values:
- roundedRect: initialized rounded rectangle.
func (*RoundedRect) InitFromRect ¶
func (self *RoundedRect) InitFromRect(bounds *graphene.Rect, radius float32) *RoundedRect
InitFromRect initializes a rounded rectangle to the given bounds and sets the radius of all four corners equally.
The function takes the following parameters:
- bounds: graphene_rect_t.
- radius: border radius.
The function returns the following values:
- roundedRect: initialized rounded rectangle.
func (*RoundedRect) IntersectsRect ¶
func (self *RoundedRect) IntersectsRect(rect *graphene.Rect) bool
IntersectsRect checks if part a rectangle 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 a rounded rectangle 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 rounded rectangle is rectilinear.
func (*RoundedRect) Normalize ¶
func (self *RoundedRect) Normalize() *RoundedRect
Normalize normalizes a rounded rectangle.
This function will ensure that the bounds of the rounded 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 rounded rectangle.
func (*RoundedRect) Offset ¶
func (self *RoundedRect) Offset(dx float32, dy float32) *RoundedRect
Offset offsets the rounded rectangle's origin by dx and dy.
The size and corners of the rounded rectangle are unchanged.
The function takes the following parameters:
- dx: horizontal offset.
- dy: vertical offset.
The function returns the following values:
- roundedRect: offset rounded rectangle.
func (*RoundedRect) Shrink ¶
func (self *RoundedRect) Shrink(top float32, right float32, bottom float32, left float32) *RoundedRect
Shrink shrinks (or grows) a rounded 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 rounded 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 rounded rectangle.
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
deprecated
type ShaderArgsBuilder struct {
// contains filtered or unexported fields
}
ShaderArgsBuilder builds the uniforms data for a GskGLShader.
Deprecated: since version 4.16.
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
deprecated
func (builder *ShaderArgsBuilder) SetBool(idx int, value bool)
SetBool sets the value of the uniform idx.
The uniform must be of bool type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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
deprecated
func (builder *ShaderArgsBuilder) SetInt(idx int, value int32)
SetInt sets the value of the uniform idx.
The uniform must be of int type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform to.
func (*ShaderArgsBuilder) SetUint
deprecated
func (builder *ShaderArgsBuilder) SetUint(idx int, value uint32)
SetUint sets the value of the uniform idx.
The uniform must be of uint type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform to.
func (*ShaderArgsBuilder) SetVec2
deprecated
func (builder *ShaderArgsBuilder) SetVec2(idx int, value *graphene.Vec2)
SetVec2 sets the value of the uniform idx.
The uniform must be of vec2 type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform too.
func (*ShaderArgsBuilder) SetVec3
deprecated
func (builder *ShaderArgsBuilder) SetVec3(idx int, value *graphene.Vec3)
SetVec3 sets the value of the uniform idx.
The uniform must be of vec3 type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform too.
func (*ShaderArgsBuilder) SetVec4
deprecated
func (builder *ShaderArgsBuilder) SetVec4(idx int, value *graphene.Vec4)
SetVec4 sets the value of the uniform idx.
The uniform must be of vec4 type.
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
The function takes the following parameters:
- idx: index of the uniform.
- value to set the uniform too.
func (*ShaderArgsBuilder) ToArgs
deprecated
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().
Deprecated: GTK's new Vulkan-focused rendering does not support this feature. Use GtkGLArea (../gtk4/class.GLArea.html) for OpenGL rendering.
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 Stroke ¶
type Stroke struct {
// contains filtered or unexported fields
}
Stroke collects the parameters that are needed when stroking a path.
An instance of this type is always passed by reference.
func (*Stroke) Copy ¶
Copy creates a copy of a GskStroke.
The function returns the following values:
- stroke: new GskStroke. Use gsk.Stroke.Free() to free it.
func (*Stroke) Dash ¶
Dash gets the dash array in use.
The function returns the following values:
- gfloats (optional): the dash array or NULL if the dash array is empty.
func (*Stroke) DashOffset ¶
DashOffset gets the dash offset.
The function returns the following values:
- gfloat: dash offset.
func (*Stroke) LineCap ¶
LineCap gets the line cap used.
See gsk.LineCap for details.
The function returns the following values:
- lineCap: line cap.
func (*Stroke) LineJoin ¶
LineJoin gets the line join used.
See gsk.LineJoin for details.
The function returns the following values:
- lineJoin: line join.
func (*Stroke) LineWidth ¶
LineWidth gets the line width used.
The function returns the following values:
- gfloat: line width.
func (*Stroke) MiterLimit ¶
MiterLimit gets the miter limit.
The function returns the following values:
- gfloat: miter limit.
func (*Stroke) SetDash ¶
SetDash sets the dash pattern to use.
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.LineCap.Round or gsk.LineCap.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 gsk.Stroke.SetDashOffset().
The function takes the following parameters:
- dash (optional): the array of dashes.
func (*Stroke) SetDashOffset ¶
SetDashOffset 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 gsk.Stroke.SetDash() for more details on dashing.
The function takes the following parameters:
- offset into the dash pattern.
func (*Stroke) SetLineCap ¶
SetLineCap sets the line cap to be used when stroking.
See gsk.LineCap for details.
The function takes the following parameters:
- lineCap: line cap.
func (*Stroke) SetLineJoin ¶
SetLineJoin sets the line join to be used when stroking.
See gsk.LineJoin for details.
The function takes the following parameters:
- lineJoin: line join to use.
func (*Stroke) SetLineWidth ¶
SetLineWidth sets the line width to be used when stroking.
The line width must be > 0.
The function takes the following parameters:
- lineWidth: width of the line in pixels.
func (*Stroke) SetMiterLimit ¶
SetMiterLimit sets the miter limit to be used when stroking.
The miter limit is the distance from the corner where sharp turns of joins get cut off.
The limit is specfied in units of line width and must be non-negative.
For joins of type gsk.LineJoin.Miter that exceed the miter limit, the join gets rendered as if it was of type gsk.LineJoin.Bevel.
The function takes the following parameters:
- limit: miter limit.
type StrokeNode ¶
type StrokeNode struct {
RenderNode
// contains filtered or unexported fields
}
StrokeNode: render node that will fill the area determined by stroking the the given gsk.Path using the gsk.Stroke attributes.
func NewStrokeNode ¶
func NewStrokeNode(child RenderNoder, path *Path, stroke *Stroke) *StrokeNode
NewStrokeNode creates a RenderNode that will fill the outline generated by stroking the given path using the attributes defined in stroke.
The area is filled with child.
The function takes the following parameters:
- child: node to stroke the area with.
- path describing the area to stroke.
- stroke attributes to use.
The function returns the following values:
- strokeNode: new RenderNode.
func (*StrokeNode) Child ¶
func (node *StrokeNode) Child() RenderNoder
Child gets the child node that is getting drawn by the given node.
The function returns the following values:
- renderNode: child that is getting drawn.
func (*StrokeNode) Path ¶
func (node *StrokeNode) Path() *Path
Path retrieves the path that will be stroked with the contents of the node.
The function returns the following values:
- path: Path.
func (*StrokeNode) Stroke ¶
func (node *StrokeNode) Stroke() *Stroke
Stroke retrieves the stroke attributes used in this node.
The function returns the following values:
- stroke: Stroke.
type SubsurfaceNode ¶
type SubsurfaceNode struct {
RenderNode
// contains filtered or unexported fields
}
SubsurfaceNode: render node that potentially diverts a part of the scene graph to a subsurface.
func (*SubsurfaceNode) Child ¶
func (node *SubsurfaceNode) 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 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: PangoFont containing the glyphs.
- glyphs: PangoGlyphString 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 ¶
Color retrieves the color used by the text node.
The value returned by this function will not be correct if the render node was created for a non-sRGB color.
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 GdkTexture.
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.
Note that GSK applies linear filtering when textures are scaled and transformed. See gsk.TextureScaleNode for a way to influence filtering.
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 TextureScaleNode ¶
type TextureScaleNode struct {
RenderNode
// contains filtered or unexported fields
}
TextureScaleNode: render node for a GdkTexture, with control over scaling.
func NewTextureScaleNode ¶
func NewTextureScaleNode(texture gdk.Texturer, bounds *graphene.Rect, filter ScalingFilter) *TextureScaleNode
NewTextureScaleNode 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.
The function takes the following parameters:
- texture to scale.
- bounds: size of the texture to scale to.
- filter: how to scale the texture.
The function returns the following values:
- textureScaleNode: new GskRenderNode.
func (*TextureScaleNode) Filter ¶
func (node *TextureScaleNode) Filter() ScalingFilter
Filter retrieves the GskScalingFilter used when creating this GskRenderNode.
The function returns the following values:
- scalingFilter: GskScalingFilter.
func (*TextureScaleNode) Texture ¶
func (node *TextureScaleNode) 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 describes a 3D transform.
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 a given into a 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: return location for the transform.
- 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.
This function consumes self. Use gsk.Transform.Ref() first if you want to keep it around.
The function returns the following values:
- transform (optional): inverted transform.
func (*Transform) Matrix ¶
Matrix multiplies next with the given matrix.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
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.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
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 by an angle around the Z axis.
The rotation happens around the origin point of (0, 0).
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
The function takes the following parameters:
- angle: rotation angle, in degrees (clockwise).
The function returns the following values:
- transform (optional): new transform.
func (*Transform) Rotate3D ¶
Rotate3D rotates next angle degrees around axis.
For a rotation in 2D space, use gsk.Transform.Rotate()
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
The function takes the following parameters:
- angle: rotation angle, in degrees (clockwise).
- axis: rotation axis.
The function returns the following values:
- transform (optional): 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.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
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 (optional): new transform.
func (*Transform) Scale3D ¶
Scale3D scales next by the given factors.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
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 (optional): new transform.
func (*Transform) Skew ¶
Skew applies a skew transform.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
The function takes the following parameters:
- skewX: skew factor, in degrees, on the X axis.
- skewY: skew factor, in degrees, on the Y axis.
The function returns the following values:
- transform (optional): new transform.
func (*Transform) String ¶
String converts the transform into a human-readable string.
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 transform 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 are a subset of the full 4x4 matrix that is computed by gsk.Transform.ToMatrix() and 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) To2DComponents ¶
func (self *Transform) To2DComponents() (outSkewX float32, outSkewY float32, outScaleX float32, outScaleY float32, outAngle float32, outDx float32, outDy float32)
To2DComponents converts a transform 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.
The function returns the following values:
- outSkewX: return location for the skew factor in the x direction.
- outSkewY: return location for the skew factor in the y direction.
- outScaleX: return location for the scale factor in the x direction.
- outScaleY: return location for the scale factor in the y direction.
- outAngle: return location for the rotation angle.
- outDx: return location for the translation in the x direction.
- outDy: return location for the translation in the y direction.
func (*Transform) ToAffine ¶
func (self *Transform) ToAffine() (outScaleX float32, outScaleY float32, outDx float32, outDy float32)
ToAffine converts a transform 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.
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 4x4 matrix for the transform.
The previous value of out_matrix will be ignored.
The function returns the following values:
- outMatrix: return location for the matrix.
func (*Transform) ToTranslate ¶
ToTranslate converts a transform 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.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
The function takes the following parameters:
- other (optional): transform to apply.
The function returns the following values:
- transform (optional): new transform.
func (*Transform) TransformBounds ¶
TransformBounds transforms a rectangle using the given transform.
The result is the bounding box containing the coplanar quad.
The function takes the following parameters:
- rect: rectangle to transform.
The function returns the following values:
- outRect: return location for the bounds of the transformed rectangle.
func (*Transform) TransformPoint ¶
TransformPoint transforms a point using the given transform.
The function takes the following parameters:
- point to transform.
The function returns the following values:
- outPoint: return location for the transformed point.
func (*Transform) Translate ¶
Translate translates next in 2-dimensional space by point.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
The function takes the following parameters:
- point to translate the transform by.
The function returns the following values:
- transform (optional): new transform.
func (*Transform) Translate3D ¶
Translate3D translates next by point.
This function consumes next. Use gsk.Transform.Ref() first if you want to keep it around.
The function takes the following parameters:
- point to translate the transform by.
The function returns the following values:
- transform (optional): new transform.
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.