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
field :Field
A variable in the global namespace which stores the electrostatic field.
Type:
Methods
draw()
p5.js draw function, used to draw the electrostatic field and the charge
indicator in the top left corner.
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.
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.
setup()
p5.js setup function, used to create a canvas and instantiate the field
variable.