summaryrefslogtreecommitdiff
path: root/src/sim/sim.h
blob: 16189a1e83583ca05007cd202a2c7175da520dd3 (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
/** \file
 * \brief Simulation Base Driver
 *
 * See Copyright Notice in cd.h
 */

#ifndef __SIM_H
#define __SIM_H


struct _cdSimulation
{
  cdTT_Text* tt_text; /* TrueType Font Simulation using FreeType library */

  int antialias;

  cdCanvas *canvas;

  const char* font_map[100];
  int font_map_n;

  /* horizontal line draw functions */
  void (*SolidLine)(cdCanvas* canvas, int xmin, int y, int xmax);
  void (*PatternLine)(cdCanvas* canvas, int xmin, int xmax, int y, int pw, const long *pattern);
  void (*StippleLine)(cdCanvas* canvas, int xmin, int xmax, int y, int pw, const unsigned char *stipple);
  void (*HatchLine)(cdCanvas* canvas, int xmin, int xmax, int y, unsigned char hatch);
};

#define simRotateHatchN(_x,_n) ((_x) = ((_x) << (_n)) | ((_x) >> (8-(_n))))

void simFillDrawAAPixel(cdCanvas *canvas, int x, int y, unsigned short alpha_weigth);
void simFillHorizLine(cdSimulation* simulation, int xmin, int y, int xmax);
void simGetPenPos(cdCanvas* canvas, int x, int y, const char* s, FT_Matrix *matrix, FT_Vector *pen);
int simIsPointInPolyWind(cdPoint* poly, int n, int x, int y);

/* list of non-horizontal line segments */
typedef struct _simLineSegment
{
  int x1, y1;   /* always y1 < y2 */
  int x2, y2;   /* (x2,y2) is not included in the segment to avoid duplicated intersections */
  int x;        /* incremental x from x2 to x1 */
  int DeltaX, DeltaY, XDir;
  unsigned short ErrorInc, ErrorAcc;
} simLineSegment;

void simAddSegment(simLineSegment* segment, int x1, int y1, int x2, int y2, int *y_max, int *y_min);
int simSegmentInc(simLineSegment* segment, cdCanvas* canvas, int y);

void simPolyFill(cdSimulation* simulation, cdPoint* poly, int n);
void simLineThin(cdCanvas* canvas, int x1, int y1, int x2, int y2);
void simLineThick(cdCanvas* canvas, int x1, int y1, int x2, int y2);
void simfLineThin(cdCanvas* canvas, double x1, double y1, double x2, double y2, int *last_xi_a, int *last_yi_a, int *last_xi_b, int *last_yi_b);
extern int simLineStyleNoReset;

int simCalcEllipseNumSegments(cdCanvas* canvas, int xc, int yc, int width, int height);

#endif