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
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)

    Two hearts overlapped with each other
    Welcome back
    Catch up on the top discussions and highlights from your team.
    /
    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
    Luke Franzke
    p5.js Curve Reactor
    p5.js Curve Reactor
    Luke Franzke
    Reactors
    Reactors
    Luke Franzke
    (Extra) Curve Reactor
    (Extra) Curve Reactor
    Luke Franzke
    3D Reactors
    3D Reactors
    Luke Franzke
    p5.js Particle System
    p5.js Particle System
    paulina.zybinska (Unlicensed)
    {"serverDuration": 56, "requestCorrelationId": "860504e232db4259a23959bbe18b53b4"}