Repository navigation
Vision
This page is a canvas to help tighten the concepts in Lucidity and try to understand and visualise how all the pieces fit together.
With the current ideas, a project can be exported as a single markdown file which is a nice feature.
Source code is divided into blocks, elements that are displayed visually. Each block has a unique id but they can share the same name as long as this does not resolve in circular loops while assembling the graph.
To target an element, we can refer to it's name by writing an '@' before, like '@foo'. To target the element's id, we use an '$' (this is mostly for serialisation purpose).
Example project X:
We prepare the project with three.WebGL for rendering. We also add a slot for full image effects:
+-------+
| @root | <-- The first element defines where we plug
+-^-----+-----+
| three.WebGL |
+-^-----------+
| fx |
+-^-----+
| scene |
+-^-----+
We describe the glow effect here, first with the structure:
+------+
| @fx | <-- We add this branch to the block named "fx"
+-^----+
| blur |
+-^----+
And then we can edit the placeholders of blocks. When we have an "@" inside the header, this tells us that all the code blocks until we have a header of the same level or a header of lesser level. For example if the '@' is in a h3 header, it will concern all code until another h3, h2 or h1 is encountered.
In the source, placeholders are identified by tags in comments: <frag:nameOfFragment>. The special placeholder name source targets the full source of the block.
// <frag:fractal>
// Default content used when the "fractal" fragment is not redefined
// stays inside the source like this.
// </frag:fractal>The @ tells us that the following code will be glsl to fill placeholder 'fractal' inside 'blur'. Note that if we
had multiple 'blur' blocks in the whole graph, they would ALL be concerned by the changes we do here. This is called "copy-paste inheritance". It forces all blocks with the same name to have the same language.
Note that the compiler knows that this 'blur.frag' source is glsl from the block's sources definitions. The format for targeting a placeholder is:
[block name](.[sub-source name]).[placeholder name]
In headers, we can also use $ in which case we target the element by unique id.
Example of a chunk of code that will be "copied" in the placeholder 'fractal':
float fractal (vec2 pix) {Bits by bits until we have a new header, all code is joined and is inserted inside the placeholder 'blur.fractal'.
Here we can have another placeholder for the same block. We can write text like: the blur effect is enabled when the user presses the C3 key on the keyboard:
enabled = midi.note.c3 > 0Parts with branch structure contain a lot of information: structure but also all the sources for the different elements. In the markdown, we have:
# The 'lucidity' root element informs that this yaml block is actually code for lucidity
lucidity: graph
# Where to connect this branch
branch: root
entry: flgm
nodes:
flgm:
- atlm
- afrw
atlm:
- pulv
blocks:
flgm:
name: three.WebGL
lang: ts
atlm:
name: foo
# ...For now, all sources in graph are contained inside this comment block and serialised as YAML so that when we bounce all this as "md" files, the versioning system is not too confused.
When we have an "@" header, this creates a separate file with the given extension. All text become comments and code blocks of the same language become just code. The other code blocks are kept in comments.
All content is serialised like this:
+ index.md <-- h1 header
+ 3DSetup.asgl.md <-- h2 header ("asgl" is the id of this part)
+ Effects.qrft.md <-- h2 header
+ Effects
+ Glow.tl8b.md <-- h3 header
+ Glow
+ @blur.fractal.klft.glsl
When serialized, a header of higher level contains the ids of the levels below for ordering. For example, the top-most index.md would contain:
# This is the foo title
Any text until the next header.
` ` `lucidity
type: section
parts:
- id: asgl
disabled: true
- qrft
` ` `
Since files have a unique id, they can be renamed and moved freely (as long as the id is kept).