Close

Failing to reshape blocks + feature ideas

A project log for Barnabas Blocks Upgrade - BIG 2021

Webserial API webtool to upload Arduino code.

danteDante 07/25/2021 at 01:471 Comment

Hello again,

Reshaping blocks has proven incredibly difficult. I know there are different ways blocks can be rendered (like the way they are shown on Google's documentation website versus on Barnabas Blocks):

Barnabas Blocks (with inline inputs turn on, which is not default)

Blockly documentation:

Scratch default rendering (Scratch is not actually built directly off Blockly as I previously thought, but is instead a fork with notable additions):

(source for the above is here)

Reshaping blocks is clearly possible, I just have no idea where to do it. I spent several hours cross-referencing appearances of the word "render" between Scratch and Blockly and trying to add code in various places in Barnabas Blocks to change rendering, but to no avail.

I previously mentioned the idea of searching for SVG in the codebase - I was correct that there were images embedded in the code (encoded in base64), but none of them were meaningful as they were all simple effects or not blocks (like the dropdown arrow being implemented as SVG embedded in a file). This seems like a very difficult task.

On a better note, there might be another idea to implement - a backpack system. Scratch has an account-persistent space called the backpack that can be used to store code. if code like the above (which I wrote to render clock hands) is useful in another project, entire sections of code can be dragged to the backpack and dragged out of it at another time, or even in another project.

Barnabas Blocks has no account or project system, but code that persists past clearing your workspace might be a good idea. Finding a way to serialize block XML and other specifics might be difficult, though.

Second, I thought of implementing the missing binary boolean functions - NOR, NAND,  and XOR. This should not be difficult on its own.

Slightly more difficult would be the idea to implement bitwise math in Blockly. This could prove difficult, mainly because it has a specific order of operations that has to be implemented (Blockly has a way to do orders of operation, but it's still some work), and support for bitwise math on non-integers is not part of the C standard. I doubt avr-gcc (the C compiler for Arduino) or the ATMega328P (the Arduino microcontroller) supports such a thing. Therefore Blockly would be required to either do type checking or cast every input to a bitwise operator to an integer. I haven't thought of anything specific though.

Discussions

richard wrote 07/26/2021 at 16:24 point

Hey Dante, I agree, reshaping blocks seems very very very difficult. I'm not in the nitty-gritty as you are, but I have tried to do everything humanly possible(with my ability) to no avail. Perhaps the barnabas blocks developer can chime in ;) haha. As far as the initial "easier" assignments, I think our team is all on the same page so awesome!

  Are you sure? yes | no