Skip to content

Instantly share code, notes, and snippets.

View lonekorean's full-sized avatar

Will Boyd lonekorean

View GitHub Profile
@lonekorean
lonekorean / file.js
Created June 10, 2018 22:34
Getting viewport dimensions
let viewportWidth = document.documentElement.clientWidth;
let viewportHeight = document.documentElement.clientHeight;
@lonekorean
lonekorean / file.css
Created June 10, 2018 21:46
Background canvas CSS
canvas {
position: fixed;
z-index: -1;
top: 0;
left: 0;
}
@lonekorean
lonekorean / file.html
Last active June 10, 2018 21:44
Background canvas HTML
<canvas id="bg"></canvas>
@lonekorean
lonekorean / file.js
Created March 5, 2018 22:02
Solid color paint worklet
class SolidColorPainter {
static get inputArguments() {
return ['<color>'];
}
paint(ctx, size, props, args) {
ctx.fillStyle = args[0].toString();
ctx.fillRect(0, 0, size.width, size.height);
}
}
@lonekorean
lonekorean / file.css
Created March 5, 2018 22:01
Using an input argument
.solid {
background-image: paint(solid-color, #c0eb75);
/* other styles as needed... */
}
@lonekorean
lonekorean / file.js
Created March 4, 2018 19:42
Check for Properties and Values API support
if ('registerProperty' in CSS) {
// good to go!
}
@lonekorean
lonekorean / file.js
Last active March 4, 2018 19:42
Check for Typed OM support
if ('CSSUnitValue' in window) {
// good to go!
}
@lonekorean
lonekorean / file.css
Created March 3, 2018 20:20
CSS to animate polka dot fade
.polka-dot {
--dot-spacing: 20px;
--dot-fade-offset: 0%;
--dot-color: #fc466b;
background: paint(polka-dot-fade);
/* other styles as needed... */
}
.polka-dot:hover, .polka-dot:focus {
@lonekorean
lonekorean / file.css
Created March 3, 2018 20:17
CSS that uses the polka dot fade paint worklet
.polka-dot {
--dot-spacing: 20px;
--dot-fade-offset: 0%;
--dot-color: #40e0d0;
background: paint(polka-dot-fade);
/* other styles as needed... */
}
@lonekorean
lonekorean / file.js
Created March 3, 2018 20:15
Paint worklet for polka dot fade
class PolkaDotFadePainter {
static get inputProperties() {
return ['--dot-spacing', '--dot-fade-offset', '--dot-color'];
}
paint(ctx, size, props) {
let spacing = props.get('--dot-spacing').value;
let fadeOffset = props.get('--dot-fade-offset').value;
let color = props.get('--dot-color').toString();