123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body>
	<main class="scene">
		<div class="sky" id="sky">
			<canvas id="canvas"></canvas>
		</div>
		<div class="ground">
			<div class="rover">
				<div class="rover-tracks"></div>
				<div class="wheel-row">
					<div class="wheel"></div>
					<div class="wheel"></div>
					<div class="wheel"></div>
				</div>
				<div class="wheel-row rear">
					<div class="wheel"></div>
					<div class="wheel"></div>
					<div class="wheel"></div>
				</div>
				<div class="chassis">
					<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" id="chassis">
						<polyline points="480,120 340,30 250,10 150,55" class="darker"/>
						<polyline points="480,120 340,30 250,10 150,55"/>
						<polyline points="45,100 45,55 260,55 260,100" class="darker"/>
						<polyline points="45,100 45,55 260,55 260,100"/>
						<circle cx="150" cy="55" r="15"/>
					</svg>					
				</div>
				<div class="chassis rear">
					<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" id="chassis">
						<polyline points="45,100 45,55 260,55 260,100" class="darker"/>
						<polyline points="480,120 340,30 250,10 150,55" class="darker"/>
						<polyline points="45,100 45,55 260,55 260,100"/>
						<polyline points="480,120 340,30 250,10 150,55"/>
						<circle cx="150" cy="55" r="15"/>
					</svg>					
				</div>
				<div class="body"></div>
				<div class="panels"></div>
				<div class="camera-mount">
					<div class="camera-lower"></div>
					<div class="camera-upper"></div>
				</div>
				<div class="antenna"></div>
				<div class="light blink"></div>
			</div>
		</div>
	</main>
</body>
            
          
!
            
              // base colors

$black: #000;
$white: #fafafa;

// mars colors
$softpeach: #eee2e2;
$calico: #e3c09d;
$tonyspink: #e39776;
$reddamask: #dd6345;
$thunderbird: #b83b1c;

$tuna: #2f2f3a;

// ui settings

$font-disabled: 0.38;
$font-medium: 0.6;
$font-high: 0.87;

$font-disabled-black: rgba($black, $font-disabled);
$font-medium-black: rgba($black, $font-medium);
$font-high-black: rgba($black, $font-high);

$font-disabled-white: rgba($white, $font-disabled);
$font-medium-white: rgba($white, $font-medium);
$font-high-white: rgba($white, $font-high);

$border-width: 3px;
$border-radius: $border-width;

$battery: #4caf50;
$battery-low: #ef5350;

$message-background: #dcedc8;

// illustration settings

// corresponds to 1.5m
$rover-color: lighten($tuna,50);
$rover-color-red: desaturate(darken($reddamask,10),30);
$rover-height: 30rem;

* {
	box-sizing: border-box;
	padding: 0;
	margin: 0;
	position: relative;

	&::before,
	&::after {
		content: "";
		display: block;
		position: absolute;
	}
}

body {
	background: #eee;
	font-family: "Roboto", sans-serif;
	line-height: 1.5;
	overflow: hidden;
	width: 100vw;
	height: 100vh;
}

.scene {
	display: grid;
	grid-template-columns: 1fr;
	grid-template-rows: 2fr 1fr;
	width: 100%;
	height: 100%;
}

.sky {
	grid-row-start: 1;
	background-image: linear-gradient(
		to top,
		$softpeach 0,
		$calico 15%,
		$tuna 90%
	);
}

.ground {
	background-image: linear-gradient(
		to top,
		$reddamask,
		$tonyspink,
		darken($softpeach, 10)
	);
	grid-row-start: 2;
}

.rover-tracks {
	background-image: repeating-linear-gradient(
		-40deg,
		desaturate($thunderbird,15) 0,
		desaturate($thunderbird,15) 0.25rem,
		darken(desaturate($thunderbird,15),3) 0.25rem,
		darken(desaturate($thunderbird,15),3) 0.5rem
	);
	box-shadow: 0 0 4px 0 $tuna inset;
	height: 1rem;
	width: 500rem;
	
	opacity: 0.4;
	
	position: absolute;
	bottom: 0;
	right: 2.5rem;
	
	&::before {
	background-image: repeating-linear-gradient(
		-40deg,
		desaturate($thunderbird,15) 0,
		desaturate($thunderbird,15) 0.25rem,
		darken(desaturate($thunderbird,15),3) 0.25rem,
		darken(desaturate($thunderbird,15),3) 0.5rem
	);
		box-shadow: 0 0 4px 0 $tuna inset;
		height: 1rem;
		width: 500rem;
		bottom: 1.5rem;
	}
}

