Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mandelbrot set javascript

const MAX_ITERATION = 80
function mandelbrot(c) {
    let z = { x: 0, y: 0 }, n = 0, p, d;
    do {
        p = {
            x: Math.pow(z.x, 2) - Math.pow(z.y, 2),
            y: 2 * z.x * z.y
        }
        z = {
            x: p.x + c.x,
            y: p.y + c.y
        }
        d = Math.sqrt(Math.pow(z.x, 2) + Math.pow(z.y, 2))
        n += 1
    } while (d <= 2 && n < MAX_ITERATION)
    return [n, d <= 2]
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery loop each tr in table grepper 
Javascript :: how to make 1st letter capital in ejs 
Javascript :: jquery if attribute 
Javascript :: get meta tag value from url javascript 
Javascript :: video play on page load 
Javascript :: urlencoded json express 
Javascript :: set value input date javascript 
Javascript :: // Write a function that takes two strings (a and b) as arguments // If a contains b, append b to the beginning of a // If not, append it to the end // Return the concatenation 
Javascript :: javascript check if string ends with 
Javascript :: datalist example 
Javascript :: why my bootstrap classes is not working on onclick event in react 
Javascript :: Add Tailwind CSS to Svelte 
Javascript :: easy import reactjs 
Javascript :: how to disable mouse right click in html page 
Javascript :: jquery on enter click 
Javascript :: javascript scroll down 
Javascript :: usehistory example 
Javascript :: js how to hide an image 
Javascript :: cordova capacitor document viewer fail 
Javascript :: javascript foreach 
Javascript :: when was react invented 
Javascript :: random choice js array 
Javascript :: react native button 
Javascript :: javascript shuffle array 
Javascript :: convert csv to json python using pandas 
Javascript :: express messages 
Javascript :: angular 10 get unique values from array of objects 
Javascript :: sticky operations in javascript 
Javascript :: id of other schema type mongoose 
Javascript :: react-native-paper resize switch resize 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =