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

JavaScript

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

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

              
                .gamebox
  canvas#app(width=1000, height=450)
  .time Time 1:20
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Lato:400,400i,700")

html, body
  background-color: black
  height: 100%
  display: flex
  justify-content: center
  align-items: center

.gamebox
  width: 1000px
.time
  font-family: Lato
  color: #eee
  text-align: right
              
            
!

JS

              
                var canvas = document.getElementById('app');
var ctx = canvas.getContext('2d');
let bgImg = new Image(),
    comet = new Image(),
    star = new Image();


// const gameStart = {
//     key: 'gameStart',
//     preload: function(){
//         this.load.image('userImg', comet);
//         this.load.image('starImg', star);
//     },
//     create: function(){
//         this.player = this.physics.add.sprite(150, 150, 'userImg');
//         this.star = this.add.sprite(100, 100, 200, 120, 'starImg');
//     },
//     update: function(){}
// }

// // config
// const config = {
//     type: Phaser.AUTO,
//     width: 1000,
//     height: 450,
//     parent: 'app',
//     physics: {
//         default: 'arcade',
//         arcade: {
//             gravity: {
//                 y: 850
//             },
//             // debug: true,
//         },
//     },
//     scene: [
//         gameStart,
//     ]
// }
// const game = new Phaser.Game(config);

// bg.img
function loadImg(imgName, imgW, imgH, url) {
  imgName.onload = function(){
    ctx.drawImage(imgName, 0, 0,imgW, imgH);
  }
  imgName.src = url;
}

!(function draw() {
  ctx.fillStyle = "#030B33";
  ctx.fillRect(0, 0, 1000, 450);
  var g = ctx.createLinearGradient(1000, 0, 1000, 450);
  g.addColorStop(0,"rgba(136, 0, 204, .32)");
  g.addColorStop(.4,"rgba(136, 0, 204, 0)");
  ctx.fillStyle = g;
  ctx.fillRect(0, 0, 1000, 450);

  var g = ctx.createLinearGradient(0, 0, 1000, 450);
  g.addColorStop(.6,"rgba(0, 64, 153, 0)");
  g.addColorStop(1,"rgba(0, 64, 153, 0.4)");
  ctx.fillStyle = g;
  ctx.fillRect(0, 0, 1000, 450);

  var g = ctx.createLinearGradient(0, 0, 1000, 0);
  g.addColorStop(0,"rgba(115, 6, 6, .4)");
  g.addColorStop(1,"rgba(115, 6, 6, 0)");
  ctx.fillStyle = g;
  ctx.fillRect(0, 0, 1000, 450);
})();

setTimeout(function(){
  loadImg(bgImg, 1000, 460, 'https://drive.google.com/uc?export=view&id=1vCxlkyvQSdv8QaYLqz2yUHLpy-K0sTqo')
},0);

setTimeout(function(){
  colorBall('#FF7ACA', '#FF440A', 450, -270, .85, .85)
  colorBall('#CD5BDE', '#8AAEEC', 300, 240, .7, .7)
  colorBall('#8E8E93', '#68686E', 130, -110, .4, .4)
  colorBall('#8E8E93', '#68686E', -140, -190, .75, .75)
  colorBall('#FFCF69', '#8BFAFF', 830, 200, .55, .55)
  comet.onload = function(){
    
    ctx.translate(80, 250);
    ctx.drawImage(comet, 0, 0,200, 120);
  }
  comet.src = 'https://drive.google.com/uc?export=view&id=18L58iwwnp4AFnCA1VyF-qdt6ZB3MlsKp';
},3000);

setTimeout(function(){
  star.onload = function(){
    ctx.translate(590, 0);
    ctx.drawImage(star, 0, 0, 80, 80);
  }
  star.src = 'https://drive.google.com/uc?export=view&id=1Zix4dRrG0RGRcRKIEFqavs4O-OzExLFe';
},4000);

