This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Ported from the Python code of Mark Ransom | |
-- https://stackoverflow.com/a/40231268 | |
-- For more on the magic numbers, see | |
-- http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html | |
ColorConvert = {} | |
ColorConvert.__index = ColorConvert | |
setmetatable(ColorConvert, { | |
__call = function (cls, ...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local dlg = Dialog { title = "Alt Hotkeys" } | |
dlg:button { | |
id = "a", | |
text = "&ABC", | |
onclick = function() | |
app.alert("A") | |
end | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader modScalar( | |
float A = 0.0, | |
float B = 1.0, | |
output float Mod = 0.0) { | |
Mod = mod(A, B); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |