Skip to content

Morpho 0.11.0.post1

Latest

Choose a tag to compare

@morpho-matters morpho-matters released this 31 Jan 23:02

Changes

  • Changed line spacing behavior for paragraph-like figures.
    • Vertical spacing is now based upon a calculated general line height instead of the particular row height for the given line of text. This should make spacing more consistent overall, but it makes the ybuf parameter much more sensitive now, so lower values are typically needed to achieve the same kind of line spacing as before.
    • This change can largely be reverted by setting the morpho.text.LINE_HEIGHT_ALPHABET string constant to just a single dollar sign "$". This reversion can be attained on a more local level by passing in "$" to the new alphabet optional keyword argument of paragraph() and its cousins.
  • Image class - Replaced center property with the center() method for sake of consistency across all BoundingBoxFigures.
    • This means center is no longer a settable property.
  • Path drawIn() action - Now defaults to using morpho.transition.default for the transition method instead of uniform.
    • Note that this only affects single paths/splines and not multipaths/multisplines.
  • MultiSpline.squeeze() now also squeezes (see below) individual subsplines.
  • Multi/Spline fromsvg() method now parses toplevel opacity of svg elements instead of ignoring it.
  • Figures found in the calculus submodule now have their transition functions default to morpho.transitions.default instead of slow_fast_slow.
  • Changed Animation.aspectRatioWH to a method in order to be more consistent with the syntax for Camera.aspectRatioWH().

New Features

  • For Image class
    • Now supports (I think most?) other image formats besides PNG, such as JPG and GIF.
    • Added imageDimensions property that returns the imageWidth and imageHeight as a tuple.
    • newSource() can now extract a specific frame from an image file that contains multiple frames (e.g. GIF, WEBP, etc.)
  • For MultiImage class
    • MultiImage figures can now be initialized from an image file containing multiple frames where each frame of the image file will become one subfigure of the MultiImage figure.
      • This also pairs well with the new animate() actor action for Frame figures.
  • For Frame class
    • New actor action subtween() tweens (optionally a subset of) the subfigures of a Frame to the subfigures of another target Frame with optional substaggering.
    • New method selection() provides a way to select subfigures using filter functions.
    • Added labelSubfigures() method to FancyFrame subclass which labels subfigures in an animation with their corresponding index values. Helpful during animation construction.
    • permute() can now take an optional swap keyword specifying a dict mapping indices to indices indicating indices that should be swapped in the permutation. Indicies that are unspecified will not be moved.
    • New index() method returns the index position of a given subfigure or subfigure name.
    • New animate() actor action makes a Frame actor "play" all of the subfigures of its final keyfigure one after the other like a flipbook.
      • This actor action is also available to all multifigure types (e.g. MultiImage, MultiSpline, etc.)
      • Particularly useful for MultiImage actors that have been initialized from a multi-frame image file.
  • All BoundingBoxFigures - Added boxAspectRatioWH() method.
  • For Animation class
    • Added JPEG as another export type.
      • Use the extension jpg or jpeg.
    • Added WEBP as another export type.
      • Requires img2webp to be installed and part of the PATH environment variable.
    • New allLayers() method returns a generator yielding all layers in the animation, including their masks, in a depth-first search.
    • Added rescalePixels() methods that can be used to rescale tweenables that have a pixel tag.
    • Added rescale() method that rescales an entire Animation, including rescaling pixel values.
    • Added lengthstamp() method that returns a string indicating the animation's length in [hours]:minutes:seconds:frames format (hours is omitted if it is zero).
  • For Camera class - Added aspectRatioWH() method.
  • Added squeeze() method to the Spline class which removes isolated (and therefore invisible) nodes from the spline.
    • This method is also auto-called on all the individual subsplines whenever MultiSpline.squeeze() is called.
  • Polygon figures are now alignable and support background boxes.
  • Layer masks can now optionally function as cloaks if attribute cloak is set to True---meaning the visible part of the mask will correspond to regions that will be hidden in the target layer.
  • latex.matches() can now combine multiple match filters using bitwise operations like &, |, and ~
    • For example, mytex.select[~morpho.latex.matches("x")] will select all glyphs that do NOT match the glyph "x".
  • For FlowField gadget
    • Methods like last(), newkey(), etc. now return public FlowFrame or SpaceFlowFrame figures.
    • Added FlowFieldFrame() and FlowField3DFrame() functions that behave exactly like FlowField() and FlowField3D() except they return FlowFrame figures instead of gadgets. This allows FlowFields to be interacted with exactly like any other type of actor instead of being treated as very restricted gadgets.
  • Added toHex() function to the color submodule which is the inverse of parseHexColor()/parseHex()
  • For tools.basics
    • Added removeDuplicates() function.
    • Added cround() function that rounds complex numbers.
    • Added roundStable() function that rounds a sequence of numbers in such a way that their cumulative sum sequence does not drift after rounding.
    • Added clerp() function: a clamped version of lerp() that clamps the interpolation parameter t to be in between the specified start and end parameters.

