Friday, July 23, 2021

A little dynamic JS in my HTML

I have to work tomorrow morning so I won’t get any real coding done tonight. I have been looking at doing more with HTML, which I basically ignore while doing javascript things with numbers and the canvas. The canvas element is just another object and I can call it and manipulate it from javascript. I’m going to create a page and pretty much do all the stuff from javascript. The idea is that the page will ask the user to ‘create a new world’, which to start with is a square canvas of some random (or pseudo-random, actually) width and the same height. So I will copy over my variables and functions for PR# and I will generate the canvas when the user clicks on ‘create a new world’, and remove it when the user clicks on another button, ‘destroy the world!’ For that I will want to do something dramatic with the canvas before it’s gone.

  1. Open new page ‘Create And Destroy The World!’

  2. Copy over my variables and functions for PR#

  3. Button to create a new canvas for which I will need a PR width and (the same) height

  4. Draw a blue or green circle in a clear rectangle, then draw some smaller circles for land or sea. I’m just doing some sloppy world mapping here

  5. Remove it and get ready to draw a new canvas and world, but blow it up first!

The important bit is to create a canvas dynamically, remove it and create a new one. Use para in the body as well to tell the user stuff without annoying pop-up dialog boxes. Doing something with canvas is the bare minimum, then I need to get to bed!


No comments:

Post a Comment