Introductory text to programming based around building a fractal generator. It introduces basic concepts such as variables, data types, looping, decision making and basic programming strategies while working towards drawing a Mandelbrot fractal to the screen.
This is the first out of two volumes. The first volume primes readers by exposing them to basic theory and code. The reader is not expected to do any coding while reading this book, as that activity is reserved for the second volume.
Author(s): Bjørn I.F. Westerheim
Series: Volume 1: Theory
Edition: Draft
Publisher: Self
Year: 2021
Language: English
Tags: introduction tutorial programming fractals fun Mandelbrot
1. THE BACKGROUND 2
1.1. INTRODUCTION 2
1.1.1. Fast and furious 3
1.1.2. Writing code 3
1.1.3. Programming languages 4
1.1.4. Compiling code 6
1.2. MEMORY 8
1.2.1. SLOW MEMORY 8
1.2.2. FAST MEMORY 9
1.2.3. ACCESSING MEMORY 10
1.2.4. SUMMARY 12
2. BUILDING BLOCKS 14
2.1. COMMENTS 15
2.2. THE DATA TYPE 16
2.2.1. Integers (int) 17
2.2.2. The decimal (double) 17
2.2.3. The Boolean (bool) 18
2.2.4. The object 18
2.2.5. The string (string) 18
2.2.6. The nothing value 19
2.2.7. The symbols 20
2.3. THE VARIABLE 21
2.3.1. Assigning a value 22
2.3.2. The math operators 23
2.3.3. Casting: Forcing a datatype 28
2.4. COLLECTIONS 33
2.4.2. Introducing List<> 34
2.4.3. Invoking List<> 35
2.4.4. Sneak peak at functions 38
2.4.5. Accessing collection data 40
2.4.6. Multi-dimensional lists 43
2.4.7. The array datatype 45
2.5. SUMMARY 47
3. BETTER CODE 50
3.1. CODE COMPLEXITY 50
3.2. COMMENTS, PART DEUX 51
3.3. VARIABLE NAMING 54
3.4. INTERMEDIARY VARIABLES 55
3.5. THE FUNCTION 57
3.5.1. Function arguments 58
3.5.2. Returning values 60
3.5.3. Splitting up code 61
3.5.4. The black box 70
3.6. SUMMARY 71
4. WORKING WITH DATA 74
4.1. MAKING CHOICES 74
4.1.1. The condition 74
4.1.2. The if-else construct 75
4.2. REPEATING CODE 78
4.2.1. Introducing the loop 78
4.2.2. The while-loop 79
4.2.3. The for-loop 82
4.2.4. Looping through collections 85
4.2.5. The foreach loop 94
4.3. REUSING CODE 97
4.3.1. Functions 97
4.3.2. Libraries 99
4.3.3. Language Framework 101
4.4. SUMMARY 102
4.4.1. Summarizing the building blocks 102
4.4.2. Things we have not covered 104
5. BUILDING CODE 110
5.1. THE CANVAS 110
5.1.1. The Pixel 110
5.1.2. The Pixel Color 112
5.1.3. The Screen Buffer 114
5.2. CREATING IMAGES 116
5.2.1. Filling the screen 117
5.2.2. Generating pictures 121
5.3. THE MANDELBROT FRACTAL 130
5.3.1. The base formula 130
5.3.2. Partial 2-Color Mandelbrot 135
5.3.3. The full 2-Color Mandelbrot 143
5.3.4. Fractal, V3: monochromatic 160
5.3.5. Fractal, V3: full color 165
5.3.6. Some more examples 168
5.4. CONCLUSION 176
5.4.1. Onwards to part 2 177