Color and Texture In Desmos

Desmos the tool is an online graphing calculator, Desmos the site is a page that links to the calculator portion and a few other pages that cover graphs that the Desmos staff found notable. The staff picked graphs fall into two categories namely, “Math Examples” and “Creative Art”. I want to talk about a big problem with the latter of the two, namely it’s bias toward bad line art, and offer a few solutions.

First a bit of context. As I’m writing this, the graph art page is this:

Clipboard01

There’s a lot to unpack here.

First weird color choices. Violin, the shoe, Harry, and Disney Castle are all composed of lines that use the default colors that you get when making functions in Desmos. I suspect this is just because they didn’t know that they could change the colors on the functions when making a graph, but the result of having terrible colors is still what happens. Also that Mickey. Why this person chose purple and red I will never understand.

Next major issue is wonky shaping. Project and Drumset both have something clearly off about them, in a way that doesn’t necessarily look intentional. More specifically, Drumset is made entirely out of oddly utilized conics, that is parabolas and ellipsoids and such, that make the perspective look really screwed up. This is probably just because the creator wasn’t going for detail and probably didn’t know many more equations than those, but the point that it looks bad still stands.

The bunny, Winnie, and Rick are all marred my the fact that they’re just tracings of other images. This is a deeper issue that deserves another post entirely.

All that said, there’s still one aspect that’s setting each of these graphs back in a big way.

They’re all just line art.

I have no idea why all that the Desmos staff ever picks seems to be mediocre line art. Perhaps that’s all there is. Nobody really cares all that much about Desmos graph art, so it would make sense if nobody saw that much reason to make more substantial graph art. That I can’t fix, but the fact that these are all fairly bland pieces of line art is something I can offer help with.

If you want to shade in your piece of graph art, there are a few techniques I’m aware of that you could use. The rest of this post will be dedicated to exploring those.

Method 1: Shading

Desmos is primarily designed as a graphing calculator, and as such supports inequalities. That is to say if you have an equation like y>x, Desmos will shade in the region for which this is true, in this case the space above the line. The shading will be more translucent than the lines that one can make in Desmos, such that shaded regions can overlap. There are deeper ways to control the regions that can be shaded in this way, but for now I’ll just point out that it’s something that one can do.

Of the graphs pictured above, only two make use of anything beyond lines. Those are the bunny and the ballerina, both of which use it only sparingly and, coincidentally, inside of ellipses.

Shading is best for it’s easy manipulation and versatility. The aforementioned translucence lends itself to overlaying areas of shading, which can be used to create most of the colors a person could want.

Method 2: Lining

This one’s a little weirder than the last. Later methods far outdo this is terms of strangeness, but I’d still like to ask you to bear with me.

Lining looks like this:

Obviously I call it lining because it’s the type of shading that uses lines.

Basically the idea here is to have a set of lines or curves that create smooth shading through variations in density. That is, it looks darker when there are more lines close together.

Using this method relies on having fairly close control over large numbers of equations. This can be achieved manually, if you’re insane, or with lists the way I did in the graph above. In said graph, I have a list separating a bunch of lines. Then I distort those lines by adding in a multivariable equation. Then same effect could be achieved any number of other ways, but the point is that it works.

Method 3: Fill

Now we’re really going deep. Fill is the one of the only things in Desmos that I’m absolutely sure nobody knows about. It’s based on a glitch and may not work in the future, but is still worthy of note for as long as it isn’t patched.

To explain fill, I’ll first describe how I found out about it. I was playing around with the equation for a circle when it occurred to me to set x^2 + y^2 equal to something other than a constant. I set it to x and it graphed a circle of radius .5 tangent to the y axis at zero. Likewise I set it equal to y and got the same thing but tangent to the x axis. I set x^2 + y^2 equal to the square root of x^2 + y^2 and got a circle as if I had set it equal to 1.

Then I squared the aforementioned root and got this:

Clipboard01.jpg

This is what I call fill.

The best explanation I have for why this happens has to do with rounding errors in calculators. Sometimes when testing a calculator’s accuracy a person will put it through a test where they take the square root of a non-square number and then square the output to compare it to the original input. For example, they’ll take the square root of 2, square the decimal output, and it will likely come out as 1.9999999999 or something.

If you just set an equation equal to itself, Desmos won’t graph anything since it can’t detect any areas of change. However, using some functions to produce slight errors can trick Desmos into filling a space with the little scattered lines pictured above since it’s constantly detecting places to put lines.

Overall, fill is useful as it can fill spaces with texture rather than some flat color. It’s a bit hard to control, but if utilized properly it can be extremely versatile. For instance, if you construct fill around just one variable, the lines will only appear vertically. Likewise, using functions that produce more errors in certain regions can be used to make automatic areas of fill, which I used to make the galaxy in the sky of the Gatsby Graph that’s at the top of this blog.

Method 4: Post-Fill

It just works.

As it stands I have very little of an idea of what mechanisms produce the thing that I call post-fill. However, I do have some guesses.

Desmos processes single and multi- variable equations differently. For instance, if you tell it to graph y=sin(100x), it will do so in fairly high detail as it only has to process one axis of inputs. However if you tell it to graph say, 0=(sin(100x)-y)^3, which is the same curve, it will do so in much less detail because it’s suddenly having to process a plane of inputs rather than an axis. Post-fill, I think, comes from some sort of difficulty in trying to reconcile these two styles of calculation.

This is post-fill:

Clipboard01.jpg

As you can see, it’s some sort of shading error that can be produced by squaring a simple equation and then telling Desmos to shade the region that’s greater than zero. Swapping the x and y of the above equation will result in the grain of the glitch going horizontally rather than vertically.

Post-fill does not work if the second term of the equation getting squared is a power of 2. I’m told this is because computers, which work in binary, have an easier time with powers of 2, but as I don’t understand the mechanics of the glitch I can’t tell how much that actually effects the output.

The biggest issue in using post-fill has to do with the fact that it doesn’t work unless the conflict that produces it maintained. That is to say that you can’t do too much to the equation without Desmos deciding to use the shading checks that govern more complex equations, which would kill the effect. Boundaries can be put on it, but only boundaries that go along with the grain of the glitch. As such it can at most be used to produce an interesting background.

Method 5?: Plaid

And yeah, since it’s the day after April Fools I’ll note that adding “?plaidMode” to the end of a Desmos URL will turn all shading plaid.

Thanks for reading, and happy graphing!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s