Last active
January 1, 2016 19:59
-
-
Save anvaka/8193474 to your computer and use it in GitHub Desktop.
Imagine you have graph layout algorithm, which uses a physical engine. The engine has dozens of configuration options. What do you think is the best way to expose these options?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // engine is injected into layout: | |
| var layout = forceBasedLayout(engine); | |
| // Modify global gravity force: | |
| engine.gravity(9.8); | |
| // Modify drag coefficient: | |
| engine.drag(0.1); | |
| // ... you can also chain code above | |
| // engine.gravity(9.8).drag(0.1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // engine is injected into layout: | |
| var layout = forceBasedLayout(engine); | |
| // Modify global gravity force and drag coefficient: | |
| engine.options({ | |
| gravity: 9.8, | |
| drag: 0.1 | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // engine is injected into layout: | |
| var layout = forceBasedLayout(engine); | |
| // Modify global gravity force and drag coefficient: | |
| engine.option('gravity', 9.8); | |
| engine.option('drag', 0.1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment