Assembly Language for Beginners

(Jeff_L) #1

8.13. DEMOS


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 8.25: 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^51 , but we’ll modify it so it will print the
iteration numbers instead of some symbol^52 :


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;
for (imagCoord = 1.2; imagCoord >= -1.2; imagCoord -= 0.05)
{
for (realCoord = -0.6; realCoord <= 1.77; realCoord += 0.03)
{
iterations = 0;
realTemp = realCoord;
imagTemp = imagCoord;
arg = (realCoord realCoord) + (imagCoord imagCoord);
while ((arg < 2*2) && (iterations < 40))
{


(^51) wikipedia
(^52) Here is also the executable file:beginners.re

Free download pdf