I'm exploring a bunch in doing artistic things wit...
# compose-desktop
l
I'm exploring a bunch in doing artistic things with Compose Canvas, and the more I do it, the more I think that it'd totally be doable to make a vector image editor using Compose and Kotlin code, and that would easily run on a bunch of major platforms, including the green robot one, at last. Has anyone started such a project?
r
Yeah there’s no reason it can’t be done
But if you want to do something super serious like Inkscape or Affinity Designer you may need to roll out some of your own vector algorithms, etc. Path/Canvas doesn’t go quite far enough
(although Compose 1.7 adds new APIs to Path that help a bit)
👍🏻 1
l
What kinds of vector algorithms?
Also, Compose 1.7? I haven't heard of that blob thinking fast
I played with
PathMeasure
, and though the documentation wasn't very helpful, I figured it out, and it's quite powerful! I can do some things with it that I don't know how I'd go about it in Affinity Designer!
r
1.7 isn’t out yet that’s why 🙂
blob think smart 1
but it adds an iterator on
Path
to iterate over the segments (curves) inside a path
l
Oh, that's a nice thing! It allows to not have to record everything you put into said path if you want to look into it, right?
r
yeah
it’s available for android.graphics.Path both as the graphics-path androidx library and my own pathway library on Maven
it’s also in Android 14
but now there will be a Compose API (with backcompat)
👌🏼 1
🎉 4
😍 3
👌🏾 1
👌🏻 1
l
It isn't such a big deal for a design app that would have its own path model?
r
it can be a pain if you want to support existing APIs/formats
l
Well, I guess it could help not overcomplicate things with a custom model blob thinking fast
What about the "vector algorithms" you mentioned?
r
Depends on what you are planning on doing
But for instance morphing, hit testing, etc.
Tracing
There are some of those things I want to add to the standard APIs
👍🏼 1
👍 1
👍🏾 1
👍🏻 1
l
Part of morphing is being added by Chet~GPT~ into androidx.graphics.shapes, correct?
r
Yeah but not for general paths
l
It's the kind of things that is in ShapeShifter?
👀 1
r
Yeah. And it's easier to implement when you can... Iterate over the content of a Path ^^
Also on my list of things I want to add to Compose
l
That would be awesome!
I know I'd use it
BTW, I found
Offset
and
Size
pretty useful for drawing things lately, but I've been missing a bunch of extensions like several minus and plus operators, and extensions to go from a topLeft to a center and vice-versa. Do you think this kind of contributions would be accepted?
a
I have very good experience with doing fancy drawing things with Canvas. We use it for a drawing canvas for a process modeller tool. I also found I missed Offset and Size extensions, but on the other hand I wanted to keep all the domain model stuff not bound to Compose. We already had a Kotlin common module with all sorts of geometry stuffs, so we only made some helpers to translate between the Compose geometry primitives to our own. This works pretty great and allowed us to reuse much of the same viewmodels with an SVG approach in Compose HTML.
👍🏻 1
l
The new Compose Path APIs aren't out yet, correct? I'm not seeing graphics or path mentioned in the first 2 alphas of 1.7: https://developer.android.com/jetpack/androidx/releases/compose-ui#version_17_2
r
They're in 1.7
I just added hit testing too that will be in the next alpha (or the one after i forget). Also exploring morphing right now
l
Thank you! Why are those not in the release notes? blob thinking fast
Looks like fun to stuff to experiment with, I can see
and
,
xor
, and
minus
have been added too. Do you know a good resource about implementing path morphing? I don't know how hard it'd be, but I'm curious and interested in prototyping. BTW, is a
drawTextOnPath
coming in 1.7 too?