Global

Members

chargeIsNegative :boolean

A variable in the global namespace which stores whether or not the next particle added will have a negative charge.
Type:
  • boolean
Source:

field :Field

A variable in the global namespace which stores the electrostatic field.
Type:
Source:

Methods

draw()

p5.js draw function, used to draw the electrostatic field and the charge indicator in the top left corner.
Source:

keyPressed()

Determines which key is pressed and checks to see if the chargeIsNegative should change. Checks to see if either a single particle or all particles should be removed from the field. Signals a re-rendering of the canvas.
Source:

mousePressed()

Adds a particle at the pointer position if the pointer is on the canvas. The particle will be either positive or negative depending on the value of the chargeIsNegative variable. Signals a re-rendering of the canvas.
Source:

setup()

p5.js setup function, used to create a canvas and instantiate the field variable.
Source:

Documentation generated by JSDoc 4.0.2 on Sun Jan 26 2025 19:14:19 GMT-0800 (Pacific Standard Time)