Skip to content

Instantly share code, notes, and snippets.

@joonas-yoon
Last active May 9, 2023 08:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joonas-yoon/038f37a11942167c695fd8c149197038 to your computer and use it in GitHub Desktop.
Save joonas-yoon/038f37a11942167c695fd8c149197038 to your computer and use it in GitHub Desktop.
f(x) = [r, g, b] ; from (1, 0, 0) to (0, 1, 0) to (0, 0, 1) for 0 <= x <= 1
def vec3(x):
return [
max(0.0, min(1.0 - 2.0*x, 1.0)),
abs(1.0 - abs(2.0*x - 1.0)),
max(0.0, min(2.0*x - 1.0, 1.0))
]
for i in range(100+1):
x = i/100
print(x, vec3(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment