summaryrefslogtreecommitdiff
path: root/test/mandelbrot.h
blob: ccae9db115e8be5efca4c4264af65a5dd947775d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Mandelbrot set header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2023 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file.  If this
// file is missing or damaged, see the license at:
//
//     https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
//     https://www.fltk.org/bugs.php
//

#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Input.H>

#define USE_COLORS 0 // change to 1 to start in color mode

class Drawing_Area : public Fl_Box {
  void draw() FL_OVERRIDE;
public:
  uchar *buffer;
  int use_colors;
  int W,H;
  int dx, dy, dw, dh; // drawing box offsets
  int nextline;
  int drawn;
  int julia;
  int iterations;
  int brightness;
  double jX, jY;
  double X,Y,scale;
  int sx, sy, sw, sh; // selection box
  void erase_box();
  int handle(int) FL_OVERRIDE;
  void resize(int,int,int,int) FL_OVERRIDE;
  void new_display();
  void new_buffer();
  enum {
    MAX_BRIGHTNESS = 16,
    DEFAULT_BRIGHTNESS = 16,
    DEFAULT_BRIGHTNESS_COLOR = 8,
    MAX_ITERATIONS = 14,
    DEFAULT_ITERATIONS = 7
  };
  Drawing_Area(int x,int y,int w,int h) : Fl_Box(x,y,w,h) {
    buffer = 0;
    use_colors = USE_COLORS;
    W = w;
    H = h;
    dx = dy = 0; // NOTE: as the box type is set *after* the constructor
    dw = dh = 0; //       the actual offsets are determined in draw()
    nextline = 0;
    drawn = 0;
    julia = 0;
    X = Y = 0;
    scale = 4.0;
    iterations = 1<<DEFAULT_ITERATIONS;
    brightness = use_colors ? DEFAULT_BRIGHTNESS_COLOR : DEFAULT_BRIGHTNESS;
    sx = sy = sw = sh = 0;
  }
  int idle();
};