Blocks and Components
Blocks
Blocks are the smallest unit of computation in Pictorus. Blocks appear in the Block Palette to the left of the canvas. Blocks are pre-compiled functions, which are chained together to form algorithms.
You modify a block's behavior by adjusting its Parameters. You can double-click on a block to open its Settings and edit its Parameters. You can also right-click on a block to get to the Settings.
Blocks almost always emit a single output (except, of course, Output blocks). They can have zero, one, or more inputs.
Components
Components allow us to aggregate blocks into re-usable functions. They're a powerful way to modularize your App, create new behaviors and functionality, not to mention a convenient way to clean up sprawling diagrams. The Yahboom G1 Tank
API is a Component, composed of several sub-components that communicate to the robot's hardware.
To create a new Component, right-click anywhere on the canvas and select New Component
. Double-clicking on a Component will navigate into it, and reveal another layer to your diagram. You can navigate in and out of these nested layers using the path links at the top of the canvas:
Components rely on special ComponentInput and ComponentOutput blocks to pass data in and out. These are easy to identify in a diagram given their unique shape. Adding these blocks within the Component makes them appear as inputs/outputs from the level above:
Ports can also be reordered after being created, which may be helpful for cleaning up diagram connections upstream of the component. This can be done by double-clicking on any port of a given type or right clicking and selecting Settings.
Reusable Component Library
Components can be made reusable across different apps, allowing users to build out a library of commonly used functions. To make a component reusable, right click on it and select Make Reusable
. After following the prompts and saving, the component will appear in the My Library subsection of the Block Pallette within any of a user's apps. We have also pre-built a set of components that interface with common sensors and acutators, availables in the From Market subsection of the Block Pallette.
For more ways to make Components powerful, check out: