Changes
- Added `svgelements` as a dependency. Should be automatically installed when updated thru pip.
- `Path.center()` now returns the center of the path's bounding box instead of the center of mass of its nodes. The center of mass can now instead be calculated by calling the `centroid()` method.
- Mask layers whose `visible` attribute is set to `False` are no longer applied.
- Figure delays, Layer time offsets, and Layer `start`/`end` features are now officially deprecated.
+ They're not being removed yet, but I will no longer be making much effort to support them such as bug fixes or ensuring they remain compatible with new features going forward.
New Features
- New actors can now be automatically created and affixed to a layer in a single line with the syntax `myactor = mylayer.Actor(myfigure)`
+ This streamlines the process of introducing new actors to the current end of the global animation timeline. Coupled with the `set()` method, new actors can be created, initialized, and affixed to a layer all in one line:
python
The return value of `Layer.Actor()` is the newly created Actor object itself
arrow = mylayer.Actor(morpho.grid.Arrow(1, 2+2j).set(width=5, color=[1,0,0], ...))
+ Placement on the timeline can still be modified by passing in the optional keyword inputs `timeOffset` or `atFrame`
python
myactor = mylayer.Actor(myfigure, timeOffset=10)
myactor2 = mylayer.Actor(myfigure2, atFrame=0)
- New `MultiSpline` figure enables Morpho to load many SVG files by calling `MultiSpline.fromsvg(filename)`
- Morpho can now parse LaTeX math code into a MultiSpline figure by calling `morpho.latex.parse(latexCode)`.
+ Note this requires you to have a LaTeX distribution installed, as well as dvisvgm.
- `PText` and physical paragraph figures have a new `toSpline()` method that converts a physical text figure into a MultiSpline.
+ Note this is still a pretty experimental feature and needs further improvement, especially for paragraphs where the output can sometimes look significantly off.
- Paths and Splines now support a `box()` method that returns the bounding box of the figure.
+ Also included are side methods `left()`, `right()`, `top()`, `bottom()` and corner methods `northwest()`, `southwest()`, `southeast()`, `northeast()`.
- Paths and Splines now support background boxes via setting the attributes `background`, `backAlpha`, and `backPad`.
- Paths and other Path-like figures have a new `dashOffset` attribute.
- New Spline `autosetHandles()` method converts Splines into Catmull-Rom Splines by modifying the tangent handles.
- `Spline.fimage()` now works.
- Paths and Splines now support an `align` property that works similarly to `align` for Images and Text figures. Mainly useful for aligning MultiSplines representing a math expression.
- Paths and Splines can now be "backstroked", meaning the stroke will appear behind the fill. This is done by setting a *negative* `width` value: `mypath.width = -6`.
- Arrows now have a `vector` property which returns/sets the tail-to-head vector:
python
myarrow.vector Returns myarrow.head - myarrow.tail
myarrow.vector = 2+3j Equivalent to myarrow.head = myarrow.tail + 2+3j
- New `morpho.grid.basicgrid()` function produces a grid better suited for when you don't need the grid to morph.
- `paragraph()` now has `xbuf` and `ybuf` optional inputs that work like a size-independent `xgap` and `ygap` in which the gap spacing is specified in units relative to the font size.
- New `select` property for `Frame` figures allows modifying all the attributes of a subset of subfigures.
+ Example: `myframe.select[2:5].set(pos=1+2j)` modifies the `pos` attribute of subfigures 2 thru 4 (inclusive).
+ A boolean-valued choice function can also be given to `select[]` to only select subfigures meeting a certain criterion:
python
myframe.select[lambda subfig: subfig.alpha == 0].set(alpha=1)
+ Note that `select[]` cannot be used to extract a sub-Frame. For that, use the `sub[]` property.
- New `sub` property for `Frame` figures allows extracting a subset of subfigures as a new `Frame` figure. The input syntax is the same as for `select[]`, but the returned value is a new `Frame` consisting of copies of the selected subfigures.
- Position of a keyfigure in an Actor's timeline can now be obtained by calling `myactor.timeof(keyfigure)`.
- New `morphFrom()` actor action provides an easy way to morph a copy of an actor into a new actor. Particularly useful when animating a new math formula morphing out of another math formula.
- Added various box functions to `morpho.tools.basics`:
+ `padbox()` adds horizontal/vertical padding to a box.
+ `totalBox()` computes the total bounding box of a list of boxes.
+ `shiftBox()` translates a box by a given vector.
Improvements
- The `endDelay()` and `endDelayUntil()` methods of the `Animation` class now have aliases `wait()` and `waitUntil()`.
- Non-physical paragraphs are now easier to initialize as providing `windowShape` is optional in most use cases now.
- Text array inputs to `paragraph()` are now much more tolerant, supporting a mix of `Text` figures, strings, and sublists.
+ Example:
python
morpho.text.paragraph(["Hello", morpho.text.Text("World", color=[1,0,0])], ...)
- `Actor.key[]` can now be accessed by object as well as by stack index enabling syntax like
python
myactor.key[keyfig] = newkeyfig
del myactor.key[keyfig]
- Paths/Splines with deadends are now properly tweenable.
- Path/Spline slicing now handles deadends correctly.
- `enbox()`, `encircle()`, and `crossout()` functions can now take an optional `pad` input to apply padding to the given box.
- Added new option for outlined path rendering.
- The `origin` attribute for Paths and Splines can now be accessed/modified using the alias `pos`, making them feel similar to Image and Text figures in that regard.
- Methods can now be called from `Frame.all`. Useful for calling a method that will modify each subfigure in place, e.g. `myframe.all.commitTransforms()`
- `Frame.merge()` now returns `self`, enabling method chaining after a merge call.
- `Polygon` now handles drawing bad vertex values (e.g. `nan` or `inf`) better.
- Temporary directories are now generated differently when exporting an animation, removing the need to set an export signature if exporting multiple animations in parallel.
Bug Fixes
- `Frame.merge()` should now correctly handle merging another `Frame` figure.
- Zero-length space arrows are now drawn.
- Fixed visual bug with cyclic paths with arrows.
- Fixed bug with `Spline.close()`
- `Spline` spiral and pivot tween methods now correctly tween the `origin` attribute.
- `SpaceSpline.newNode()` now has `relHandles` option.
- Fixed bug in color gradient detection for Paths.
- Fixed bug in bounding box methods for physical Text figures.
- Stroke widths below 0.5 are now ignored. This should fix some visual bugs.
- Fixed visual bug for Splines whose tangent handles were extremely close but not coincident with their positional nodes.
- Fixed bug with Paragraph tweening.