Created
October 27, 2019 13:44
-
-
Save tonetheman/6a6728d41463f2e37ab0fd297b25617a to your computer and use it in GitHub Desktop.
first program in raytracing in a weekend in racket
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
#lang racket | |
(define nx 200) | |
(define ny 100) | |
(display (string-append "P3\n" | |
(number->string nx) " " | |
(number->string ny) "\n255\n")) | |
(for ([j (in-range (- ny 1) 0 -1)]) | |
(for ([i (in-range 0 (- nx 1))]) | |
(let ([r (/ i nx)] | |
[g (/ j ny)] | |
[b 0.2]) | |
(let ([ir (exact-round (* 255.99 r))] | |
[ig (exact-round (* 255.99 g))] | |
[ib (exact-round (* 255.99 b))]) | |
(display (string-append (number->string ir) | |
" " (number->string ig) | |
" " (number->string ib) "\n")) | |
) ;; end of inner let | |
) ;; end of let first let | |
) ;; end of inner for | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment