Skip to content

Instantly share code, notes, and snippets.

@behreajj
behreajj / undocMethods.lua
Created August 7, 2021 19:17
Undocumented Methods
local x = Point(1, 2)
for key, value in pairs(getmetatable(x)) do
print(key, value)
end
print(x + Point(3, 4))
print(x * 5)
@behreajj
behreajj / altHotkeys.lua
Created July 24, 2021 21:09
Alt Hotkeys
local dlg = Dialog { title = "Alt Hotkeys" }
dlg:button {
id = "a",
text = "&ABC",
onclick = function()
app.alert("A")
end
}
@behreajj
behreajj / circ_grease_pencil.py
Last active May 26, 2021 01:53
Bramble Circle in Grease Pencil
import bpy
import math
from mathutils import Vector
grease_data = bpy.data.grease_pencils.new("Stroke")
grease_layers = grease_data.layers
active_layer = grease_layers.new("Layer")
grease_frames = active_layer.frames
active_frame = grease_frames.new(
bpy.context.scene.frame_current,
@behreajj
behreajj / constraint_setup.py
Created May 25, 2021 13:25
Constraint Setup
import bpy
from mathutils import Vector
cam_data = bpy.data.cameras.new("Camera")
cam_data.type = 'ORTHO'
cam_data.ortho_scale = 4.0
cam_obj = bpy.data.objects.new(cam_data.name, cam_data)
cam_obj.location = (10.0, 10.0, 5.0)
@behreajj
behreajj / closureExample.c
Last active May 23, 2021 17:40
Closure Example
shader closureExample(
normal Normal = N,
float DiffuseRoughness = 0.01,
color DiffuseColor = 0.0,
float GlassRoughness = 0.125,
float GlassIor = 1.45,
float GlassReflectivity = 0.125,
color GlassColor = 1.0,
@behreajj
behreajj / pingPong.c
Last active May 23, 2021 01:36
Zig Zag, Bounce, Oscillate
float zigzag(float t) {
float a = t * 0.5;
float b = a - floor(a);
return 1.0 - abs(b + b - 1.0);
}
float oscillate(float t) {
return 0.5 + 0.5 * sin(M_PI * (t - 0.5));
}
@behreajj
behreajj / floorMod.c
Created May 22, 2021 20:41
Floor Mod
shader modScalar(
float A = 0.0,
float B = 1.0,
output float Mod = 0.0) {
Mod = mod(A, B);
}
@behreajj
behreajj / fractScalar.c
Last active May 23, 2021 01:35
Fraction
shader fractScalar(
float A = 0.0,
output float Fract = 0.0,
output int Trunc = 0.0,
output float Floor = 1.0) {
Trunc = trunc(A);
Fract = A - Trunc;
Floor = 1.0 - Fract;
@behreajj
behreajj / mixLab.c
Last active May 22, 2021 12:31
Mix Lab
shader mixLab(
color A = 0.0,
color B = 1.0,
float T = 0.5,
color LB = 0.0,
color UB = 1.0,
output color Color = 0.5) {
color aLinear = sRgbTolRgb(A);
@behreajj
behreajj / labxyz.c
Last active May 22, 2021 16:29
CIE XYZ CIE LAB Conversion
vector xyzToLab(vector xyz) {
float vx = xyz[0] / 0.95047;
float vy = xyz[1];
float vz = xyz[2] / 1.08883;
vx = select(7.787 * vx + 16.0 / 116.0, pow(vx, 1.0 / 3.0), vx > 0.008856);
vy = select(7.787 * vy + 16.0 / 116.0, pow(vy, 1.0 / 3.0), vy > 0.008856);
vz = select(7.787 * vz + 16.0 / 116.0, pow(vz, 1.0 / 3.0), vz > 0.008856);
return vector(