Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.






                var  x2 = 200, y2 = 200; // initial ordered pairs (at center of screen)
function setup() {
  createCanvas(400, 400); //create the canvas
  background(255); //black background
  frameRate (3); //frame rate or speed

function draw() {
  stroke(random(255), random(255), random(255)) //random linecolor
  strokeWeight(random(50));//random line width
  x1 = random(400);//random x1 value
  y1 = random(400);//random y1 value
  x3 = random(400);
  y3 = random(400);
  line1 = line(x1,y1,x2,y2) //draw line from center (200,200) to random (x1,y1)
  m1 = (y2-y1)/(x2-x1); //calculate slope of line1
  m2 = -1/(m1) //perpendicular slope is -1/m for line 1
  b2 = y3-x3*m2 //find b of line2 (y = mx+b) using a new point (x3,y3)
  line(x3,m2*x3+b2,x1,m2*(x1)+b2) //two points (x2,y2) and (x1,m2(x1)+b2)