Skip to content

Instantly share code, notes, and snippets.

@steveruizok
steveruizok / getSegmentRoundedRectangleIntersection.ts
Created July 24, 2020 12:43
Get the points where a line segment intersects a rectangle with rounded corners.
/**
* Get the intersection points between a line segment and a rectangle with rounded corners.
* @param x0 The x-axis coordinate of the segment's starting point.
* @param y0 The y-axis coordinate of ththe segment's ending point.
* @param x1 The delta-x of the ray.
* @param y1 The delta-y of the ray.
* @param x The x-axis coordinate of the rectangle.
* @param y The y-axis coordinate of the rectangle.
* @param w The width of the rectangle.
@armollica
armollica / .block
Last active November 8, 2021 21:38
Proj4/WKT + D3
height: 600
@Vestride
Vestride / encoding-video.md
Last active June 5, 2024 14:38
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@Joncom
Joncom / gist:e8e8d18ebe7fe55c3894
Last active September 11, 2021 00:29
Check if two line segments intersect
// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) {
var s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x;
s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x;
s2_y = p3_y - p2_y;
var s, t;
@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};