Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML5 Canvas line drawing
    text
    copied!<p>I'm working on a program that sets variables to random numbers, and then creates a line across the canvas where the y coordinates are different each time. In the program, one button generates a bumpy line, and the other uses some code that makes a much smoother line. </p> <p>Right now, I'm working on a way to fill the space below the randomly generated line so that it will resemble a hill, but I'm running into a few problems.</p> <p>In the "text/javascript" area, I define the canvas and its coordinates, and all of the random y value variables (but they aren't used yet). If the "bumpy" button is clicked, it runs a function that sets the y coordinate variables to anything inside the canvas, and then draws the line. If the "Smooth" button is clicked, the code randomly sets the first y coordinate variable, and then sets the next variables to a coordinate either a little bit bigger, or a little bit smaller then the previous point, and then draws the line. The third button is called "fill." This button runs another function which checks to see if a hill has been drawn yet, and the begins drawing another line using all the y coordinate values +10. (In other words, draws a line directly beneath the original line.) My plan was for the button to draw lines like this all the way to the bottom of the canvas, thus filling the space beneath the line. This is where it gets weird, and I think the problem is that the "fill" button uses information (stored in variables) that was created in other functions.</p> <p>What should I do?</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload