Recreating - ColorWheel - noob alert

Posted on
  • Hi!

    Link to the code I am recreating:
    https://www.espruino.com/ide/?codeurl=https://rozek.github.io/BangleApps/apps/colorwheel/app.js&upload&emulator

    I am just playing around for a project in school (uploaded my code in this post) , with 0 programming skills and have som difficulties with my code (wonder why).

    As you can see, you can click on all the different modes (the colors displayed on the wheel), but not in the middle without it being called "undefined". I seemed to have fixed the problem before but after coding some more it showed up again, only this time I couldn't fix it.

    I want it to say "Set mode" if I click on the white circle in the middle and did as I did with the others:

    switch (true) {

    case (Color == standard_green):
      switchMode("Friends");
      break;
    case (Color == standard_red):
      switchMode("Work");
      break;
    case (Color == standard_pink):
      switchMode("Exercise");
      break;
    case (Color == standard_blue):
      switchMode("Study");
      break;
    **case (Color == standard_white): switchMode("Set mode"); 
      break;**
    

    }
    });

    But it won't work.

    My other problem is that I wan't my code to itterate through 20 pictures, but it only itterates through 10.
    I've defined the image variables and put them in a list:
    let blue_images = [
    blue_image_1, blue_image_2, blue_image_3, blue_image_4, blue_image_5,
    blue_image_6, blue_image_7, blue_image_8, blue_image_9, blue_image_10,
    blue_image_11, blue_image_12, blue_image_13, blue_image_14, blue_image_15,
    blue_image_16, blue_image_17, blue_image_18, blue_image_19, blue_image_20
    ];

    Anyone who knows what the problem is with the code?

    Thank you! :)


    2 Attachments

  • Hi! I don't have an answer to your question I'm afraid, but want to tip you off about using a code block in your post above. Go to edit your post -> highlight the code to be contained with a boarder and line numbers -> Press the "</> code" button in the toolbar.

    It will make it a little easier for someone to help you out :)

  • Hi, skimmed over your code... noticed several things... some are coding conventions which do not break the code but make it more difficult to build a mind map - map the code in the mind for grasping. Beside that, I noticed your Polygon = [] and its population w/ values for drawing. I could not figure how many points you add, but you have to be aware of the limit it has. Your may have too many points. Not all all drawn which could explain the missing parts. To get thru a polygon with too many values, you have to break it up into multiples to compose the final one. See Swiss Federal Railway Clock modeled w/ Circular Gauges. It's less about the clock, it is about the circular gauges: I use some algorithm to compose a partial circle (arc) drawn using polygons by actually drawing multiple segments of that partial circle (arc)... (the full circle is just a partial circle / arc of 360 degrees).

    Addendum: see g.drawPoly/fillPoly have a limit of 64 nodes - Your Color wheel.js uses 72 segments... which puts you already 12+% beyond the max limit. To achieve that: think about drawing two circles using Espruino's Graphics method .drawCircle(): draw the outer circle, and then clear the inner portion with another one... That way you take advantage of the best resolution with the highest speed.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Recreating - ColorWheel - noob alert

Posted by Avatar for Sara @Sara

Actions