| // Taken From: | |
| // https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment | |
| function sqr (x) { | |
| return x * x; | |
| } | |
| function dist2 (v, w) { | |
| return sqr(v[0] - w[0]) + sqr(v[1] - w[1]); | |
| } |
| <template> | |
| <div class="inline-block" v-html="require('icon-' + this.icon + '.svg')"></div> | |
| </template> | |
| <style module> | |
| .svg { | |
| fill: currentColor; | |
| height: 1em; | |
| margin-top: -4px; | |
| vertical-align: middle; |
| <!doctype html> | |
| <meta charset="utf-8"> | |
| <title>Benchmark</title> | |
| <body></body> | |
| <style>html, body, #map { height: 100%; margin: 0; } </style> | |
| <div id="map"></div> | |
| <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.0/mapbox-gl.js'></script> | |
| <!-- <script src="mapbox-gl.js"></script> --> |
I tried to run https://dev.to/andraconnect/augmented-reality-in-10-lines-of-html and https://github.com/jeromeetienne/ar.js from my own computer and got the following error:
Can't access user media :()
This error comes from:
https://github.com/jeromeetienne/jsartoolkit-experiments/blob/master/basic.html Line 100: navigator.getUserMedia
| const glslify = require('glslify'); | |
| const path = require('path'); | |
| const assign = require('object-assign'); | |
| const defined = require('defined'); | |
| // This is the original source, we will copy + paste it for our own GLSL | |
| // const vertexShader = THREE.ShaderChunk.meshphysical_vert; | |
| // const fragmentShader = THREE.ShaderChunk.meshphysical_frag; | |
| // Our custom shaders |
| // SAT collision check and resolution | |
| // Public domain | |
| // Usage example: | |
| // if (testCollision(obb1, obb2, mtv)) { // obb1, obb2 - sf::RectangleShape, mtv - sf::Vector2f | |
| // obb1.move(mtv); | |
| // } | |
| static const float NORMAL_TOLERANCE = 0.0001f; | |
| using RectVertexArray = std::array<sf::Vector2f, 4>; |
ℹ️ There is a newer alternative project that does similar things and more, check it out at https://github.com/stevenilsen123/mac-keyboard-behavior-in-windows
Make Windows PC's shortcut act like macOS (Mac OS X) (using AutoHotkey (ahk) script)
With this AutoHotKey script, you can use most macOS style shortcuts (eg, cmd+c, cmd+v, ...) on Windows with a standard PC keyboard.
Tweening between one and many polygons with an approach that's faster and more robust than this Voronoi jigsaw attempt.
This approach uses earcut and some artisanal TopoJSON to triangulate the polygon and successively merge the triangles into the desired number of pieces, and then adds/rewinds points for smoother transitions (see this demo for a better look at what's happening behind the scenes).
See also: Triangulation morphing, Jigsaw morphing, Smoother polygon transitions
| // The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae | |
| // Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16. | |
| // See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details | |
| float4 SampleTextureCatmullRom(in Texture2D<float4> tex, in SamplerState linearSampler, in float2 uv, in float2 texSize) | |
| { | |
| // We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding | |
| // down the sample location to get the exact center of our "starting" texel. The starting texel will be at | |
| // location [1, 1] in the grid, where [0, 0] is the top left corner. | |
| float2 samplePos = uv * texSize; |