trans_chain is what + produces when combining transforms that can't
collapse into a single trans matrix – e.g. a trans_warp with
another trans_warp, or a trans_warp mixed with a trans. It is not
usually constructed directly; it holds an ordered list of steps
(each a trans, trans_warp, or trans_fn), applied in sequence –
steps[[1]] first, steps[[length(steps)]] last – exactly like
chained + calls on a drawable would suggest.
Usage
trans_chain(steps = list())Arguments
- steps
A list of trans/trans_warp/
trans_chainobjects.
Details
Two consecutive trans (affine) steps are not automatically
collapsed into one matrix when they're already part of a chain (only a
bare trans + trans collapses); this only costs a little efficiency,
not correctness.
See also
Other transform helpers:
trans(),
trans_affine(),
trans_fn(),
trans_identity(),
trans_reflect(),
trans_rotate(),
trans_scale(),
trans_shear(),
trans_translate(),
trans_warp()
Examples
# combining an affine trans with a trans_warp produces a trans_chain,
# applied in the order given by +
chained <- trans_rotate(pi / 6) + trans_warp(amount = 0.08)
chained
#> <sketchpad::trans_chain>
#> @ steps:List of 2
#> .. $ : <sketchpad::trans>
#> .. ..@ matrix: num [1:3, 1:3] 0.866 0.5 0 -0.5 0.866 ...
#> .. $ : <sketchpad::trans_warp>
#> .. ..@ amount : num 0.08
#> .. ..@ distortion_x: <sketchpad::noise_field>
#> .. .. .. @ noise : function (x, y = NULL, z = NULL, t = NULL, frequency = 1, seed = NULL,
#> ...)
#> .. .. .. @ fractal : function (base, new, strength, ...)
#> .. .. .. @ frequency: num 1
#> .. .. .. @ octaves : int 2
#> .. .. .. @ seed : int 1
#> .. ..@ distortion_y: <sketchpad::noise_field>
#> .. .. .. @ noise : function (x, y = NULL, z = NULL, t = NULL, frequency = 1, seed = NULL,
#> ...)
#> .. .. .. @ fractal : function (base, new, strength, ...)
#> .. .. .. @ frequency: num 1
#> .. .. .. @ octaves : int 2
#> .. .. .. @ seed : int 2
draw(shape_rectangle(width = 1.5, height = 0.6, trans = chained))