Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                class Vector2 {
	constructor(x, y) {
  	this.x = x;
    this.y = y;
  }
  
  timesMatrix2(matrix2) {
    const newX = (this.x * matrix2.m00) + (this.y * matrix2.m10);
    const newY = (this.x * matrix2.m01) + (this.y * matrix2.m11);
    
    return new Vector2(newX, newY);
  }
  
  magnitude() {
    return Math.sqrt(this.x ** 2 + this.y ** 2);
  }
}

class Matrix2 {
  constructor(m00, m01, m10, m11) {
    this.m00 = m00; this.m01 = m01;
    this.m10 = m10; this.m11 = m11;
  }
  
  timesMatrix2(otherMatrix2) {
    const newM00 = (this.m00 * otherMatrix2.m00) + (this.m01 * otherMatrix2.m10);
    const newM01 = (this.m00 * otherMatrix2.m01) + (this.m01 * otherMatrix2.m11);
    const newM10 = (this.m10 * otherMatrix2.m00) + (this.m11 * otherMatrix2.m10);
    const newM11 = (this.m10 * otherMatrix2.m01) + (this.m11 * otherMatrix2.m11);
    
    return new Matrix2(newM00, newM01, newM10, newM11);
  }
}

const vector = new Vector2(5, 6);
const firstMatrix = new Matrix2(5, 6, 7, 8);
const secondMatrix = new Matrix2(1, 2, 3, 4);

const vectorResult = vector.timesMatrix2(secondMatrix);

// Logs 23 34
console.log(vectorResult.x, vectorResult.y);

const matrixResult = firstMatrix.timesMatrix2(secondMatrix);

// Logs 23 34 31 46
console.log(matrixResult.m00, matrixResult.m01, matrixResult.m10, matrixResult.m11);

// In our case this would be written in matrix form as:
//
//  23 34
//  31 46
              
            
!
999px

Console