github nacular/doodle v0.8.0
0.8.0

latest releases: v0.11.5, v0.11.4, v0.11.3...
3 years ago

Features

3D Transforms

Views can now have full 3D transformations via their transform property. This works because AffineTransform has been updated to support scale,
rotation, and translations that involve x, y and z axes. The result is that Views can now be placed in a full 3D space by simply giving them a
transform that has been modified accordingly.

import io.nacular.doodle.drawing.AffineTransform.Companion.Identity
import io.nacular.measured.units.Angle.Companion.degrees

// Rotate this View around they y-axis (through its center) by 45°
view.transform *= Identity.rotateY(around = view.center, by = 45 * degrees)

Views can also now render in 3D, since Canvas also supports the new 3D transforms.

view {
    render = {
        transform(Identity.rotateY(by = 45 * degrees)) {
            // ...
        }
    }
}

3D Perspective

A realistic 3D space requires more than just affine transforms (which keep parallel lines parallel). Simulating this requires perspective transforms. Views now
have a camera property, which gives them a perspective when combined with a 3D transform. The following allows the y-axis rotation to look more realistic.

import io.nacular.doodle.drawing.AffineTransform.Companion.Identity
import io.nacular.measured.units.Angle.Companion.degrees

// Rotate this View around they y-axis (through its center) by 45°
view.transform *= Identity.rotateY(around = view.center, by = 45 * degrees)

// Position the View's camera to apply some realistic perspective warping
view.camera = Camera(position = view.center, distance = 1000.0)

Canvas also takes a Camera in its transform method to enable perspective.

view {
    render = {
        transform(Identity.rotateY(by = 45 * degrees), camera = Camera(Origin, distance = 1000.0)) {
            // ...
        }
    }
}

Kotlin 1.7 Support

Doodle now supports 1.7.10!!

APIs

  • New View.intersects method to simplify hit detection. This method works on a point that has been transformed into the View's plane.
  • Improved utilities for PointerListeners and PointerMotionListeners that need to monitor a subset of the events.
  • ConvexPolygon.reversed creates a polygon with the points in reverse order
  • New AffineTransform2D type to handle cases where full 3D transforms aren't supported (like PatternPaint transforms)
  • AffineTransform now represents 3D transforms and its APIs have been updated to reflect this
  • Vector2D (alias for Point) and Vector3D types to represent 2D and 3D points
  • [Breaking] Path and PathBuilder are now sealed
  • [Breaking] AffineMatrix3D is now internal
  • [Breaking] Remove AffineTransform extensions for times/div(Number), and plus/minus(AffineTransform)
  • [Breaking] No longer exposing AffineMatrix3D
  • [Breaking] Fixed bug in squareMatrixOf where row and col were reversed

Fixes | Improvements

  • General
    • Improved Matrix performance by switching from List to Array
    • Render issue in PathIcon
    • AffineTransform.scale when z != 1
    • Edge case in RenderManagerImpl when View becomes invisible before it is first rendered
    • Bug in FilteredList iterator implementation
  • Browser
    • UrlView not updating url value
    • Text can become blurry on Windows when transform applied to a View
    • Fixed clipping withing PatternPaint
    • Added work-around for cases (i.e. in Document) where RealGraphicsSurface is created as top-level, but is not within the display root.
  • Desktop
    • Fixed antialias on Canvas clipping

Dependencies

  • Kotlin -> 1.7.10
  • Coroutines -> 1.6.3
  • DateTime -> 0.3.3
  • Skiko -> 0.7.22
  • Mockk -> 1.12.4

Don't miss a new doodle release

NewReleases is sending notifications on new releases.