Sha256: c4947fee02df787780e846918bada343371b59822812448af29e32070284c917

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

# Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
# All contributing project authors may be found in the NOTICE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

def run
  puts "Rendering"
  y = -39.0
  while y <= 39.0
    puts
    x = -39.0
    while x <= 39.0
      i = iterate(x/40.0,y/40.0)
      if (i == 0)
        print "*"
      else
        print " "
      end
      x += 1
    end
    y += 1
  end
  puts
end

def iterate(x:double,y:double)
  cr = y-0.5
  ci = x
  zi = 0.0
  zr = 0.0
  i = 0

  result = 0
  while true
    i += 1
    temp = zr * zi
    zr2 = zr * zr
    zi2 = zi * zi
    zr = zr2 - zi2 + cr
    zi = temp + temp + ci
    if (zi2 + zr2 > 16)
      result = i
      break
    end
    if (i > 1000)
      result = 0
      break
    end
  end

  result
end

i = 0
while i < 10
  start = System.currentTimeMillis
  run
  puts "Time: #{(System.currentTimeMillis - start) / 1000.0}"
  i += 1
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mirah-0.1.4-java examples/fractal.mirah
mirah-0.1.3-java examples/fractal.mirah
mirah-0.1.2-java examples/fractal.mirah
mirah-0.1.1-java examples/fractal.mirah
mirah-0.1.0-java examples/fractal.mirah
mirah-0.1.0.pre-java examples/fractal.mirah
mirah-0.0.12-java examples/fractal.mirah
mirah-0.0.11-java examples/fractal.mirah
mirah-0.0.10-java examples/fractal.mirah
mirah-0.0.9-java examples/fractal.mirah
mirah-0.0.8-java examples/fractal.mirah
mirah-0.0.7-java examples/fractal.mirah
mirah-0.0.6-java examples/fractal.mirah
mirah-0.0.5-java examples/fractal.mirah