.rover {
	width: $rover-height * (1.6 / 1.5);
	height: $rover-height;
	
	position: absolute;
	
	left: 0;
	right: 0;
	margin: 0 auto;
	bottom: 30%;
	
	z-index: 50;
	
	transform-origin: bottom;
	transform: scale(0.5);
}

.wheel-row {
	height: $rover-height * (0.25 / 1.5);
	width: 100%;
	
	display: flex;
	justify-content: space-between;
	
	position: absolute;
	bottom: 0;
	
	z-index: 10;
	
	&.rear {
		left: 0.75rem;
		bottom: 0.75rem;
		z-index: 5;
	}
}

.wheel {
	background: $rover-color-red;
	border: 0.25rem solid $rover-color;
	border-radius: 50%;
	box-shadow: 0.5rem -0.1rem 0 0 $tuna;
	
	width:  $rover-height * (0.25 / 1.5);
	height: $rover-height * (0.25 / 1.5);
	
	&::before {
		background-color: $rover-color;
		border-radius: 50%;
		box-shadow: 2px -1px 0 0 $tuna inset;
		width: 60%;
		height: 60%;
		
		top: 20%;
		left: 20%;
	}
	
	&::after {
		$size: 20%;
		background-color: $tuna;
		border: 3px solid $rover-color;
		box-shadow: 2px -1px 0 0 $tuna;
		border-radius: 50%;
		width: $size;
		height: $size;
		
		top: ((100 - $size) / 2) - 3;
		left: ((100 - $size) / 2) - 3;
	}
}

.body {
	background-image:  linear-gradient(
		to bottom,
		darken($rover-color-red,20),
		$rover-color-red,
	);
	border-top: 0.25rem solid darken($rover-color-red,30);
	border-right: 0.5rem solid lighten($rover-color-red,15);
	width: $rover-height * 0.6;
	height: $rover-height * 0.2;
	
	margin: 0 auto;
	
	position: absolute;
	bottom: $rover-height * 0.225;
	left: 0;
	right: 0;
	
	&::before {
		background: lighten($tuna,10);
		border-right: 0.5rem solid lighten($tuna,20);
		
		width: $rover-height * 0.4;
		height: $rover-height * 0.05;
		
		left: 0;
		right: 0;
		top: -($rover-height * 0.0575);
		
		margin: 0 auto;
	}
}

.panels {
	width: 120%;
	height: 1rem;
	
	background: darken($softpeach,15);
	border-top: 0.25rem solid desaturate($rover-color-red,15);
	border-right: 8rem solid lighten(desaturate($rover-color-red,15),15   );
	border-left: 8rem solid lighten(desaturate($rover-color-red,15),5);
	border-bottom: 0.25rem solid $tuna;
	
	position: absolute;
	
	bottom: 14rem;
	right: 0;
}

.chassis {
	width: 100%;
	height: 8rem;
	
	position: absolute;
	bottom: 2rem;
	
	z-index: 5;
	
	&.rear {
		z-index: 0;
		transform: translate(0.5rem,-0.5rem);
			
			svg {
					polyline {
					stroke: darken($softpeach,15);
					}
				}
	}
	
	svg {
		polyline {
			stroke: darken($softpeach,5);
			stroke-linejoin: round;
			stroke-width: 1rem;
			fill: none;
			
			&.darker {
				stroke: darken($softpeach,30);
				transform: translate(0.25rem,-0.1rem);
				z-index: -1;
			}
		}
		
		circle {
			fill: darken($softpeach,5);
			stroke: darken($softpeach,15);
			stroke-width: 0.25rem;
		}
	}
}

.camera-mount {
	background-image: linear-gradient(
	to right,
	darken($softpeach,25),
	$softpeach,
	lighten($softpeach,10)
	);
	border-top-right-radius: 0.75rem;
	border-top-left-radius: 0.75rem;
	
	box-shadow: 0 1px 3px 0 darken($softpeach,25) inset;
	
	height: $rover-height * 0.3;
	width: 1.5rem;
	
	position: absolute;
	
	bottom: $rover-height * 0.5;
	right: 9rem;
	
	&::before,
	&::after {
		background-image: linear-gradient(
		to right,
		darken($softpeach,25),
		$softpeach,
		lighten($softpeach,10)
		);
		border-top: 2px solid darken($softpeach,25);
		
		width: 2rem;
		left: -0.25rem;
	}
	
	&::before {
		height: 0.5rem;
		bottom: 0;
	}
	
	&::after {
		border-bottom: 1px solid darken($softpeach,25);
		height: 1rem;
		bottom: 3rem;
	}
}

