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

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)

    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    p5.js Simple Reactor
    Updated Sept 23, 2021

      p5.js Simple Reactor

      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.

       

      {"serverDuration": 34, "requestCorrelationId": "d06bf01b1ac64570bbeef475a0e06af3"}