0

I'm new to Javascript. I'm working on a script to display a Julia set using canvas using the external distance estimation method

This is the code I'm using to color it:

    distance_estimation: function(distance, max_distance, iteration, max_iteration){
        var color;
        if(distance > max_distance || iteration == max_iteration){
            color = "rgb(0,0,0)";
        }
        else{
            color = "rgb(255,255,255)";
        }
        return color;
    }

This is what I expected it to look like: http://upload.wikimedia.org/wikipedia/commons/3/3a/Demj.jpg

This is what I got: https://i.stack.imgur.com/2elYx.png

What can I do to make the script generate a picture similar to the one in the link?

Adam Zuckerman
  • 1,633
  • 1
  • 14
  • 20

1 Answers1

0

Difficult to tell without more code, but...

It looks like you're drawing with paths and one or more of those paths are missing beginPath.

context.beginPath() must be used to start a new path or else the previous path commands will be re-executed. This results in overdrawing previous lines and results in "blackened" drawings.

markE
  • 102,905
  • 11
  • 164
  • 176