.camera-lower {
		background-image: linear-gradient(
		to top,
		darken($softpeach,25),
		$softpeach,
		darken($softpeach,10)
		);
	width: 6rem;
	height: 1.5rem;
	
	border-top-right-radius: 0.75rem;
	border-bottom-right-radius: 0.75rem;
	box-shadow: 3px 0 0 0 darken($rover-color,15);
	
	top: -0.75rem;
	left: -2.5rem;
	
	position: absolute;
	
	z-index: -1;
	
	&::before {
		background: $rover-color;
		width: 1.5rem;
		height: 1.5rem;
		border-radius: 50%;
		box-shadow: 3px 0 0 0 darken($rover-color,15);
		left: -0.5rem;
	}
	&::after {
		background-image: linear-gradient(
		to top,
		darken($rover-color,15),
		$rover-color,
		lighten($rover-color,5)
		);
		border-right: 1px solid darken($rover-color,20);
		
		width: 1.25rem;
		height: 0.3rem;
		
		border-radius: 0.15rem;
		
		left: -0.9rem;
		top: 0.55rem;
	}
}

.camera-upper {
	background: darken($rover-color,15);
	border-left: 1rem solid $softpeach;
	border-right: 0.15rem solid $softpeach;
	border-bottom: 0.15rem solid darken($softpeach,10);
	width: 7rem;
	height: 1.75rem;
	
	position: absolute;
	left: -3.2rem;
	top: -2.5rem;
	
	&::before,
	&::after {
		background: lighten($tuna,15);
		border-radius: 50%;
		border: 3px solid lighten($tuna,5);
		box-shadow: -4px 0 0 0 $tuna;
		width: 0.75rem;
		height: 0.75rem;
		top: 0.2rem;
	}
	
	&::before {
		left: 0.4rem;
	}
	
	&::after {
		right: 0.5rem;
	}
}

.antenna {
	background-image: linear-gradient(
	to right,
	darken($rover-color,25),
	$rover-color,
	lighten($rover-color,10)
	);
	width: 0.5rem;
	height: 8rem;
	
	position: absolute;
	
	bottom: $rover-height * 0.5;
	left: 10rem;
	
	&::before,
	&::after {
		background-image: linear-gradient(
		to right,
		darken($rover-color,25),
		$rover-color,
		lighten($rover-color,10)
		);
		border-top: 1px solid darken($rover-color,20);
	}
	
	&::before {
		
		width: 1rem;
		height: 0.25rem;
		
		left: -0.25rem;
		bottom: 0;
	}
	
	&::after {
		border-bottom: 1px solid darken($rover-color,20);
		
		height: 0.25rem;
		width: 0.75rem;
		left: -0.125rem;
		
		top: 2px;
	}
}

.light {
	
	&.blink {
		animation: 2s light-flash linear infinite;
		
		&::before {
		animation: 2s light-glow linear infinite;
		}
	}
	background: $tuna;
	width: 1rem;
	height: 1rem;
	
	border-top-right-radius: 0.5rem;
	border-top-left-radius: 0.5rem;
	
	border-bottom: 0.25rem solid $rover-color;
	
	position: absolute;
	bottom: $rover-height * 0.5;
	left: 18rem;
	
	&::before {
		background: $reddamask;
		width: 100%;
		height: 100%;
		
		filter: blur(6px);
		
		opacity: 0;
		
		z-index: -1;
	}
}

@keyframes light-flash {
	25%,75% {
		background: $tuna;
	}
	50% {
		background: $reddamask;
	}
}

@keyframes light-glow {
	25%,75% {
		opacity: 0;
	}
	50% {
		opacity: 1;
	}
}
            
          
!
            
              // Night Sky

var canvas = document.getElementById('canvas'),
		ctx = canvas.getContext('2d');

canvas.width = window.innerWidth;
canvas.height = document.getElementById('sky').offsetHeight;

var stars = [],
		FPS = 0,
		x = canvas.width;

for (let i = 0; i < x; i++) {
  stars.push({
    x: Math.random() * canvas.width,
    y: Math.random() * canvas.height,
    radius: Math.random(),
    vx: Math.floor(Math.random() * 10) - 5,
    vy: Math.floor(Math.random() * 10) - 5
  });
}

// Draw the scene

function draw() {
  ctx.clearRect(0,0,canvas.width,canvas.height);
  
  ctx.globalCompositeOperation = "lighter";
  
  for (let i = 0, x = stars.length; i < x; i++) {
    let s = stars[i];
  
    ctx.fillStyle = "#EEE2E2";
    ctx.beginPath();
    ctx.arc(s.x, s.y, s.radius, 0, 2 * Math.PI);
    ctx.fill();
  }
}
  
draw();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console