crystal_ray_tracer
Version, currently master branch1 version
- master branchlatestJul 10, 2021
github.com/drhuffman12/crystal_ray_tracer
Based on code from jzakiya, for adding to https://github.com/edin/raytracer
Installation
# Add this to your shard.yml
dependencies:
crystal_ray_tracer:
github: drhuffman12/crystal_ray_tracer
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Authors
- Jabari Zakiya (jzakiya), Daniel Huffman
Dependencies
Runtime Dependencies
- faker*github: askn/faker
- hardware*github: crystal-community/hardware
- stumpy_png*github: stumpycr/stumpy_png
README
crystal_ray_tracer
This is an example shard for use in generating ray-traced images.
It is a Reorganization of jzakiya's ported-from-Ruby code into a Crystal-lang 'shard' library.
It is for sake of use in https://github.com/edin/raytracer under the crystal sub-folder; also for re-use elsewhere, as this is a shard.
See also forum posts:
- https://forum.crystal-lang.org/t/doing-raytracer-in-crystal/3029
- https://forum.crystal-lang.org/t/doing-raytracer-in-crystal/3029/54?u=drhuffman12
Installation
-
Add the dependency to your
shard.yml:dependencies: crystal_ray_tracer: github: your-github-user/crystal_ray_tracer -
Run
shards install
Usage
require "crystal_ray_tracer"
TODO: Write usage instructions here
Examples
Build the example app
For a quick, simpler build to test this out, enter:
crystal build examples/jzakiya.cr -o examples/jzakiya
For a longer, more advanced build to get better performance, enter:
crystal build examples/jzakiya.cr -o examples/jzakiya --release
This doesn't (at least not yet) make much use of multi-threaded fibers, but you can enable it like this:
crystal build examples/jzakiya.cr -o examples/jzakiya --release -Dpreview_mt
The compiled file will be in the examples folder or what ever you specify after the -o option.
Run the example app
examples/jzakiya
This will generate the example image (based on the image used for https://github.com/edin/raytracer) called crystal-raytracer.png in (for now) the root of the repo.
This file will look like:

(Using the --release flag makes it generate the image significantly faster than the un-optimized compilation. On my system including '--release', makes it run about 12 times faster.)
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/your-github-user/crystal_ray_tracer/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Jabari Zakiya - Ported and optimized Ruby code to Crystal-lang (See: https://forum.crystal-lang.org/t/doing-raytracer-in-crystal/3029)
- Daniel Huffman - Repo creator and maintainer - Helping reorganize Crystal code
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Jul 10, 2021
- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/drhuffman12/crystal_ray_tracer
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1