Improvements

  • Grid functions like mathgrid(), mathaxes(), etc. can now optionally accept their view parameter as a positional argument, not just as a keyword argument.
  • Added aliases topleft(), topright(), bottomleft(), and bottomright() for the box corner methods northwest(), northeast(), etc.
  • Frame.merge() can now accept raw lists/tuples of figures, not just other Frame-type figures.
  • Subfigure modifiers are now taken into account when Frame-like figures are drawn.
  • matrix.rotationNd() - theta parameter is now optional.
  • Path/Spline class - box() method now throws a ValueError if the path/spline has no nodes.
  • Spline class
    • coincides() can now take optional keyword arguments that are passed into numpy.allclose() when making spline comparisons.
    • matchesShape() can now take multiple targets to check if any of them match.
    • toPath() now correctly handles deadends.
  • MathGrid types now support transformation tweenables.
  • RasterMap class
    • Added support for transformation tweenables and background boxes.
    • Added toImage() method.
  • Animation class - windowShape attribute now auto-rounds the dimensions it's given.
  • Camera class
    • box() method now supports the raw keyword.
    • toSubview() method now returns self.
  • Quadmesh figures now possess a gamma tweenable allowing the gamma correction value to be set and tweened.
  • If a Path-like figure is divided into sub-paths using deadends, those sub-paths will be drawn with closure if they form a loop.
    • In particular this makes PText figures that are turned into Splines look better when rendered.
  • LaTeX caching now automatically creates the specified cache directory if it doesn't exist yet.
  • Added alias parseHex() for function morpho.color.parseHexColor().
  • tools.basics - Added cparts() alias for complex2vect() function.
  • Actor actions are now inherited according to the class MRO in cases where multiple inheritance is used.
  • PText.toSpline() now passes additional keyword arguments to the tosvg() method.
  • Keyword input glo can now be used as an alias for glob in newendkey()

Bug Fixes

  • mp4 exports will no longer fail if a window dimension is an odd number.
  • Multiplying a Mat object on the left by a scalar will now correctly result in another Mat-type object instead of an np.array.
  • Polygon.box() - Implemented nodeCount() which was needed for the box() method to work properly.
  • wiggle actor action now works properly on pre-rotated figures.
  • Axis and Track actors now rescale correctly when animations are rescaled.
  • Fixed an issue with popIn/Out() for MultiPath-like figures where it could still display a background box for certain fully shrunk figures if backPad was nonzero.
  • Fixed an issue with PText.tosvg() where converted text would sometimes be missing characters if the text was very long.
  • Fixed an issue with Animation.export() where exporting an animation with a transparent background using the scale keyword would sometimes have aliasing effects (or worse).
  • Fixed an issue where exporting very high resolution animations could result in a memory error.