Gnome::Gsk4::N-Transform

#------------------------------------------------------------------------------- #--[Class Description]---------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Description

Gnome::Gsk4::N-Transform is an object to describe transform matrices.

Unlike Gnome::Graphene::N-Matrix, Gnome::Gsk4::N-Transform retains the steps in how a transform was constructed, and allows inspecting them. It is modeled after the way CSS describes transforms.

Gnome::Gsk4::N-Transform 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.

=end rakudoc

#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Class initialization

new

:native-object

Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object() :$native-object! )

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

new-transform

No documentation of method new.

method new-transform ( --> Gnome::Gsk4::Transform \)

=end rakudoc

#------------------------------------------------------------------------------- #--[Methods]-------------------------------------------------------------------- #-------------------------------------------------------------------------------

=begin rakudoc

Methods =end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

equal

Checks two transforms for equality.

method equal ( N-Object $second --> Bool )
  • $second; the second transform

Return value; True if the two transforms perform the same operation.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

get-category

Returns the category this transform belongs to.

method get-category (--> GskTransformCategory )

Return value; The category of the transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

invert

Inverts the given transform.

If $self is not invertible, undefined is returned. Note that inverting undefined also returns undefined, which is the correct inverse of undefined. If you need to differentiate between those cases, you should check $self is defined before calling this function.

method invert (--> N-Object )

Return value; The inverted transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

matrix

Multiplies $next with the given $matrix.

method matrix ( N-Object $matrix --> N-Object )
  • $matrix; the matrix to multiply $next with

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

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.

method perspective ( Num() $depth --> N-Object )
  • $depth; distance of the z=0 plane. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect..

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

print

Converts $self into a human-readable string representation suitable for printing.

The result of this function can later be parsed with .Transform.parse().

method print ( N-Object $string )
  • $string; The string to print into

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

ref

Acquires a reference on the given Gnome::Gsk4::N-Transform.

method ref (--> N-Object )

Return value; the Gnome::Gsk4::N-Transform with an additional reference.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

rotate

Rotates $next $angle degrees in 2D - or in 3D-speak, around the z axis.

method rotate ( Num() $angle --> N-Object )
  • $angle; the rotation angle, in degrees (clockwise).

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

rotate-3d

Rotates $next $angle degrees around $axis.

For a rotation in 2D space, use .rotate()

method rotate-3d ( Num() $angle, N-Object $axis --> N-Object )
  • $angle; the rotation angle, in degrees (clockwise).

  • $axis; The rotation axis

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

scale

Scales $next in 2-dimensional space by the given factors.

Use .scale-3d() to scale in all 3 dimensions.

method scale ( Num() $factor-x, Num() $factor-y --> N-Object )
  • $factor-x; scaling factor on the X axis.

  • $factor-y; scaling factor on the Y axis.

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

scale-3d

Scales $next by the given factors.

method scale-3d ( Num() $factor-x, Num() $factor-y, Num() $factor-z --> N-Object )
  • $factor-x; scaling factor on the X axis.

  • $factor-y; scaling factor on the Y axis.

  • $factor-z; scaling factor on the Z axis.

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

skew

Applies a skew transform.

method skew ( Num() $skew-x, Num() $skew-y --> N-Object )
  • $skew-x; skew factor, in degrees, on the X axis.

  • $skew-y; skew factor, in degrees, on the Y axis.

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

to-2d

Converts a Gnome::Gsk4::N-Transform to a 2D transformation matrix. $self must be a 2D transformation. If you are not sure, use .get-category() >= %GSK_TRANSFORM_CATEGORY_2D to check.

The returned values have the following layout:

This function can be used to convert between a Gnome::Gsk4::N-Transform and a matrix type from other 2D drawing libraries, in particular Cairo.

method to-2d ( Num() $out-xx, Num() $out-yx, Num() $out-xy, Num() $out-yy, Num() $out-dx, Num() $out-dy )
  • $out-xx; (transfer ownership: full) return location for the xx member.

  • $out-yx; (transfer ownership: full) return location for the yx member.

  • $out-xy; (transfer ownership: full) return location for the xy member.

  • $out-yy; (transfer ownership: full) return location for the yy member.

  • $out-dx; (transfer ownership: full) return location for the x0 member.

  • $out-dy; (transfer ownership: full) return location for the y0 member.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

to-2d-components

Converts a Gnome::Gsk4::N-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)
 C<$self> must be a 2D transformation. If you are not sure, use
C<.get-category()> >= %GSK_TRANSFORM_CATEGORY_2D

to check.

method to-2d-components ( Num() $out-skew-x, Num() $out-skew-y, Num() $out-scale-x, Num() $out-scale-y, Num() $out-angle, Num() $out-dx, Num() $out-dy )
  • $out-skew-x; (transfer ownership: full) return location for the skew factor in the x direction.

  • $out-skew-y; (transfer ownership: full) return location for the skew factor in the y direction.

  • $out-scale-x; (transfer ownership: full) return location for the scale factor in the x direction.

  • $out-scale-y; (transfer ownership: full) return location for the scale factor in the y direction.

  • $out-angle; (transfer ownership: full) return location for the rotation angle.

  • $out-dx; (transfer ownership: full) return location for the translation in the x direction.

  • $out-dy; (transfer ownership: full) return location for the translation in the y direction.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

to-affine

Converts a Gnome::Gsk4::N-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)
 C<$self> must be a 2D affine transformation. If you are not
sure, use
C<.get-category()> >= %GSK_TRANSFORM_CATEGORY_2D_AFFINE

to check.

