File Exchange Pick of the Week

Our best user submissions

String Art II

Sean‘s pick this week is also stringart by Giuseppe Cardillo.  Jiro picked this last week; I’d already written this post; this may be our first blog race condition in history.

Contents

String Art

This is a fun program for creating string or thread art. Giuseppe gives more information on the theory and history in the
FEX post. Let’s see the default. Note if you run it, you’ll see the lines animating.

stringart

We can also adjust the number of sides, density, crossings and color.

stringart('Sides', 5, 'Density', 20, 'Crossed', 1, 'Color', rand(1, 3))

Live Controls

Now, if you’re thinking that’s a lot of knobs to turn. This could be a good place for Live Controls in a Live Script. That way we can interactively adjust those parameters.

The live script can be downloaded from here so you can play with it. R2018a or newer is required.

Function Signatures

Okay, that was fun. But what if you didn’t know which options string art has? Giuseppe has given us four name-value pairs
to tune the behavior of the stringart. Starting in R2018a, we can write code suggestions that will allow the live editor or tab-complete to provide information on these name-value pairs.

I added it for string art so now you can see what happens as I type.

In the live editor:

Tab-complete at the command line or in a plain code file.

Writing Function Signatures

In order to create function signatures, you need to define a functionSignatures.json file and write the input schema. Here it is for stringart. I defined the type based on the attribute validation for each name-value pair.

{
"_schemaVersion": "1.0.0",
"stringart":
{
   "inputs":
   [
      {"name":"Sides", "kind":"namevalue", "type":[ "numeric", "scalar", "real", "integer",">=3"],"purpose":"Number of polygon sides"},
      {"name":"Crossed", "kind":"namevalue", "type":[ "numeric", "scalar", "real", "integer","<=1"],"purpose":"Crossed or not"},
      {"name":"Density", "kind":"namevalue", "type":[ "numeric", "scalar", "real", "integer",">=10"],"purpose":"Number of pins per side"},
      {"name":"Color", "kind":"namevalue", "type":[ "numeric","row","real","ncols=3",">=0","<=1"],"purpose":"Color - RGB Triplet"}
   ]
}
}

Note: I typically edit these in a third party editor which correctly highlights the JSON; in this case Visual Studio.

Comments

Do you have a use for live controls, function signatures, or a new hobby of making string art where simulating or prototyping
it with software would be faster than laying down pins?

Give it a try and let us know what you think here or leave a comment for Giuseppe.

Published with MATLAB® R2018a

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.