Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Porting to infamous #2

Open
trusktr opened this issue Dec 21, 2017 · 7 comments
Open

Porting to infamous #2

trusktr opened this issue Dec 21, 2017 · 7 comments

Comments

@trusktr
Copy link

trusktr commented Dec 21, 2017

Hello. I recently completed most of the "mixed mode" feature for infamous (there's some small things left to do).

Here's a demo of the HTML API:

https://codepen.io/trusktr/pen/rpegZR

There's also a JavaScript API (CSS3D-only example). I've got lots of ideas planned for the JS API like how to make it work in workers with SharedArrayBuffer, how to make it work without any DOM (f.e. in Node.js with OpenGL), and possibly writing the core classes in WebAssembly (or something that compiles to WASM) for performance.

Anyways, I'd like to get AutoLayout ported to Infamous! I think this would be cool!

@IjzerenHein
Copy link
Owner

Hi. That sounds awesome! I don't really work with famous anymore these days, but if I can help with something let me know. Cheers

@trusktr
Copy link
Author

trusktr commented Dec 4, 2018

Hello Hein, I've started work on this! https://github.com/trusktr/infamous/tree/autolayout

WIP, I'll circle back to replace the Famous parts with Infamous parts.

(By the way, Infamous will be renamed and get a new website with complete docs soon!)

@trusktr
Copy link
Author

trusktr commented Dec 4, 2018

I'm planning to see if I can extend the 2D autolayout into 3D autolayout.

@trusktr
Copy link
Author

trusktr commented Dec 4, 2018

Do you remember on these lines,

node.setAbsoluteSize(
(widths && (widths[key] === true)) ? undefined : subView.width,
(heights && (heights[key] === true)) ? undefined : subView.height
);

what the undefined absolute size values do?

Is it that the size will be 100% size of the parent when the size mode is proportional?

@trusktr
Copy link
Author

trusktr commented Dec 4, 2018

Almost there. Basically I already converted to infamous API, f.e.:

https://github.com/trusktr/infamous/blob/0b953ab7e2c06bc220f27a0994793c1255dc0c86/src/autolayout/AutoLayoutNode.js#L229-L244

Then I just need to take these parts,

https://github.com/trusktr/infamous/blob/0b953ab7e2c06bc220f27a0994793c1255dc0c86/src/autolayout/AutoLayoutNode.js#L43-L47

and convert them to use the Infamous Motor.addRenderTask API. Or maybe not, as setting the size values on the previous linked lines automatically enqueues a render task.

It's late, I'll try and finish it another day soon.

@trusktr
Copy link
Author

trusktr commented Dec 8, 2018

Alright, finished the initial version!

Here's what it looks like, with the parts I changed labeled with PORTED. Here's an example.

To run it, clone and checkout the autolayout branch, npm install, the serve the root of the repo with http-server or live-server.

npm install
npm i -g live-server
live-server .

then visit

http://localhost:8080/examples/

(Note, the WebGL is in experimental mode, a bunch of it is stable, but there's also a bunch of stuff to fix/polish/change)


When I circle back around I'll improve it so the API is exposed through the HTML elements, so we can write stuff like:

<i-autolayout-node vfl="
  //viewport aspect-ratio:3/1 max-height:300
  H:|-[row:[red(green,blue)]-[green]-[blue]]-|
  V:|[row]|
">
  <i-box class="green" class="green"></i-box>
  <i-box class="red" color="red"></i-box>
  <i-box class="blue" color="blue"></i-box>
</i-autolayout-node>

or

<i-vfl id="rowLayout">
  //viewport aspect-ratio:3/1 max-height:300
  H:|-[row:[red(green,blue)]-[green]-[blue]]-|
  V:|[row]|
</i-vfl>

<i-autolayout-node vfl="#rowLayout">
</i-autolayout-node>

or

<i-autolayout-node vfl="/path/to/source.vfl">
</i-autolayout-node>

@trusktr
Copy link
Author

trusktr commented Dec 9, 2018

Alright, finished the HTML API. Here's what the declarative example looks like.

Here's what the AutoLayoutNode class looks like.

In the examples, you can see that we can update the VFL just changing the content of the visualFormat prop (which is mapped to the visual-format attribute, and using el.setAttribute() would also work the same).


Up next I want to have 3D layout!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants