Skip to content

Instantly share code, notes, and snippets.

View Sphinxxxx's full-sized avatar

Andreas Borgen Sphinxxxx

View GitHub Profile
@Sphinxxxx
Sphinxxxx / index.html
Created December 12, 2017 18:10
SVG Coffee stain
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="220" viewBox="0 0 250,220">
<defs>
<!-- https://css-tricks.com/squigglevision-in-css-and-svg/ -->
<!-- https://codepen.io/mullany/pen/MyWxxX/ -->
<filter id="squiggler">
<feTurbulence baseFrequency="0.05" numOctaves="3" />
<feDisplacementMap in="SourceGraphic" scale="12" />
</filter>
</defs>
@Sphinxxxx
Sphinxxxx / init-three.js
Last active March 26, 2018 18:23
Create a three.js scene with a camera, controls and lighting.
function initThree(config) {
config = config || {};
const container = config.container,
addLights = (config.addLights !== false),
addControls = (config.addControls !== false);
const renderer = new THREE.WebGLRenderer();
(container || document.body).appendChild(renderer.domElement);
// create a scene
@Sphinxxxx
Sphinxxxx / draw-on-an-image.markdown
Last active December 6, 2018 20:08
Draw on an image
@Sphinxxxx
Sphinxxxx / index.html
Last active May 28, 2018 23:49
Warp image on canvas
<h2>Drag the round handles to warp the image</h2>
<img id="i" />
<div id="drag-wrapper">
<canvas id="c"></canvas>
<div class="drag-handle" data-corner="0"></div>
<div class="drag-handle" data-corner="1"></div>
<div class="drag-handle" data-corner="2"></div>
<div class="drag-handle" data-corner="3"></div>
@Sphinxxxx
Sphinxxxx / index.pug
Created May 1, 2018 14:08
Superellipse (include squircle)
main#app
h1 Superellipse
a(href="https://en.wikipedia.org/wiki/Superellipse")
img(src="https://wikimedia.org/api/rest_v1/media/math/render/svg/2b21da32fe407ff5714620b26c50343d21afed15")
section#settings.inputs(@input="recalc")
label
span a
input(type="range" v-model.number="config.a" min="10" max="400")
output {{config.a}}
@Sphinxxxx
Sphinxxxx / index.html
Last active June 19, 2018 17:20
Shape subdivision
<h2>Shape subdivision</h2>
<section id="app">
<label>
<span>Dividers</span>
<input type="number" v-model.number="svg.dividers" min="1">
</label>
<svg :width="svg.size[0]" :height="svg.size[1]">
<corner v-for="c in svg.shape.corners" :c="c"></corner>
<bezier v-for="b in getBeziers()" :wrapper="b" />
@Sphinxxxx
Sphinxxxx / index.html
Last active June 24, 2018 21:50
<meter> element settings
<main>
<h1>&lt;meter&gt; element settings</h1>
<h3><a target="_blank" href="https://stackoverflow.com/questions/44939391/what-exactly-do-the-low-high-and-optimum-attributes-do-in-the-meter-element">What exactly do the low, high and optimum attributes do?</a></h3>
<label>Thresholds (<code>low</code>/<code>high</code>) & <code>optimum</code>:</label>
<div class="slider" id="sl1">
<div class="thumb" data-icon="▿" data-point="down" data-prop="low"></div>
<div class="thumb" data-icon="▿" data-point="down" data-prop="high"></div>
<div class="thumb" data-icon="★" data-point="down" data-prop="optimum" style="color:orange;"></div>
</div>
@Sphinxxxx
Sphinxxxx / index.html
Created July 26, 2018 23:39
Yet another Mandelbrot fractal
<canvas></canvas>