SharpConstraintLayout
SharpConstraintLayout copied to clipboard
Nice project, I've been making something similar too, maybe we can create something together!
Hi, it's my first talking to you, よろしくお願いいたします。
I watched your video demonstrating what the project can do, I have videos showing what I've been doing too https://user-images.githubusercontent.com/35312807/149654567-86c5c7d3-c958-4e16-a43b-01f6878e0add.mp4 https://ewr1.vultrobjects.com/recording/2022-07-21%2007-54-14.mp4
I wrote algorithms for calculating layout, although I think the way to create layout is important after all.
I am using https://github.com/Xyncgas/BlazorCL which has a structure called LDS (Layout_Data_Structure) that has left, top, width, height, which is sufficient to draw a 2D rectangle, while it is familiar to people who are working with the browsers too.
I made this structure with explicit struct layout :
As you can see LDS backed by a Vector4 Memory and inside the structure it has point2d and dimension2d that's backed by Vector too which allows SIMD accelerations when doing calculations
I started doing some tricks, for example I can write codes like this :
Since there isn't a good enough solution that comes with the browser and dotnet to do exactly what I want to do for drawing layout, I found myself having the needs to implement my own layout algorithms, which making it available in csharp for me to draw any layout knowing it's gonna work.
Lastly I would like to share some interesting things I've been doing, notice how I'm using operators in the layout definitions, that lets me say I want to divide a layout to 20 rows and 3 columns and pick the first grid (rectangle) with the syntax such as
LDS MyLayout => LDS.Screen % (3, 20);
And from there I can keep drawing layout in however ways I would like using things like
LDS MyLayout2 => MyLayout ^ (2,-19);
To draw another rectangle at the bottom right corner of the screen
And then I can draw another rectangle between them using
LDS MyLayout3 => MyLayout.BR & MyLayout2.TL;
To draw another rectangle between two points
During development layouts are generally created not to be directly displayed but to generate other layout that will be used for the elements, this can create a performance problem due to there being a lot function called to create a lot of layout that are depended by the others. This can be mitigated once the UI has been designed, with LDS.Export()
and LDS.Import()
the final layout can be abstracted to a compile time constant that can be imported later when the layout is being drawn which is going to work the same, while reducing the complexity of the computation to always O(1)