Kebbin
11/14/2021, 3:53 AMKebbin
11/14/2021, 3:56 AMIgor Demin
11/14/2021, 2:40 PMKebbin
11/15/2021, 1:15 AMIgor Demin
11/15/2021, 8:19 AMBox(Modifier.drawWithContent {
drawIntoCanvas {
it.concat(matrix)
drawContent()
}
}) {
}
Don't know yet how exactly, but you can look at these tutorials:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/transforms/3d-rotation
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/transforms/matrixKebbin
11/15/2021, 8:19 AMKebbin
11/15/2021, 10:43 AMKebbin
11/19/2021, 9:18 AMCamera
object to use with the Matrix
.
It seems others are using android.graphics.Camera
but I'm not sure that's the thing to do with a Compose Project??
Thanks!Igor Demin
11/19/2021, 9:31 AMKebbin
11/19/2021, 9:34 AMKebbin
11/19/2021, 9:35 AMIgor Demin
11/19/2021, 9:40 AMWould this be a possibility with Desktop Compose?Compose has
canvas.setMatrix
function, which accepts 4x4 matrix. 4x4 matrix can manipulate how the image projected to the screen.Kebbin
11/19/2021, 9:41 AMKebbin
11/19/2021, 9:42 AMcanvas.setMatrix
.
Thanks!Kebbin
11/19/2021, 9:51 AMKebbin
11/19/2021, 9:52 AMKebbin
11/20/2021, 5:49 AMKebbin
11/20/2021, 8:35 AMKebbin
11/20/2021, 8:36 AMKebbin
11/20/2021, 8:38 AMIgor Demin
11/20/2021, 1:45 PMfind how to refresh the object when the rotate value changes on mouse movement!if your matrix is wrapped to
mutableStateOf
, Compose will automatically redraw the Canvas.
alternative is to call `currentRecomposeScope.invalidate`:
@Composable
fun App() {
val scope = currentRecomposeScope
Button(onClick = {
scope.invalidate()
}) {
Text("Refresh")
}
Canvas(Modifier) {
...
}
}
Kebbin
11/21/2021, 6:21 AMval matrix by remember { mutableStateOf( Matrix( ...etc...
or just like
val matrix = mutableStateOf( etc...
Also, should it best be created within the Canvas modifier, or further back up the hierarchy?
My main issue at the moment is tweaking the rotation and scale origins to suit my needs, as I have a couple of nested Surfaces to handle the panning (translation), zoom (scale), and rotation separately.
Cheers!Igor Demin
11/21/2021, 10:29 AMval matrix by rememberthis one, if you define
matrix
in Composable function. remember
just remembers the state instance across recompositions (mutableStateOf
itself).
Also, should it best be created within the Canvas modifierIt should be created outside of Canvas, but you can access it inside Canvas
Kebbin
11/21/2021, 11:23 AMKebbin
11/25/2021, 12:28 PMKebbin
11/25/2021, 12:28 PMKebbin
11/25/2021, 12:30 PMIgor Demin
11/25/2021, 12:34 PMKebbin
11/25/2021, 12:36 PMdarkmoon_uk
11/25/2021, 12:40 PMdarkmoon_uk
11/25/2021, 12:44 PM@Composable
, in a way that you could also sit 'untransformed' components around it as your UI/tool palette?darkmoon_uk
11/25/2021, 12:46 PMKebbin
11/25/2021, 1:01 PM@Composable Surface
. Anything placed on it is affected, and anything else around it is not.
I will build a component palette and menus, etc.
I now can move on to creating my data model, know that I have my 3D view basics in place!darkmoon_uk
11/25/2021, 1:09 PM@Composable
to identify e.g. the switch point or light clicked?
Since I tinker with a bit of hardware too @Kebbin I'm curious on the hardware side - what does an interface to the railway kit look like; RS232, or is it all Wifi and API's as well these days?darkmoon_uk
11/25/2021, 1:17 PM.clickable
then transformed it... it just remains clickable 🙂Kebbin
11/25/2021, 7:27 PMKebbin
11/28/2021, 8:47 AM