Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <canvas id="canvas"></canvas>
              
            
!

CSS

              
                canvas {
  width: 100%;
  height: auto;
} 
              
            
!

JS

              
                
// const canvas = document.getElementById("canvas");
// canvas.width = 1000
// canvas.height = 1000
// const ctx = canvas.getContext("2d");

// ctx.fillStyle = '#000'


// for (let i = 0; i < 255; i++) {
//   for (let j = 0; j < 255; j++) {
//     ctx.fillStyle = `rgb(
//         ${Math.floor(i)},
//         ${Math.floor(j)},
//         0)`;
//     ctx.fillRect(j * 1, i * 1, 25, 25);
//   }
// }


const WIDTH = window.innerWidth
const HEIGHT = window.innerHeight
const HALF_WIDTH = window.innerWidth / 2
const HALF_HEIGHT = window.innerHeight / 2
const canvas = document.getElementById("canvas");
canvas.width = WIDTH
canvas.height = HEIGHT
// canvas.height = 800
let options = { colorSpace: "display-p3" };
const ctx = canvas.getContext("2d", options);

// Get the DPR and size of the canvas
const dpr = window.devicePixelRatio;
const rect = canvas.getBoundingClientRect();

// Set the "actual" size of the canvas
canvas.width = rect.width * dpr;
canvas.height = rect.height * dpr;

// Scale the context to ensure correct drawing operations
ctx.scale(dpr, dpr);

// Set the "drawn" size of the canvas
// canvas.style.width = `${rect.width}px`;
// canvas.style.height = `${rect.height}px`;


// ctx.fillStyle = '#000'




// for (let i = 0; i < 300; i++) {
  
//     for (let z = 0; z < 120; z+= 0.25) {
//       const x = Math.sin(z* (Math.PI/180)) * i + 500
//       const y = Math.cos(z* (Math.PI/180)) * i + 500
      
//       const saturation = i/300
//       const red = z / 120
//       const green = 1 - red
//       ctx.fillStyle = `color(display-p3 ${red * saturation} ${green * saturation} 0)`;
//       ctx.fillRect(x, y, 0.5, 0.5);
//   }
  
// }
const RADIUS = 300
let i = 0
let z = 0
// const patternseed = 0.00004
const patternseed = 0.1

const drawBottomRightFrame = ()=>{
  i = i < RADIUS ? i + 1 : 0
  z = z < 120 ? z + patternseed : 0
  const x = Math.sin( z * (Math.PI/180)) * i + HALF_WIDTH
  
  const y = Math.cos( z * (Math.PI/100)) * i + HALF_HEIGHT
  
 
  const saturation = i/RADIUS
  const red = z / 120
  const green = 1 - red
  
  
  // ctx.fillStyle = `color(display-p3 ${red} ${green} 0 )`;
  ctx.fillStyle = `color(display-p3 ${green} ${1 - saturation} ${red})`; // to get them all
  ctx.fillRect(x, y, 1, 1);
  
}

let a = 0
let b = 0
const drawTopFrame = ()=>{
  a = a < RADIUS ? c + 1 : 0
  b = b < 120 ? b + patternseed : 0
   const x = Math.cos(Math.PI/3 * 2 + b * (Math.PI/100)) * a + HALF_WIDTH
  
  const y = Math.sin( Math.PI/3 * 2 + b * (Math.PI/180)) * a + HALF_HEIGHT
  

  const saturation = a/RADIUS
  const red = b / 120
  const green = 1 - red
  
  
  // ctx.fillStyle = `color(display-p3 ${red} ${green} 0 )`;
  ctx.fillStyle = `color(display-p3 ${1-saturation} ${1-saturation} ${saturation})`; // to get them all
  ctx.fillRect(x, y, 1, 1);
  
}

let c = 0
let d = 0
const drawLeftFrame = ()=>{
  c = c < RADIUS ? c + 1 : 0
  d = d < 120 ? d + patternseed : 0
   const x = Math.cos(Math.PI/3 * 4 + d * (Math.PI/180)) * c + HALF_WIDTH
  
  const y = Math.sin( Math.PI/3 * 4 + d * (Math.PI/100)) * c + HALF_HEIGHT
  

  const saturation = c/RADIUS
  const red = d / 120
  const green = 1 - red
  
  
  // ctx.fillStyle = `color(display-p3 ${red} ${green} 0 )`;
  ctx.fillStyle = `color(display-p3 ${red}  ${1 - saturation} ${green}  )`; // to get them all
  ctx.fillRect(x, y, 1, 1);
  
}

const anim = ()=>{

  for (let w = 0; w < 1000; w++) {
    drawBottomRightFrame()
    drawTopFrame()
    drawLeftFrame()
  }
window.requestAnimationFrame(anim)
  
}

window.requestAnimationFrame(anim)
              
            
!
999px

Console