Reverse Engineering for Beginners

(avery) #1

CHAPTER 83. DEMOS CHAPTER 83. DEMOS


if iterations > max_iterations:
break
iterations++

return iterations

black-white


for each point on screen P:
if check_if_is_in_set (P) < max_iterations:
draw point


colored


for each point on screen P:
iterations = if check_if_is_in_set (P)
map iterations to color
draw color point


The integer version is where the operations on complex numbers are replaced with integer operations according to the rules
which were explained above.


Listing 83.4: For integer numbers

def check_if_is_in_set(X, Y):
X_start=X
Y_start=Y
iterations=0


while True:
if (X^2 + Y^2 > bounds):
break
new_X=X^2 - Y^2 + X_start
new_Y=2*X*Y + Y_start
if iterations > max_iterations:
break
iterations++

return iterations

black-white


for X = min_X to max_X:
for Y = min_Y to max_Y:
if check_if_is_in_set (X,Y) < max_iterations:
draw point at X, Y


colored


for X = min_X to max_X:
for Y = min_Y to max_Y:
iterations = if check_if_is_in_set (X,Y)
map iterations to color
draw color point at X,Y


Here is also a C# source which is present in the Wikipedia article^6 , but we’ll modify it so it will print the iteration numbers
instead of some symbol^7 :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Mnoj
{
class Program
{
static void Main(string[] args)
{
double realCoord, imagCoord;
double realTemp, imagTemp, realTemp2, arg;
int iterations;


(^6) wikipedia
(^7) Here is also the executable file:beginners.re

Free download pdf