# Keeping your code compatible with recent changes

**URL:** <https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641>\
**Category:** Announcements\
**Created:** [March 18, 2024, 12:25pm UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641 "2024-03-18T12:25:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [March 18, 2024, 12:25pm UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/1 "2024-03-18T12:25:04Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [March 18, 2024, 2:31pm UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/2 "2024-03-18T14:31:15Z")

</div>

# 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](https://github.com/openrndr/openrndr/commit/7091676a458decd9be119f848425847a7601cb7f), [writer](https://github.com/openrndr/openrndr/commit/f7777601608eae5babbbfa7fd55e7cafd3534da6)

## Required changes

- Add `orx-composition`, `orx-svg` and `orx-text-writer` [to your template](https://github.com/openrndr/openrndr-template/commit/cf4ebfc490c2cd182c7da7be366170f61f11227a)
- 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](https://github.com/hamoid/penplotter-openrndr/commit/0c423bd8537e58bba5ccd1ace5e2fcf8375b2f23).

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [March 25, 2024, 11:12am UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/3 "2024-03-25T11:12:20Z")

</div>

# 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](https://github.com/openrndr/openrndr/commit/09af6eb1fc312e81b45f1a9a0dfe56518df7e154)

## Required changes

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

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [March 25, 2024, 12:09pm UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/4 "2024-03-25T12:09:30Z")

</div>

# 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](https://github.com/openrndr/orx/commit/8fbb1068238014cf803ecc05102e22ec8e1c59c5)

## 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` |

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [October 29, 2024, 11:35am UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/5 "2024-10-29T11:35:48Z")

</div>

# Rectangle.uniform

The `.uniform()` methods were recently updated to make use of better hash functions. We can now query random uniform points from [Rectangle, Triangle, Circle and Box](https://github.com/openrndr/orx/tree/master/orx-noise/src/commonMain/kotlin/shapes). In these changes `Rectangle.uniform` was moved into a `shapes` package, which requires to update the `import` as listed below (otherwise the IDE will complain about the wrong number of arguments).

Related commits: [[orx-noise] Add hash functions · openrndr/orx@fba1e5b · GitHub](https://github.com/openrndr/orx/commit/fba1e5b61a8c49f7c225bfe7f8eac9df2a461c71)

## Required changes

| Find | Replace with |
| --- | --- |
| `import org.openrndr.extra.noise.uniform` | `import org.openrndr.extra.noise.shapes.uniform` |

In this change, the `.uniform()` method lost it’s distance-to-edge argument. If you made use of it, first offset the rectangle and the call `.uniform()`.

```
drawer.bounds.uniform(100.0)

```

becomes

```
drawer.bounds.offsetEdges(-100.0).uniform()

```

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [February 27, 2025, 3:21am UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/6 "2025-02-27T03:21:02Z")

</div>

## OPENRNDR Random class now deprecated

The OPENRNDR Random class gets often confused with the Kotlin Random class. Less experienced users may import the wrong one using the IDE’s automatic import feature, and the code would fail to run.

Therefore it has been recently deprecated. Here alternatives to commonly used methods:

| Before | After | Import |
| --- | --- | --- |
| Random.double() | Double.uniform(-1.0, 1.0) | import org.openrndr.extra.noise.uniform |
| Random.double(0.0) | Double.uniform(0.0, 1.0) | import org.openrndr.extra.noise.uniform |
| Random.double0() | Double.uniform(0.0, 1.0) | import org.openrndr.extra.noise.uniform |
| Random.bool(0.01) | Boolean.random(0.01) | import org.openrndr.extra.noise.primitives.random |
| Random.simplex(0.1) | simplex(1234, 0.1, 0.0) | import org.openrndr.extra.noise.simplex |
| Random.simplex(vec2 \* 0.1) | simplex(1234, vec2 \* 0.1) | import org.openrndr.extra.noise.simplex |
| Random.int(12, 34) | Int.uniform(12, 34) | import org.openrndr.extra.noise.primitives.random |
| Random.int0(123) | Int.uniform(0, 123) | import org.openrndr.extra.noise.primitives.random |

### Random.seed

If your program uses `Random.seed` because you want reproducible randomness, there are some required changes. `Random.seed` expected a `String`, but we will now use Kotlin’s `Random`, which expects an `Int` for a seed in its constructor. You will need to figure out an approach for switching to integer seeds. Once you do,

Before: `Random.seed = "friendly parrot"`  
Now: `val rnd = Random(seed = 2) // remember to import kotlin.random.Random`

Then pass the `rnd` variable to any of the methods in the table above, or to methods like `Rectangle.scatter()`:

```kotlin
Double.uniform(0.0, 1.0, rnd)
Int.uniform(12, 34, rnd)
drawer.bounds.scatter(width * 0.1, random = rnd)

```

By passing a seeded `Random` generator the sequence of produced values will be the same each time you run the program.

### Random.unseeded { }

Since random functions are now unseeded by default, `Random.unseeded` can be safely deleted from your code (openrndr/orx `0.4.5-alpha8` or later).

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [March 4, 2025, 4:06am UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/7 "2025-03-04T04:06:35Z")

</div>

# Color transform methods moved into orx

The functions used to generate a `colorMatrix` have been moved into orx, affecting the usage of these methods

- tint()
- invert()
- grayscale()
- constant()

Related commits: [openrndr](https://github.com/openrndr/openrndr/commit/c6a94816bbbafd5f50e3c6ab8702135c2d8450b9) and [orx](https://github.com/openrndr/orx/commit/00463484103f705b305aaa25f4a14c2df4bf93d7).

## Required changes

| Find | Replace with |
| --- | --- |
| `import org.openrndr.draw.tint` | `import org.openrndr.extra.color.colormatrix.tint` |
| `import org.openrndr.draw.grayscale` | `import org.openrndr.extra.color.colormatrix.grayscale` |
| `import org.openrndr.draw.invert` | `import org.openrndr.extra.color.colormatrix.invert` |
| `import org.openrndr.draw.constant` | `import org.openrndr.extra.color.colormatrix.constant` |

Here the [relevant section in the guide](https://guide.openrndr.org/drawing/images.html#changing-the-appearance-of-images).

---

<div class="post-metadata">

**Author:** ![skurfuerst](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/skurfuerst/32/844_2.png) [@skurfuerst](https://openrndr.discourse.group/u/skurfuerst)\
**Post date:** [May 28, 2025, 5:33am UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/8 "2025-05-28T05:33:36Z")

</div>

Hey everybody,

first off, thanks for this AWESOME work 🙂 I’ve just updated a bigger project from 0.4.4 to 0.4.5-alpha9. Besides the things in this thread, it seemed to me that somehow my system (OSX, M1) switched to OpenGL ES instead of plain OpenGL - which broke all my custom shaders 🙂 .

After some debugging, it turned out to be [this line](https://github.com/openrndr/openrndr/blob/c1c0efe8cd9478998220a916afffaea3f4b9ef0e/openrndr-jvm/openrndr-gl3/src/jvmMain/kotlin/org/openrndr/internal/gl3/DriverGL3Configuration.kt#L73) where it switched to OpenGL ES for M1 OSX Mac.

=\> so for me setting `-Dorg.openrndr.gl3.gl_type=gl` was crucial.

All the best, and keep up the great work,  
Sebastian

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [May 28, 2025, 7:52am UTC](https://openrndr.discourse.group/t/keeping-your-code-compatible-with-recent-changes/641/9 "2025-05-28T07:52:15Z")

</div>

Thank you @skurfuerst for your kind words and for sharing your discovery. Welcome to the forum! 🙂 I’ll share it with the team in case we can give more info about this change.

**Update** : so as I understand, one solution is what you did: keep it running GL by using that flag. The other would be to adjust the shaders so they run with GLES as well.

If anyone prefers the second route, one needs to be aware that there’s no implicit type conversion: `sin(2)` will not work, it needs to be `sin(2.0)`. So one needs to use ints where ints are expected, and floats where floats are expected. Either add a decimal point, remove it, or cast the variable to the expected type with `int(x)` or `float(x)`. Such changes might fix most compatibility issues.
