Skip to content

Instantly share code, notes, and snippets.

View companje's full-sized avatar

Rick Companje companje

View GitHub Profile
@companje
companje / perspective-sphere.pde
Created February 28, 2024 22:40
Load WorldMap .OBJ with adjusted perspective
View perspective-sphere.pde
PShape globe;
float w,h,eyeZ;
void setup() {
fullScreen(P3D);
w = width;
h = height;
eyeZ = 1460; // = h/2 + offset
@companje
companje / 0.Sphere.pde
Created February 27, 2024 06:55
Sphere
View 0.Sphere.pde
Quaternion q = new Quaternion(1, 0, 0, 0);
ArrayList<PVector> dots = new ArrayList();
PImage tex;
PShape sphere;
PShader shader;
void setup() {
size(900, 900, P3D);
tex = loadImage("earth.jpg");
sphere = createShape(SPHERE, height/2);
@companje
companje / 0.Sphere-with-red-dots-reacting-to-mouse.pde
Last active February 24, 2024 15:47
Sphere ArcBall rotate with Quaternion, also with inverse rotation
View 0.Sphere-with-red-dots-reacting-to-mouse.pde
Quaternion q = new Quaternion(1, 0, 0, 0);
PShape globe;
PImage tex;
ArrayList<PVector> points = new ArrayList();
float radius;
void setup() {
size(800, 800, P3D);
tex = loadImage("earth.jpg");
radius = height/2;
@companje
companje / Zoom-Shader-Processing.pde
Last active February 20, 2024 09:39
Zoom shader for sphere
View Zoom-Shader-Processing.pde
PShader shader;
PImage tex;
PShape sphere;
PVector lensCenter = new PVector(0,0,1);
float zoom = 2;
void setup() {
size(1169, 1169, P3D);
tex = loadImage("1539.jpg");
sphere = createShape(SPHERE, height/2);
@companje
companje / Load WorldMap .OBJ with adjusted perspective (Basic Perspective Sphere).pde
Created February 17, 2024 08:21
Load WorldMap .OBJ with adjusted perspective (Basic Perspective Sphere)
View Load WorldMap .OBJ with adjusted perspective (Basic Perspective Sphere).pde
PShape globe;
float w,h,eyeZ;
void setup() {
fullScreen(P3D);
w = width;
h = height;
eyeZ = 1460; // = h/2 + offset
@companje
companje / merge-csv.py
Created February 13, 2024 08:51
Merge 2 CSV's
View merge-csv.py
# ik heb twee CSV's met de volgende headers:
#
# 1) org_row,filename,straatnaam,afbeelding,oude straatnaam
# 2) "uuid","name","width","height","link"
# Ik wil graag een nieuwe CSV met de onderstaande velden waarbij de sleutelkolommen 'filename' en 'name' gebruikt kunnen worden om te matchen
# 2) "uuid","name","width","height","link","straatnaam"
#
# response from ChatGPT 3.5. In 1x goed!
@companje
companje / crop.py
Last active February 13, 2024 08:19
Mac OCR for crops
View crop.py
#!/usr/bin/env python3
import shutil,os,cv2,sys,glob
from tqdm import tqdm
from PIL import Image
from pathlib import Path
from joblib import Parallel, delayed
crop_width = 200
crop_height = 100
output_scale = .33
@companje
companje / Export_SMF_messages.py
Created December 3, 2023 21:31
SMF SimpleMachines Forum Export / Backup to JSON
View Export_SMF_messages.py
import mysql.connector, json
def get_column_names(db_name, table_name):
query = f"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{db_name}' AND TABLE_NAME = '{table_name}'"
cursor.execute(query)
return [row["COLUMN_NAME"] for row in cursor]
db_name = 'your_db'
db_user = 'root'
db_pass = ''
@companje
companje / TwoZoomableWindows.pde
Last active October 27, 2023 20:32
Multiple Zoomable Windows in Processing
View TwoZoomableWindows.pde
ZoomWindow win1, win2;
void setup() {
size(100, 100);
win1 = new ZoomWindow(dataPath("saenredam.jpg"), 0, 0, displayWidth/2, displayHeight);
win2 = new ZoomWindow(dataPath("zadelstraat.jpg"), displayWidth/2, 0, displayWidth/2, displayHeight);
}
void draw() {
}
@companje
companje / _ NormalMap.pde
Last active September 7, 2023 17:19
NormalMap Shader on Textured Sphere in Processing / Processing.org
View _ NormalMap.pde
PShader shader;
PImage colormap, normalmap;
PShape shape;
void setup() {
size(1169, 1169, P3D);
shader = loadShader("frag-shader.glsl", "vert-shader.glsl");
colormap = loadImage("colormaps/mercury.jpg");
normalmap = loadImage("normalmaps/mercury.jpg");