From 83c26e19bac20cf6a9e3456cdec7d5c52ebf3fb8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 28 Oct 2014 01:46:37 -0400 Subject: don't stop iterating if we don't find any pixels on the first try this is kind of indicating that i might actually need to switch up my iteration strategy if i'm going to get things to work properly as i zoom in, though... --- src/renderer.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer.jl b/src/renderer.jl index 1842dbb..66dc943 100644 --- a/src/renderer.jl +++ b/src/renderer.jl @@ -42,16 +42,19 @@ fractal(fc::FractalCanvas, make_c, step) = fractal(fc.c, make_c, step) function fractal(canvas::Canvas, make_c::Function, step::Function, should_wait=!isinteractive(), range=(-2.0, -2.0, 4.0, 4.0)) fc = FractalCanvas(canvas, range, make_c, step) - i = 0 - while true + saw_some_pixels = false + for i in 1:1000 FractalExplorer.step(fc.f) - new_pixels = (abs(fc.f.z) .> 2) & (fc.image .== HSV(0, 0, 0)) + diverging_pixels = (abs(fc.f.z) .> 2) + new_pixels = diverging_pixels & (fc.image .== HSV(0, 0, 0)) fc.image[new_pixels] = HSV(i * 4, 1, 1) - i = i + 1 redraw(fc) - if length(find(new_pixels)) <= 1 + if saw_some_pixels && length(find(new_pixels)) <= 1 break end + if length(find(diverging_pixels)) > 0 + saw_some_pixels = true + end end if should_wait -- cgit v1.2.3