Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.






                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);
  static CreateIdentityMatrix() {
    return new Matrix2(
      1, 0,
      0, 1,
  static CreateScaleMatrix(scaleX, scaleY) {
    return new Matrix2(
      scaleX,      0,
      0,      scaleY,

const identityMatrix = Matrix2.CreateIdentityMatrix();
const scaleMatrix = Matrix2.CreateScaleMatrix(2, 2);

const vector = new Vector2(5, 6);

const sameVector = vector.timesMatrix2(identityMatrix);
const doubledVector = vector.timesMatrix2(scaleMatrix);