function colorBall(color1, color2, transX, transY, sizeX, sizeY) {
  ctx.save();
  ctx.translate(transX, transY);
  ctx.scale(sizeX, sizeY);
  
  ctx.save();
  var g = ctx.createLinearGradient(250, 100, 250, 400);
  g.addColorStop(0, color1);
  g.addColorStop(1, color2);
  ctx.fillStyle = g;
  ctx.beginPath();
  ctx.arc(250, 250, 150, 0, 6, false);
  ctx.closePath();
  ctx.fill();
  ctx.restore();

  ctx.save();
  var g = ctx.createLinearGradient(100, 231, 400, 231);
  g.addColorStop(0, 'rgba(0,  0,  0,  0)');
  g.addColorStop(0.36, 'rgba(0,  0,  0,  0.1)');
  g.addColorStop(0.64, 'rgba(0,  0,  0,  0.1)');
  g.addColorStop(1, 'rgba(0,  0,  0,  0)');
  ctx.fillStyle = g;
  ctx.beginPath();
  ctx.moveTo(400, 236);
  ctx.bezierCurveTo(392, 312, 328, 371, 250, 371);
  ctx.bezierCurveTo(172, 371, 108, 312, 101, 236);
  ctx.bezierCurveTo(100, 240, 100, 245, 100, 250);
  ctx.bezierCurveTo(100, 333, 167, 400, 250, 400);
  ctx.bezierCurveTo(333, 400, 400, 333, 400, 250);
  ctx.bezierCurveTo(400, 245, 400, 240, 400, 236);
  ctx.closePath();
  ctx.fill();
  ctx.restore();

  ctx.save();
  var g = ctx.createLinearGradient(260, 267, 175, 120);
  g.addColorStop(0, 'rgba(255,  255,  255,  0)');
  g.addColorStop(1, 'rgba(255,  255,  255,  0.15)');
  ctx.fillStyle=g;
  ctx.beginPath();
  ctx.moveTo(131, 341);
  ctx.bezierCurveTo(102, 273, 128, 192, 194, 154);
  ctx.bezierCurveTo(260, 116, 343, 134, 388, 193);
  ctx.bezierCurveTo(386, 187, 383, 181, 379, 175);
  ctx.bezierCurveTo(338, 103, 246, 79, 175, 120);
  ctx.bezierCurveTo(103, 162, 79, 253, 120, 325);
  ctx.bezierCurveTo(124, 331, 127, 336, 131, 341);
  ctx.closePath();
  ctx.fill();
  ctx.restore();

  ctx.save();
  ctx.fillStyle = 'rgba(255,  255,  255,  0.15)';
  ctx.moveTo(369, 341);
  ctx.bezierCurveTo(398, 273, 372, 192, 306, 154);
  ctx.bezierCurveTo(240, 116, 157, 134, 112, 193);
  ctx.bezierCurveTo(115, 187, 117, 181, 121, 175);
  ctx.bezierCurveTo(162, 104, 254, 79, 325, 120);
  ctx.bezierCurveTo(397, 162, 421, 253, 380, 325);
  ctx.bezierCurveTo(377, 331, 373, 336, 370, 341);
  ctx.fill();
  ctx.restore();

  ctx.save();
  var g = ctx.createLinearGradient(210, 41, 370, 319);
  g.addColorStop(0, 'rgba(255, 255, 255, 0.25)');
  g.addColorStop(1, 'rgba(255, 255, 255, 0.3)');
  ctx.fillStyle = g;
  ctx.beginPath();
  ctx.moveTo(132, 158);
  ctx.bezierCurveTo(159, 123, 202, 100, 250, 100);
  ctx.bezierCurveTo(333, 100, 400, 167, 400, 250);
  ctx.bezierCurveTo(400, 270, 396, 288, 390, 305);
  ctx.bezierCurveTo(383, 310, 377, 315, 370, 319);
  ctx.bezierCurveTo(293, 363, 196, 337, 151, 260);
  ctx.bezierCurveTo(133, 228, 127, 192, 132, 158);
  ctx.closePath();
  ctx.fill();
  ctx.restore();

  ctx.save();
  ctx.fillStyle='rgba(255, 255, 255, 0.3)';
  ctx.beginPath();
  ctx.moveTo(130, 320);
  ctx.bezierCurveTo(207, 363, 304, 337, 349, 260);
  ctx.bezierCurveTo(367, 228, 373, 192, 369, 158);
  ctx.bezierCurveTo(341, 123, 298, 100, 250, 100);
  ctx.bezierCurveTo(167, 100, 100, 167, 100, 250);
  ctx.bezierCurveTo(100, 270, 104, 288, 111, 305);
  ctx.bezierCurveTo(117, 310, 123, 315, 130, 319);
  ctx.closePath();
  ctx.fill();
  ctx.restore();

  ctx.save();
  ctx.fillStyle = 'rgba(255, 255, 255, 0.3)';
  ctx.beginPath();
  ctx.moveTo(300, 166);
  ctx.bezierCurveTo(300, 194, 278, 216, 250, 216);
  ctx.bezierCurveTo(222, 216, 200, 194, 200, 166);
  ctx.bezierCurveTo(200, 138, 222, 116, 250, 116);
  ctx.bezierCurveTo(278, 116, 300, 138, 300, 166);
  ctx.closePath();
  ctx.fill();
  ctx.restore();
  
  ctx.save();
  ctx.fillStyle="white";
  ctx.fillStyle="rgba(255, 255, 255, 0.1)";
  ctx.beginPath();
  ctx.arc(250, 250, 195, 0, 6.6, false);
  ctx.closePath();
  ctx.fill();
  ctx.restore();
  
  ctx.save();
  ctx.fillStyle="white";
  ctx.fillStyle="rgba(255, 255, 255, 0.1)";
  ctx.beginPath();
  ctx.arc(250, 250, 250, 0, 6.6,false);
  ctx.closePath();
  ctx.fill();
  ctx.restore();
  ctx.restore();
}
              
            
!
999px

Console