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

              
                <input type="checkbox" id="show-grid">
<label for="show-grid">GRID</label>
<button id="mode-type">MODE</button>
<div class="container">
	<div class="stars"></div>
	<div class="stars"></div>
	<div class="card" id="star-card"></div>
	<div class="arrows">
		<span></span>
		<span></span>
		<span></span>
		<span></span>
		<span></span>
		<span></span>
		<span></span>
		<span></span>
	</div>
</div>
              
            
!

CSS

              
                body {
	overflow: hidden;
	margin: 0;
	padding: 0;
}

* {
	box-sizing: border-box;
	position: absolute;
	transform-style: preserve-3d;
}

*:before, *:after {
	box-sizing: border-box;
	transform-style: preserve-3d;
	position: absolute;
	content: "";
}

body {
	margin: 0;
	padding: 0;
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	perspective: 50vmin;
	background-size: 100vw 100vh;
	background-image: 
		radial-gradient(#0000, #673ab72e), 
		linear-gradient(-90deg, #2000587d, #000, #9c27b02b), 
		linear-gradient(0deg, #ff98002e, #000, #8bc34a5e);
	background-color: #000;
	box-shadow: 0 0 150vmin 11vmin #000 inset;
}

body:before {
	width: 100vw;
	height: 100vh;
	background: 
		radial-gradient(#0000, #0a123a), 
		linear-gradient(180deg, #2000587d, #000, #9c27b02b), 
		linear-gradient(0deg, #ff980054, #000, #009688ba);
}

/* Grid */
#show-grid { display: none; }
label[for=show-grid] {
	position: absolute;
	z-index: 5;
	background: #f004;
	cursor: pointer;
	bottom: 20px;
	left: 50%;
	width: 45px;
	height: 45px;
	transform: translateX(calc(-50% - 115px));
	font-family: Arial, serif;
	font-size: 11px;
	text-align: center;
	box-shadow: 0 0 0 2px #fff1;
	background: #0006;
	padding: 8px 0;
	border-radius: 2px;
	color: #fff;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: space-evenly;
	mix-blend-mode: overlay;
}
label[for=show-grid]:hover {
	background: #fff4;
}
label[for=show-grid]:before {
	font-size: 9px;
	content: "SHOW";
	position: relative;
}
#show-grid:checked + label[for=show-grid]:before {
	content: "HIDE";
}



/*** Mode Type ***/

#mode-type {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: 20px;
	border: 0;
	background: #0006;
	color: #ccc;
	font-weight: bold;
	padding: 15px;
	cursor: pointer;
	z-index: 3;
	font-size: 10px;
	line-height: 15px;
	border-radius: 2px;
	min-width: 175px;
	text-align: right;
	box-shadow: 0 0 0 2px #fff1;
	mix-blend-mode: overlay;
}

#mode-type:before {
	position: relative;
	margin-right: 10px;
	content: "FORWARD";
	font-size: 18px;
	color: #fff;
	float: left;
	font-weight: normal;
}

#mode-type.backward:before {
	content: "BACKWARD";
}

#mode-type:hover {
	background: #fff4;
	color: #fff;
}

#mode-type:hover:before {
	color: #fff;
	content: "CHANGE";
	text-indent: 5px;
	text-shadow: 0 0 1px #000;
}

