A suggestion for an additional way to describe a cfdg grammar #38
Labels
No labels
Priority-Medium
Type-Defect
auto-migrated
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: john/context-free#38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Before I explain my suggestion, allow me to copy/paste the current .cfdg I am working on; it was
written by someone else for a grass-pattern.
I have been thinking about that. The rule {} entries actually look like method
calls in a programming language.
We also have things such as:
which I think is ultimately a probability value, right?
So what if we could actually turn that into a programming-language or programming-like
language?
Say we have a common entry point which we call "main". That way we can remove the
startshape-clause. Each individual rule could be constructed like a method.
For example:
Could perhaps become:
We could use python-like syntax based on indent, or ruby-like syntax where
each "def" ends with "end". (I don't like the python requirement for a ":" after
the def, though. Indent alone should be enough.)
So why do I make this suggestion at all? Well, I think that the existing way to
build up such a context-free generated image, could also be done in a
programming-centric fashion. Perhaps this may be simpler for some folks.
We could also use aliases so that things such as "b -1.0" could be more
verbose, if the user wants to.
For example:
I think many new users have no idea what these single letters mean. They
can look at the wiki, yes, but I wonder whether it may not be better to simply
allow for a style such as:
(I made up the names here, but you get the idea.)
Anyway - not sure how likely it is to add alternative set of rules or grammar
but I wanted to suggest it. Note that I do NOT mean to obsolete the old
rules! These should be kept for many reasons, including compatibility,
but also because many other users will probably prefer the old way. Thus
my suggestion is for an ADDITIONAL way. (And perhaps we can cross-translate
it once it exists, so people can always adjust to what they prefer to use.)
Please feel free to close this issue - it is mostly meant as a suggestion for
future changes.
The single letter abbreviations already have long variants, except for x, y, and z. r and rotate are interchangeable, same for s and size, f and flip, trans and transform, h and hue, sat and saturation, b and brightness, a and alpha. skew has always just been skew, same with time and timescale.
We have already done a compatibility-breaking syntax change going from cfdg 2.x to cfdg 3.x. The code you are working with is in the old syntax, you can translate it here. I don't want to do another major syntax change unless it brings compelling new features.
On a side note, your code does randomness in the cfdg 2 manner, where random rule selection is the only way to make a shape do different things. With cfdg 3 you can have random actions inside a rule. Your grass code can be reduced to 5 rules:
It is undesirable to elliminate startshape keyword, because it's a good way to switch between different branches during debugging. In the node based systems like Fusion, Nuke or Touchdesigner you can change the current node you want to output to the screen, just think of it in similar way.
I would never get rid of startshape. But I should make it optional. If there is no startshape then the first shape in the file is the startshape. I would rather do this than pick a default startshape name like main or scene because many non-english speakers use Context Free.
I think that adding a Pythonic syntax is a non-starter. But I would be interested in a ContextFree module for Python. I only know a little about Python. But it seems to me that function decorators could be used to allow shape rules to be expressed as Python code. The AGG rendering engine could be bound to Python as a C++ library. It would be a fun project for someone who knows a lot of Python. I would be glad to help if someone wanted to do this.