Skip to content

Instantly share code, notes, and snippets.

View barrier-grid.py
import os
import cv2
import numpy as np
folder = "./cat/"
files = os.listdir(folder)
files.sort( )
dst = np.ones( (143,143), np.float )
for i, (f) in enumerate( files ):
img = cv2.imread(folder + f, cv2.IMREAD_UNCHANGED)
img = cv2.cvtColor( img, cv2.COLOR_BGR2GRAY )
@nicoptere
nicoptere / atlas.py
Last active October 21, 2021 07:32
atlas maker + rgb packer
View atlas.py
import os
import argparse
import cv2
import numpy as np
from tqdm import tqdm
from math import ceil, sqrt
def atlasFromFolder( name, src, dst, tile, packChannels, quality ):
if src[:-1] != "/":
@nicoptere
nicoptere / Instances.js
Last active February 24, 2021 14:44
create InstancedGeometries from GLTF
View Instances.js
import {
BufferAttribute,
Group,
InstancedBufferAttribute,
InstancedBufferGeometry,
Mesh,
MeshStandardMaterial,
Vector3,
} from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
View moebius 3D GLSL (for three.js)
/**
original code https://gist.github.com/Dan-Piker/f7d790b3967d41bff8b0291f4cf7bd9e
need to declare the following:
uniform vec3 origin;
uniform float p;
uniform float q;
uniform float t;
*/
@nicoptere
nicoptere / remove small paths in illustrator
Last active May 30, 2018 20:59
this will remove illustrator paths under a given length ( to clean up smaller paths basically )
View remove small paths in illustrator
#target illustrator
var document = app.activeDocument;
var maxLength = prompt ("maximum length of a path", 10, "destroy them with lasers!");
for (i=0 ; i< document.pathItems.length; i++)
{
var ipath = document.pathItems[i]
if( ipath.hidden == true )continue;
var l = 0;
for( var j = 0; j < ipath.pathPoints.length - 1; j++ ){
var p0 = ipath.pathPoints[j].anchor;
View affine transform
//from https://math.stackexchange.com/questions/296794/finding-the-transform-matrix-from-4-projected-points-with-javascript/339033#339033
// and http://jsfiddle.net/dFrHS/1/
function adj(m) { // Compute the adjugate of m
return [
m[4]*m[8]-m[5]*m[7], m[2]*m[7]-m[1]*m[8], m[1]*m[5]-m[2]*m[4],
m[5]*m[6]-m[3]*m[8], m[0]*m[8]-m[2]*m[6], m[2]*m[3]-m[0]*m[5],
m[3]*m[7]-m[4]*m[6], m[1]*m[6]-m[0]*m[7], m[0]*m[4]-m[1]*m[3]
];
}
@nicoptere
nicoptere / toOBJ
Created April 14, 2017 15:06
converts a THREE.geometry to OBJ
View toOBJ
var str = "# object mesh \n";
g.toIndexed();
var vs = g.getAttribute("position").array;
var ind = g.getIndex().array;
var precision = 6;
for( var i = 0 ; i < vs.length; i+=3 ){
@nicoptere
nicoptere / Object3D.js
Created July 5, 2016 09:33
object3d CSS
View Object3D.js
/**
* Created by nico on 19/02/14.
*/
var Object3d = function( node, position, rotation )
{
this.node = node;
this.parent = null;
View gist:abe6cabf590158c885ecce0768cee41c
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>postmortem</title>
<style>
html, body{
width:100%;
height:100%;
overflow: hidden;
@nicoptere
nicoptere / mixer
Created June 15, 2016 09:12
texture mixer
View mixer
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>MIXER</title>
<style>
head, body{
width:100%;
height:100%;
overflow: hidden;