Skip to content

Instantly share code, notes, and snippets.

Twitter abuses all media file uploads, each type in its own way. If we want to upload a good looking animation loop from some low-color, high-detail generative art, we have to game their system's mechanisms.

  • don't upload a video file, they will re-encode it into absolute 💩

  • create a GIF, which they will auto-convert into a video file 😱

  • The frames of the GIF will be resized to an even-sized width using an extremely naive algorithm. Your GIF should be an even size (1000, 2000,

@mattatz
mattatz / Matrix.hlsl
Last active April 3, 2024 01:37
Matrix operations for HLSL
#ifndef __MATRIX_INCLUDED__
#define __MATRIX_INCLUDED__
#define IDENTITY_MATRIX float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
float4x4 inverse(float4x4 m) {
float n11 = m[0][0], n12 = m[1][0], n13 = m[2][0], n14 = m[3][0];
float n21 = m[0][1], n22 = m[1][1], n23 = m[2][1], n24 = m[3][1];
float n31 = m[0][2], n32 = m[1][2], n33 = m[2][2], n34 = m[3][2];
float n41 = m[0][3], n42 = m[1][3], n43 = m[2][3], n44 = m[3][3];
@radiatoryang
radiatoryang / ForceDirectedGraph.cs
Created May 30, 2013 23:20
method for doing force directed graph stuff with NGenerics + Unity... to make it 3D, just change Vector2's to Vector3's
IEnumerator ForceDirectGraph<T>( Graph<T> graph, Dictionary<T, Vector3> graphPositions ) {
// settings
float attractToCenter = 15f;
float repulsion = 10f;
float spacing = 0.1f;
float stiffness = 100f;
float damping = 0.9f;
// initialize velocities and positions
Dictionary<Vertex<T>, Vector2> velocity = new Dictionary<Vertex<T>, Vector2>();