Shapes: Interactive shape drawing

Discuss your custom applets, calculation tools

Shapes: Interactive shape drawing

Postby oliver » Tue Nov 01, 2016 10:30 pm

Shapes is a simple interactive shape drawing tool.

It uses the Plot user folder and gives you options to select a shape and two sliders to vary the parameters that define how it's drawn.
It gives you an error message, if you don't have the Plot folder installed.

Here's how it looks:
Simulator Screen Shot Nov 1, 2016, 10.21.39 PM.png
Shapes screenshot
Simulator Screen Shot Nov 1, 2016, 10.21.39 PM.png (206.38 KiB) Viewed 84 times

Here's the code that glues UI and drawing together. You find it in the calc's Injection section.
(If you see no such section on your calc's definition page, you didn't enable injections yet. To do so, go into Settings > ND1 and turn on Show JS Injections."

Code: Select all
vars.shape = 0;
vars.a = 7;
vars.b = 15;

window.onUIChange = function(obj) {
    vars.shape = obj.shape;

window.onSliderChange = function(obj){
    if (obj.a)
        vars.a = obj.a * 30;
    else if (obj.b)
        vars.b = obj.b * 30;

showShape = function() {
    switch(vars.shape) {
        case 0: return[vars.a, vars.b]);
        case 1: return ME.Plot.noise(vars.a*3);
        case 2: return ME.Plot.spiral(-vars.a, vars.b);

if (ME.Plot)
    alert("Please go to My Data and download the Plot folder.");
Site Admin
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Return to Applets / Calculators

Who is online

Users browsing this forum: No registered users and 1 guest