summaryrefslogtreecommitdiffstats
path: root/BMPGraphing.h
blob: 4f1397203bb8733fa228ac5eaa5fd4ac5938945d (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*============================================================================
  BMPGraphing, a library for graphing.
  Copyright (C) 2005-2014 by Zack T Smith.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  The author may be reached at veritas@comcast.net.
 *===========================================================================*/

#ifndef _SUPERSIMPLEGRAPHING_H
#define _SUPERSIMPLEGRAPHING_H

#include <stdbool.h>

#define SSG_RELEASE "0.2"

#define XVALUE_MIN (15)
#define XVALUE_MAX (28)

enum {
	DATUM_X=0,
	DATUM_Y=1,
	DATUM_COLOR=2,
};

typedef long Coordinate;
typedef long long Value;

enum {
	MODE_X_AXIS_LINEAR = 0,
	MODE_X_AXIS_LOG2 = 1,
};

//---------------
// Graphing data.
//
typedef struct {
	BMP *image;
	char *title;

	unsigned char x_axis_mode;

	Coordinate width;
	Coordinate height;
	Coordinate left_margin;
	Coordinate margin;
	Coordinate last_x;
	Coordinate last_y;
	Coordinate x_span;
	Coordinate y_span;
	Coordinate legend_y;

	RGB fg;
#define MAX_GRAPH_DATA 50000
	Value data [MAX_GRAPH_DATA];
	int data_index;
#define DASHED 0x1000000 // dashed line flag

	Value max_y;
	Value min_y;
	Value min_x;
	Value max_x;
} BMPGraph;

extern void BMPGraphing_set_title (BMPGraph*, const char *);
extern void BMPGraphing_draw_labels_log2 (BMPGraph*);
extern BMPGraph *BMPGraphing_new (int w, int h, int x_axis_mode);
extern void BMPGraphing_new_line (BMPGraph *, char *str, RGB color);
extern void BMPGraphing_add_point (BMPGraph *, Value x, Value y);
extern void BMPGraphing_plot_log2 (BMPGraph *, Value x, Value y);
extern void BMPGraphing_plot_linear (BMPGraph *, Value x, Value y, Value max_amt);
extern void BMPGraphing_make (BMPGraph*);
extern BMP *BMPGraphing_get_graph (BMPGraph*);
extern void BMPGraphing_destroy (BMPGraph*);

#endif
OpenPOWER on IntegriCloud