Hi, I would like to create a custom Layout like a ...
# compose
a
Hi, I would like to create a custom Layout like a Pizza. Drawing is easy but I am not sure how to handle the tap gestures - when the user taps a slice, how can I know which slice was tapped? I was hoping Compose may have some tools to help before I roll my sleeves up with computational geometry algo.
r
It’s a feature I’ve been wanting to add to
Path
👍 2
but right now you’d need to do it yourself
a
Thank you
r
FWIW it’s pretty easy in your case
You will need to convert the x/y touch coordinate to an angle, which can be done with
atan2
and from that angle you can find the corresponding slice
Something like this:
Copy code
const val RadToDeg = (180.0 / PI).toFloat()
val angleInRad = atan2(y, x)
val angleInDeg = angleInRad * RadToDeg
angleRad
will be in the
-PI..PI
range so you might want to account for that
(btw here I assume that
x
and
y
are offsets from the center of the pizza)
a
Thanks Romain. The Pizza was a simplification of my actual problem, but your tips will help. I am working on a goniophotometer-like app; the phone and illuminant rotate on same axis. The UI rotates with the phone as samples are taken so that user always sees things level and can remove erroneous samples. The UI looks like a starburst chart (kinda pizza like :D) The actual sensor data is read from another device that is stationary.
r
Sounds like a fun project 😀
a
Ha thanks. This is for an enthusiast community that tests flashlights. A real integrating sphere is $$$$. Ideally there would be a spectrometer where the lux sensor is, to get CCT/dUV shift vs angle, but I have not found an affordable, semi-accurate one yet. Beaded TIRs solve most tint shift problems but it can be very pronounced with certain domed emitters + reflector setups. The last part, out of scope, is flicker and driver dynamic range; many flashlight drivers are unstable at their lowest settings - but that also requires special hardware / photosensors with fast response times.
r
I'm familiar with stuff like this :)
a
I bet, you are pretty famous in the photography circles ... not sure if you do any light painting photography, but this fellow is pretty active in our circles https://www.stephenknightphotography.com/
r
Oh nice! I should check that out. That said most of the lighting work I’ve done was through building Filament and writing: https://google.github.io/filament/Filament.html
Got to spend a lot of quality time with light meters 😄
a
Hey Romain, its been a while we talked in this thread ... I was looking at filament doc section "5.2.3 Photometric lights" and noticed the section about IES profiles. Can an IES profile accurately represent a light source like this, notice the angular tint shift (aka egg yolk pattern)

https://i.imgur.com/aDhD7k4.jpg

When I looked at the format, it seems only angle and lux, not CCT
r
IES profiles are only about the shape of a light, not it’s tint
👍 1
To do this we would need to create a new type of material in a “light domain”
But a light source color shouldn’t really change based on the surface angle?
It should be a result of the surface itself
a
Ok thanks, I'm working on the goniophotometer app. BTW, did you have any specific lux meters or spectrometers you liked, preferably with modbus / BLE connectivity?
r
I don’t have a spectrometer unfortunately, and I’ve been quite happy with the lux meter mentioned in the doc
Not sure what its connectivity is though
a
ah i missed it in the filament doc, will go back to find it thanks
Sekonic, I knew it lol. That photo I had above was a Cree XP-G4 BTW, lots of Cree emitters have serious tint shift, but most do anyhow. This is what we are trying to capture and display (android app + specrometer)

https://led-ld.nichia.co.jp/img/led/lighting_19_feature_6_e.png

just thought you might be interested, have a good weekend
r
That’s super interesting indeed!
@alexhelder Reporting back, I’m working on the implementation of path hit testing. It can be use to detect taps inside arbitrary shapes defined by a
Path
I have it working already for a bunch of shapes
Screen_recording_20240201_164746.mp4