How to link a letter of a string to a shape?

edited October 2017 in How To...

Hello, I would like to link the letters of a string to some shapes, for example:

link letter "a" to an ellipse link letter "b" to a rectangle link letter "c" to a triangle

so if the string is "abc" I will have "ellipse, rect and triangle" on the screen; so if the string is "bca" I will have "rectangle, triangle and ellipse" on the screen; so if the string is "cab" I will have "triangle, ellipse and rectangle" on the screen; ... and so on.

Could you help me?

Thank you very much.

Answers

  • edited October 2017 Answer ✓

    Post the code you have so far. If you have none, attempt to write this yourself.

    You will need to define a String to store the letters. You will need a loop to iterate over the letters in that String. You will need to use conditional if( ) { } else { } statements that cause things to only happen if it is the right letter. You will need to know how to use functions to draw shapes, like triangle(), ellipse(), and rect(). Where are the shapes drawn? How is their position related to the index of the character you are looking at?

  • edited October 2017

    If you only need a few basic shapes, you could also just use geometric shapes unicode and write things directly with a font and text() commands

    ... ◢ ◯ ⬛

    However the approach that @TfGuy44 suggests is much more versatile.

Sign In or Register to comment.