Class: GemWithExtensionExample::PlotFractal

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_with_extension_example/base.rb

Constant Summary collapse

PRETTY_PLOT =
false
MAX_ITERATION_COUNT =
10000
DIVERGE_LIMIT =
4.0
DIVERGE_LIMIT_SQUARED =
DIVERGE_LIMIT * DIVERGE_LIMIT
CLASSIC_JULIA_SET =
Complex(-1.0,-0.25)
MAP_SET =
" ยท "

Class Method Summary collapse

Class Method Details

.julia(grid) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/gem_with_extension_example/base.rb', line 54

def self.julia(grid)
  (0...grid.height).each do |y|
    (0...grid.width).each do |x|
      z = grid[x,y]
      i = infinity_check_ruby(MAX_ITERATION_COUNT, CLASSIC_JULIA_SET, z)
      print get_render_character(i)
    end
    puts ""
  end
end

.julia_C(grid) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/gem_with_extension_example/base.rb', line 64

def self.julia_C(grid)
  (0...grid.height).each do |y|
    (0...grid.width).each do |x|
      z = grid[x,y]
      count = infinity_check_c(MAX_ITERATION_COUNT, CLASSIC_JULIA_SET.real, CLASSIC_JULIA_SET.imaginary, z.real, z.imaginary)
      print get_render_character(count)
    end
    puts ""
  end
end

.mandelbrot(grid) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/gem_with_extension_example/base.rb', line 32

def self.mandelbrot(grid)
  (0...grid.height).each do |y|
    (0...grid.width).each do |x|
      z = grid[x,y]
      count = infinity_check_ruby(MAX_ITERATION_COUNT, z, z)
      print get_render_character(count)
    end
    puts ""
  end
end

.mandelbrot_C(grid) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gem_with_extension_example/base.rb', line 42

def self.mandelbrot_C(grid)
  (0...grid.height).each do |y|
    (0...grid.width).each do |x|
      z = grid[x,y]
      i = z.imaginary
      r = z.real
      count = infinity_check_c(MAX_ITERATION_COUNT, r, i, r, i)
      print get_render_character(count)
    end
    puts ""
  end
end