how do I create categories with blocks?
using blocks to create categories,not coloring blocks
Oh, sorry, I thought you meant "create categories with blocks in them". My bad.
I just put together this block:
It uses an extension function that loads blocks from an XML file (the format Snap! uses) and thus imports any custom categories in that XML file. The block just creates the XML file on the spot and then loads it. There is, however, no way to delete categories programmatically without JavaScript. If you should want to do so, check out the SciSnap! library.
My block will also accept lists:
And will even take alpha (transparency) values from 0 to 1:
Finally, you can also use it to change category colour by simply writing the name of the category in the first field and putting the new colour in the second field. Not all blocks will update their colour immediately, however.
xml plz
try using this block, for multiple categories/recolors at once:
to get this block, drag it into the snap editor.
when snap 10.8 releases, the list functionality that mark4sisb will (very likely) automatically come if you use a color [rgb(146,26,68)] ::pen reporter block in the color slot.
Did you know that you can drag script pictures into Snap! to import them? If not, try it! Otherwise, the forum is probably compressing the images for you. Here is the link to the project just in case:
https://snap.berkeley.edu/snap/snap.html#present:Username=mark4sisb&ProjectName=Custom%20Categories%20Metaprogramming
Edit: Just a quick note: when choosing category colours, always remember to consider the zebra colour that goes with it.
Edit2: Just added @sathvikrias's block to the project too so you can access it.
huh.
It's always been like that, in fact, the official colors and crayons library parses it as a string, which was added way before the color input was even an option users could use (without editing the xml). In fact, the color input is actually still a javascript option, the text parsing is just done on the text representation.
I mean, that's the reason why your own block works.