This file contains 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
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 |
This file contains 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
Red/System [ | |
] | |
vector3!: alias struct! [ | |
x [float!] | |
y [float!] | |
z [float!] | |
] | |
vec3-Mfloat: func [ |
This file contains 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
Red/System [ | |
] | |
vector3!: alias struct! [ | |
x [float!] | |
y [float!] | |
z [float!] | |
] | |
vec3-add: func [ |
This file contains 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
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) | |
] |
This file contains 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
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 |
This file contains 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
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]]]] | |