A Primer to Programming in Desmos

2024 autumn

A Primer to Programming in Desmos

Did you know you can develop games in Desmos?

Aw yeah, Desmos is so much more than just a graphical calculator. In fact, you can create animations, interfaces, or even entire programs. It’s kinda like Scratch – you can create anything you want, if you try hard enough!


Desmos in Action

The singular feature which makes programming in Desmos possible is actions. The Desmos article> explains them far better than I could, so have a read of that if you’re not familiar with them.

Critically, actions give us the ability to mutate state. If you think about variables:

Setting variables in Desmos

We can set them to particular values; we can change them (manually) with a slider; we can even keep them oscillating by animating the slider. What we can’t do (without actions) is use Desmos itself to change their values. We either have to type in a new value, drag the slider, or …wait for the slider to momentarily hit the value we wanted. Not exactly ideal for programming!

Actions, then, give us a programmatic way to alter variables. Check it out:

Actions in action

When we run the action, it updates the value of the variable. Now let’s pull a JavaScript and assign this expression to an identifier:

Naming an action

Now we can use $a()$ anywhere to run this action. And since it’s pretty much just a function, we can of course add parameters too:

Action with parameters

Lo and behold, what have we here? Might as well just be a function / procedure / method / whatever you wanna call it.

So, we’ve got variables, and we’ve got functions to change them. All we’re missing now is the logic to control how we go about that!


Control Flow


Circular Motion


Geometrical Graphics


Indexed
Desmos A Primer to Programming in Desmos
dev A Primer to Programming in Desmos / Coding Conventions / Python / Ruby / What’s up with my Python syntax? / Slithering Hump-Back Kebabs / Buttons: More Complicated Than They Look / decoded / 42 Methods of Flawless Fail-Safe Fixing / Gems in the Abstruse Internet / Git Gud / Migrating Windows Laptops / Especially Ingenious Quotes on Software Development / A Library to Void Future Suffering / The Programmer’s Plight / Roots
writing Generative AI / A Primer to Programming in Desmos / What’s up with my Python syntax? / Broken World / Tearful / 2 September 2024 / Eclipse / Expanse / Friend / Precipice / Seclusion / The Last Cavern / Roots / wriiiting? / wriiting / writing.

LAST DEPLOYED 10 December 2024

VIEW ON GITHUB