method to-affine ( Num() $out-scale-x, Num() $out-scale-y, Num() $out-dx, Num() $out-dy )
  • $out-scale-x; (transfer ownership: full) return location for the scale factor in the x direction.

  • $out-scale-y; (transfer ownership: full) return location for the scale factor in the y direction.

  • $out-dx; (transfer ownership: full) return location for the translation in the x direction.

  • $out-dy; (transfer ownership: full) return location for the translation in the y direction.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

to-matrix

Computes the actual value of $self and stores it in $out-matrix.

The previous value of $out-matrix will be ignored.

method to-matrix ( N-Object $out-matrix )
  • $out-matrix; The matrix to set

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

to-string

Converts a matrix into a string that is suitable for printing.

The resulting string can be parsed with .Transform.parse().

This is a wrapper around .print().

method to-string (--> Str )

Return value; A new string for $self.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

to-translate

Converts a Gnome::Gsk4::N-Transform to a translation operation. $self must be a 2D transformation. If you are not sure, use

C<.get-category()> >= %GSK_TRANSFORM_CATEGORY_2D_TRANSLATE

to check.

method to-translate ( Num() $out-dx, Num() $out-dy )
  • $out-dx; (transfer ownership: full) return location for the translation in the x direction.

  • $out-dy; (transfer ownership: full) return location for the translation in the y direction.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

transform

Applies all the operations from $other to $next.

method transform ( N-Object $other --> N-Object )
  • $other; Transform to apply

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

transform-bounds

Transforms a Gnome::Graphene::N-Rect using the given transform $self.

The result is the bounding box containing the coplanar quad.

method transform-bounds ( N-Object $rect, N-Object $out-rect )
  • $rect; a Gnome::Graphene::N-Rect

  • $out-rect; return location for the bounds of the transformed rectangle

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

transform-point

Transforms a Gnome::Graphene::N-Point using the given transform $self.

method transform-point ( N-Object $point, N-Object $out-point )
  • $point; a Gnome::Graphene::N-Point

  • $out-point; return location for the transformed point

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

translate

Translates $next in 2-dimensional space by $point.

method translate ( N-Object $point --> N-Object )
  • $point; the point to translate the transform by

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

translate-3d

Translates $next by $point.

method translate-3d ( N-Object $point --> N-Object )
  • $point; the point to translate the transform by

Return value; The new transform.

=end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

unref

Releases a reference on the given Gnome::Gsk4::N-Transform.

If the reference was the last, the resources associated to the $self are freed.

method unref ( )

=end rakudoc

#------------------------------------------------------------------------------- #--[Functions]------------------------------------------------------------------ #-------------------------------------------------------------------------------

=begin rakudoc

Functions =end rakudoc

#------------------------------------------------------------------------------- =begin rakudoc

parse

Parses the given $string into a transform and puts it in $out-transform.

Strings printed via .to-string() can be read in again successfully using this function.

If $string does not describe a valid transform, False is returned and undefined is put in $out-transform.

method parse ( Str $string, N-Object $out-transform --> Bool )
  • $string; the string to parse.

  • $out-transform; (transfer ownership: full) The location to put the transform in

Return value; True if $string described a valid transform..

=end rakudoc

Gnome::Gsk4 v0.2.1

GSK is the rendering and scene graph API

Authors

  • Marcel Timmerman

License

Artistic-2.0

Dependencies

Gnome::Gdk4:api<2>Gnome::Graphene:api<2>Gnome::GObject:api<2>Gnome::Glib:api<2>Gnome::N:api<2>

Test Dependencies

Provides

  • Gnome::Gsk4::BlendNode
  • Gnome::Gsk4::BlurNode
  • Gnome::Gsk4::BorderNode
  • Gnome::Gsk4::CairoNode
  • Gnome::Gsk4::CairoRenderer
  • Gnome::Gsk4::ClipNode
  • Gnome::Gsk4::ColorMatrixNode
  • Gnome::Gsk4::ColorNode
  • Gnome::Gsk4::ConicGradientNode
  • Gnome::Gsk4::ContainerNode
  • Gnome::Gsk4::CrossFadeNode
  • Gnome::Gsk4::DebugNode
  • Gnome::Gsk4::GLRenderer
  • Gnome::Gsk4::GLShader
  • Gnome::Gsk4::GLShaderNode
  • Gnome::Gsk4::InsetShadowNode
  • Gnome::Gsk4::LinearGradientNode
  • Gnome::Gsk4::MaskNode
  • Gnome::Gsk4::N-RoundedRect
  • Gnome::Gsk4::N-ShaderArgsBuilder
  • Gnome::Gsk4::N-Transform
  • Gnome::Gsk4::OpacityNode
  • Gnome::Gsk4::OutsetShadowNode
  • Gnome::Gsk4::RadialGradientNode
  • Gnome::Gsk4::RenderNode
  • Gnome::Gsk4::Renderer
  • Gnome::Gsk4::RepeatNode
  • Gnome::Gsk4::RepeatingLinearGradientNode
  • Gnome::Gsk4::RepeatingRadialGradientNode
  • Gnome::Gsk4::RoundedClipNode
  • Gnome::Gsk4::ShadowNode
  • Gnome::Gsk4::T-enums
  • Gnome::Gsk4::T-glshader
  • Gnome::Gsk4::T-path
  • Gnome::Gsk4::T-rendernode
  • Gnome::Gsk4::T-roundedrect
  • Gnome::Gsk4::T-stroke
  • Gnome::Gsk4::T-transform
  • Gnome::Gsk4::T-types
  • Gnome::Gsk4::TextNode
  • Gnome::Gsk4::TextureNode
  • Gnome::Gsk4::TextureScaleNode
  • Gnome::Gsk4::TransformNode

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.