Skip to content

Instantly share code, notes, and snippets.

Red [
Title: "Conway's Game of Life"
Needs: 'View
]
grid: collect [repeat i 10 [keep/only collect [repeat j 10 [keep random true]]]]
scratchgrid: collect [repeat i 10 [keep/only collect [repeat j 10 [keep false]]]]
Red [
Title: "Conway's Game of Life"
Needs: 'View
]
system/view/auto-sync?: no
grid: collect [repeat i 50 [keep/only collect [repeat j 50 [keep random true]]]]
scratchgrid: collect [repeat i 50 [keep/only collect [repeat j 50 [keep false]]]]
a: copy grid/1
b: copy grid/50
Red[
Title: "Raytracer"
Needs: 'View
Notes: "Simple raytracer based on 'Ray Tracing in One Weekend' by Peter Shirley"
]
vec3_dot: function [a[vector!] b[vector!]] [
reduce (a/1 * b/1) + (a/2 * b/2) + (a/3 * b/3)
]
Red/System [
]
vector3!: alias struct! [
x [float!]
y [float!]
z [float!]
]
vec3-add: func [
Red/System [
]
vector3!: alias struct! [
x [float!]
y [float!]
z [float!]
]
vec3-Mfloat: func [
Red/System [
Title: "Raytracer"
Notes: "Simple raytracer based on 'Ray Tracing in One Weekend' by Peter Shirley"
Usage: raytracerRS > imagename.ppm
]
#include %../red/runtime/random.reds
_random/init
_random/srand 123