0.0
No commit activity in last 3 years
No release in over 3 years
A ruby library for creating 2D cantor sets.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
>= 0
 Project Readme

cantor_carpets

Install

gem install cantor_carpets

Usage

Each fractal (called a Carpet) is determined by a seed and a depth. The seed is a 2D array that determines which squares are removed, and the depth determines the resolution of the image. The resulting image is a PNG.

seed = Array2D.new(3, 3)

seed.state = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]
carpet = Carpet.new(seed, 6)
carpet.write_image('sierpenski.png')

carpet

seed.state = [[1, 0, 1], [0, 0, 0], [1, 0, 1]]
carpet = Carpet.new(seed, 6)
carpet.write_image('dust.png')

dust

seed.state = [[0, 1, 0], [1, 1, 1], [0, 1, 0]]
carpet = Carpet.new(seed, 6)
carpet.write_image('cross.png')

cross