Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
/
p5.js Simple Reactor
Updated Sep 23, 2021

p5.js Simple Reactor

Analytics

Loading data...
const gridXcount = 20; const gridYcount = 20; var xSpacing; // x distance between each shape var ySpacing; // y distance between each shape var reactorScaler = 0.06; // this factor controls the intensity of the reactors influence function setup() { createCanvas(700, 700); xSpacing = width/(gridXcount-1) ySpacing = height/(gridYcount-1) fill(0); noStroke(); } function draw() { background(255); // populated canvas with ellipses for (var i = 0; i<gridXcount; i++ ) { for (var j = 0; j<gridYcount; j++ ) { var myPos = createVector(i*xSpacing, j*ySpacing); var reactorDistance = dist(mouseX, mouseY, myPos.x, myPos.y) var scaler = reactorDistance*reactorScaler; ellipse(myPos.x, myPos.y, 1*scaler, 1*scaler); } } }

 

Exercise

The example above uses the mouse point to scale the ellipses. Experiment with other shapes, and other transformations such as rotation, colour change, or more complex morphing.

 

Related content

p5.js Reactors
p5.js Reactors
Programming
More like this
p5.js Curve Reactor
p5.js Curve Reactor
Programming
Read with this
Reactors
Reactors
Programming
More like this
(Extra) Curve Reactor
(Extra) Curve Reactor
Programming
More like this
3D Reactors
3D Reactors
Programming
More like this
p5.js Particle System
p5.js Particle System
Programming
More like this
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
    • p5.js Introduction
    • p5.js Variables
    • p5.js Random Numbers
    • p5.js SVG + Images
    • p5.js WebGL
    • p5.js Classes and Objects
    • p5.js Events and Functions
    • p5.js Loops
    • p5.js Coordinates
    • P5js Nested Loops
    • p5.js Animation Exercise 1
    • p5.js Animation Exercise 2
    • p5.js Conditionals
    • p5.js Arrays and Lists
    • p5.js Simple Collision Detection
    • p5.js Reactors
      • p5.js Curve Reactor
      • p5.js Simple Reactor
      • p5.js Vector Fields
      • P5js Bitmap or SVG Permutations
    • p5.js Tiling and Repetition
    • p5.js Vectors
    • p5.js Animation Solution with Objects
    • p5.js Easing
    • p5.js Perlin Noise
    • p5.js Particle System
    • p5.js Sound
    • p5j.s Typography
    • P5js Archive
  • Programming in Processing (java)

{"serverDuration": 66, "requestCorrelationId": "10620060300849f6a9a988e9f8b2e761"}