Keeping your code compatible with recent changes

This thread is for OPENRNDR users who update openrndr and orx to version 0.4.5 or later. At this point it’s not yet officially released, but the changes may affect users building SNAPSHOT versions.

In most cases upstream changes to those repositories only bring new features or optimizations and require no changes in our code. But sometimes the changes do require us to update our programs.

I plan to document such changes in this thread to make it easier to live on the edge :slight_smile:

3 Likes

SVG, Composition and Writer moved from openrndr to orx

This change will make it possible to eventually use filters and gradients in SVG content and facilitate further improvements.

Related commits: SVG and Composition , writer

Required changes

  • Add orx-composition, orx-svg and orx-text-writer to your template
  • Update imports / code:
Find Replace with
import org.openrndr.shape.ClipMode import org.openrndr.extra.composition.ClipMode
import org.openrndr.shape.Composition import org.openrndr.extra.composition.Composition
import org.openrndr.shape.CompositionDimensions import org.openrndr.extra.composition.CompositionDimensions
import org.openrndr.shape.CompositionDrawer import org.openrndr.extra.composition.CompositionDrawer
import org.openrndr.shape.draw import org.openrndr.extra.composition.draw
import org.openrndr.drawComposition import org.openrndr.extra.composition.drawComposition
import org.openrndr.shape.GroupNode import org.openrndr.extra.composition.GroupNode
import org.openrndr.svg.loadSVG import org.openrndr.extra.svg.loadSVG
import org.openrndr.svg.saveToFile import org.openrndr.extra.svg.saveToFile
import org.openrndr.svg.toSVG import org.openrndr.extra.svg.toSVG
import org.openrndr.svg.writeSVG import org.openrndr.extra.svg.writeSVG
import org.openrndr.draw.Cursor import org.openrndr.extra.textwriter.Cursor
import org.openrndr.draw.Writer import org.openrndr.extra.textwriter.TextWriter
import org.openrndr.draw.writer import org.openrndr.extra.textwriter.writer
Writer(...) TextWriter(...) {

Example commit to an openrndr-template making these changes.

Segment becomes Segment2D

With this change code shared by the 2D and 3D segments is de-duplicated making it easier to maintain (and I suspect adding missing functionality to Segment3D).

Related commits: Generalize segments and paths · openrndr/openrndr@09af6eb · GitHub

Required changes

Find Replace with
Segment(...) Segment2D(...)
import org.openrndr.shape.Segment import org.openrndr.shape.Segment2D

Refactor orx-shapes package layout

Since orx-shapes has grown quite a lot, its various shape constructors were organized into logical packages. The functionality is still the same but the import statements in existing projects must be updated if switching to orx 0.4.5.

Related commits: [orx-shapes] Refactor package layout · openrndr/orx@8fbb106 · GitHub

Required changes

Find Replace with
import org.openrndr.extra.shapes.AlphaShape import org.openrndr.extra.shapes.alphashape.AlphaShape
import org.openrndr.extra.shapes.Arrangement import org.openrndr.extra.shapes.arrangement.Arrangement
import org.openrndr.extra.shapes.BoundedFace import org.openrndr.extra.shapes.arrangement.BoundedFace
import org.openrndr.extra.shapes.bezierPatch import org.openrndr.extra.shapes.bezierpatches.bezierPatch
import org.openrndr.extra.shapes.drawers.bezierPatches import org.openrndr.extra.shapes.bezierpatches.bezierPatches
import org.openrndr.extra.shapes.distort import org.openrndr.extra.shapes.bezierpatches.distort
import org.openrndr.extra.shapes.hobbyCurve import org.openrndr.extra.shapes.hobbycurve.hobbyCurve
import org.openrndr.extra.shapes.Arc import org.openrndr.extra.shapes.primitives.Arc
import org.openrndr.extra.shapes.grid import org.openrndr.extra.shapes.primitives.grid
import org.openrndr.extra.shapes.Net import org.openrndr.extra.shapes.primitives.Net
import org.openrndr.extra.shapes.Pulley import org.openrndr.extra.shapes.primitives.Pulley
import org.openrndr.extra.shapes.regularPolygon import org.openrndr.extra.shapes.primitives.regularPolygon
import org.openrndr.extra.shapes.regularPolygonBeveled import org.openrndr.extra.shapes.primitives.regularPolygonBeveled
import org.openrndr.extra.shapes.regularPolygonRounded import org.openrndr.extra.shapes.primitives.regularPolygonRounded
import org.openrndr.extra.shapes.regularStar import org.openrndr.extra.shapes.primitives.regularStar
import org.openrndr.extra.shapes.regularStarRounded import org.openrndr.extra.shapes.primitives.regularStarRounded
import org.openrndr.extra.shapes.RoundedRectangle import org.openrndr.extra.shapes.primitives.RoundedRectangle
import org.openrndr.extra.shapes.Tear import org.openrndr.extra.shapes.primitives.Tear