#mode-type:after {
	content: "";
	display: inline-block;
	float: right;
	position: absolute;
	background: 
		linear-gradient(-45deg, #cdcdcd 4px, #fff0 0 calc(100% - 4px), #cdcdcd 0 100%),
		linear-gradient(45deg, #cdcdcd 4px, #fff0 0 calc(100% - 4px), #cdcdcd 0 100%),
		linear-gradient(-45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		linear-gradient(-45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		linear-gradient(45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		linear-gradient(45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		#0006;
	background-repeat: no-repeat;
	background-size: 22px 22px, 22px 22px, 9px 9px, 9px 9px, 9px 9px, 9px 9px, 100% 100%;
	background-position: 11px 11px, 11px 11px, 24px 11px, 11px 24px, 11px 11px, 24px 24px, 0 0;
	width: 45px;
	height: 45px;
	right: -50px;
	top: 0px;
	box-shadow: 0 0 0 2px #fff1;
	border-radius: 2px;
}

#mode-type.backward:after {
	background: 
		linear-gradient(135deg, #fff0 0 4px, #fff 4px 100%),
		linear-gradient(225deg, #fff0 0 4px, #fff 4px 100%),
		linear-gradient(315deg, #fff0 0 4px, #fff 4px 100%),
		linear-gradient(45deg, #fff0 0 4px, #fff 4px 100%),
		linear-gradient(-45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		linear-gradient(-45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		linear-gradient(45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		linear-gradient(45deg, #fff0 calc(50% - 2px), #fff calc(50% - 1px) calc(50% + 1px), #fff0 calc(50% + 2px)),
		#0006;
	background-repeat: no-repeat;
	background-size: 6px 6px, 6px 6px, 6px 6px, 6px 6px, 8px 8px, 8px 8px, 8px 8px, 8px 8px, 100% 100%;
	background-position: 14px 14px, 24px 14px, 24px 24px, 14px 24px, 25px 11px, 11px 25px, 11px 11px, 25px 25px, 0 0;
}



.container {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
}

/*** Stars ***/
.stars {
	position: absolute;
	width: 100vw;
	height: 100vh;
}

.stars:before, .stars:after {
	width: 200vw;
	height: 200vh;
	content: "";
	background: #fff0;
	border-radius: 100%;
	background-image: repeating-conic-gradient(#FFF8 0%, transparent .0002%, transparent .075%, transparent .65%), repeating-conic-gradient(#FFF 0%, transparent .0004%, transparent 0.05%, transparent .495%);
	transform: translateZ(-40vmin);
	opacity: 0;
	animation: stars 4s ease-in-out 0s infinite;
	z-index: 1;
	left: -50vw;
	top: -50vh;
}

.stars:after {
	animation-name: stars2;
	animation-delay: 1s;
}

button#mode-type.backward + .container .stars:before,
button#mode-type.backward + .container .stars:after {
	animation-direction: reverse;
}

@keyframes stars {
	0% { transform: translateZ(-40vmin); opacity: 0; }
	30%, 70% { opacity: 1; }
	90% { opacity: 1;}
	100% { transform: translateZ(40vmin) rotate(15deg); opacity: 0; }
}

@keyframes stars2 {
	0% { transform: translateZ(-40vmin) rotate(180deg); opacity: 0; }
	30%, 70% { opacity: 1; }
	90% { opacity: 1;}
	100% { transform: translateZ(40vmin) rotate(195deg); opacity: 0; }
}

.stars + .stars::before {
	animation-delay: 2s;
}

.stars + .stars::after {
	animation-delay: 3s;
}


/*** Card ***/
.card {
	width: 100vw;
	height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	position: relative;
	overflow: hidden;
}

#show-grid:checked ~ .container .card {
	background:
		linear-gradient(0deg, #fff0 calc(33.33% - 2px), #fff1 33.33%, #fff0 calc(33.33% + 2px) calc(66.66% - 2px), #fff1 66.66%, #fff0 calc(66.66% + 2px) 100%),
		linear-gradient(90deg, #fff0 calc(33.33% - 2px), #fff1 33.33%, #fff0 calc(33.33% + 2px) calc(66.66% - 2px), #fff1 66.66%, #fff0 calc(66.66% + 2px) 100%);
}



/* Arrows */
.arrows {
	position: absolute;
	width: 100%;
	height: 100%;
	opacity: 0.1;
	display: none;
}

#show-grid:checked ~ .container .arrows {
	display: block;
}

.arrows span {
	position: absolute;
	width: 14px;
	height: 16px;
	background: 
		conic-gradient(from 90deg at 0% 0%, #fff 0 25%, #fff0 0 100%), 
		conic-gradient(from 135deg at 50% 0%, #fff 0 25%, #fff0 0 100%);
	left: 25%;
	top: 25%;
	background-repeat: no-repeat;
	background-size: 7px 9px, 14px 8px ;
	background-position: 4px 7px, 0 0;
	transform: rotate(-45deg);
}

.arrows span:nth-child(2) { 
	transform: rotate(0deg);	
	left: 50%;
}

.arrows span:nth-child(3) { 
	transform: rotate(45deg);	
	left: 73%;
}

.arrows span:nth-child(4) { 
	transform: rotate(90deg);	
	left: 73%;
	top: 50%;
}

.arrows span:nth-child(5) { 
	transform: rotate(135deg);	
	left: 73%;
	top: 73%;
}

.arrows span:nth-child(6) { 
	transform: rotate(180deg);	
	left: 50%;
	top: 73%;
}

.arrows span:nth-child(7) { 
	transform: rotate(225deg);	
	top: 73%;
}

.arrows span:nth-child(8) { 
	transform: rotate(270deg);	
	top: 50%;
}

#mode-type.backward ~ .container .arrows span:nth-child(1) { 
	transform: rotate(135deg);	
}
#mode-type.backward ~ .container .arrows span:nth-child(2) { 
	transform: rotate(180deg);	
}
#mode-type.backward ~ .container .arrows span:nth-child(3) { 
	transform: rotate(225deg);	
}
#mode-type.backward ~ .container .arrows span:nth-child(4) { 
	transform: rotate(270deg);	
}
#mode-type.backward ~ .container .arrows span:nth-child(5) { 
	transform: rotate(315deg);	
}
#mode-type.backward ~ .container .arrows span:nth-child(6) { 
	transform: rotate(0deg);	
}
#mode-type.backward ~ .container .arrows span:nth-child(7) { 
	transform: rotate(45deg);	
}
#mode-type.backward ~ .container .arrows span:nth-child(8) { 
	transform: rotate(90deg);	
}
              
            
!

JS

              
                let stars = [];
modeType = 0;

function setup() {
  let canvas = createCanvas(window.innerWidth, window.innerHeight);
  canvas.parent('star-card');
}

function draw() {
  clear();
  for (let i = 0; i < stars.length; i++) {
    let star = stars[i];
    star.update();
    star.display();
  }
}

function mouseMoved() {
  if (mouseX >= 0 && mouseY >= 0 && mouseX <= width && mouseY <= height) {
    let star = new Star(mouseX, mouseY);
    stars.push(star);
  } 
}

class Star {
  constructor(x, y) {
		let w3 = width / 3;
		let h3 = height / 3;
    this.x = x;
    this.y = y;
    this.alpha = 255;
    this.speed = random(2, 5);
		//this.angle = random(TWO_PI);
		//MODES		
		if(modeType==0){ //forward
    	this.radius = random(1, 5); 
			//forward grid
			if (mouseY <= h3) {   // top row
			 if (mouseX <= w3 * 3) { // right col
				this.angle = (random(TWO_PI) / 4) + 4.75;
			 }
			 if (mouseX <= w3 * 2) { // middle col
				this.angle = (random(TWO_PI) / 4) + 4;
			 }
			 if (mouseX <= w3) { // left col
				this.angle = (random(TWO_PI) / 4) + 3.1;
			 }
			} else if (mouseY >= height / 3 * 2) { // bottom row
				if (mouseX <= w3 * 3) { // right col
					this.angle = (random(TWO_PI) / 4) + 6.3;
				}
				if (mouseX <= w3 * 2) { // middle col
					this.angle = (random(TWO_PI) / 4) + 0.75;
				}
				if (mouseX <= w3) { // left col
					this.angle = (random(TWO_PI) / 4) + 1.55;
				}
			} else { // middle row
				if (mouseX <= w3 * 3) { // right
					this.angle = (random(TWO_PI) / 4) + 5.5;
				}
				if (mouseX <= w3 * 2) { // middle
					this.angle = random(TWO_PI);
				}
				if (mouseX <= w3) { // left
					this.angle = (random(TWO_PI) / 4) + 2.35;
				}
			}
		} else { // backward
			this.radius = random(5, 9); 
			//backward grid
			if (mouseY <= h3) {   // top row
			 if (mouseX <= w3 * 3) { // right col
				this.angle = (random(TWO_PI) / 4) + 1.5;
			 }
			 if (mouseX <= w3 * 2) { // middle col
				this.angle = (random(TWO_PI) / 4) + 0.9;
			 }
			 if (mouseX <= w3) { // left col
				this.angle = (random(TWO_PI) / 4) + 6.3;
			 }
			} else if (mouseY >= height / 3 * 2) { // bottom row
				if (mouseX <= w3 * 3) { // right col
					this.angle = (random(TWO_PI) / 4) + 3.15;
				}
				if (mouseX <= w3 * 2) { // middle col
					this.angle = (random(TWO_PI) / 4) + 4;
				}
				if (mouseX <= w3) { // left col
					this.angle = (random(TWO_PI) / 4) + 4.7;
				}
			} else { // middle row
				if (mouseX <= w3 * 3) { // right col
					this.angle = (random(TWO_PI) / 4) + 2.3;
				}
				if (mouseX <= w3 * 2) { // middle col
					this.angle = random(TWO_PI);
					this.speed = random(1, 2);
				}
				if (mouseX <= w3) { // left col
					this.angle = (random(TWO_PI) / 4) + 5.5;
    			this.speed = random(2, 5);
				}
			}
		}
  } // constructor

  update() {
    this.x += cos(this.angle) * this.speed;
    this.y += sin(this.angle) * this.speed;
    this.alpha -= 1;
		this.radius += 0.01;
		if(modeType==0){
			this.radius += 0.01;
		} else {
			this.radius -= 0.1;
		}
    if (this.alpha <= 0 || this.radius > 20 || this.radius < 0) {
      stars.splice(stars.indexOf(this), 1);
    }
		let rr = random(255);
		let gg = random(255);
		let bb = random(255);
    fill(rr, gg, bb);
  }

  display() {
    noStroke();
    push();
    translate(this.x, this.y);
    rotate(frameCount * 0.02);
    star(0, 0, this.radius * 5, this.radius * 0.5, 100); // change the multiplier here to change the star radius, or change the last number to modify the number of points 
    pop();
  }
}

function star(x, y, radius1, radius2, npoints) {
  let angle = TWO_PI / npoints;
  let halfAngle = angle / 2.0;
  beginShape();
  for (let a = 0; a < TWO_PI; a += angle) {
    let sx = x + cos(a) * radius2;
    let sy = y + sin(a) * radius2;
    vertex(sx, sy);
    sx = x + cos(a + halfAngle) * radius1;
    sy = y + sin(a + halfAngle) * radius1;
    vertex(sx, sy);
  }
  endShape(CLOSE);
}

document.querySelector('#mode-type').addEventListener('click', function() {
	 (modeType == 0) ? modeType = 1 : modeType = 0;
	this.classList.toggle('backward');
});
              
            
!
999px

Console