wasm-canvas
canvas.h
Go to the documentation of this file.
1 
8 #ifndef CANVAS_H
9 #define CANVAS_H
10 
11 #include <emscripten.h>
12 #include <string.h>
13 #include <stdlib.h>
14 
17 
55 {
61  struct
62  {
63  HTMLCanvasElement *canvas;
64  char contextType[19];
65  char *font;
66  char *textAlign;
67  char *fillStyle;
68  char *strokeStyle;
69  char *lineCap;
70  char *lineJoin;
71  char *globalCompositeOperation;
72  } private;
73  void (*clearRect)(CanvasRenderingContext2D *this, double x, double y, double width, double height);
74  void (*fillRect)(CanvasRenderingContext2D *this, double x, double y, double width, double height);
75  void (*strokeRect)(CanvasRenderingContext2D *this, double x, double y, double width, double height);
77  void (*fillText)(CanvasRenderingContext2D *this, char *text, double x, double y, double maxWidth);
79  void (*strokeText)(CanvasRenderingContext2D *this, char *text, double x, double y, double maxWidth);
80  /* TextMetrics *(*measureText)(CanvasRenderingContext2D *this, char *text); */ // that's a whole can of worms
81  void (*setLineWidth)(CanvasRenderingContext2D *this, double value);
82  double (*getLineWidth)(CanvasRenderingContext2D *this);
83  void (*setLineCap)(CanvasRenderingContext2D *this, char *type);
84  char *(*getLineCap)(CanvasRenderingContext2D *this);
85  void (*setLineJoin)(CanvasRenderingContext2D *this, char *type);
86  char *(*getLineJoin)(CanvasRenderingContext2D *this);
87  char *(*getFont)(CanvasRenderingContext2D *this);
88  void (*setFont)(CanvasRenderingContext2D *this, char *value);
89  void (*setTextAlign)(CanvasRenderingContext2D *this, char *value);
90  char *(*getTextAlign)(CanvasRenderingContext2D *this);
91  void (*setFillStyle)(CanvasRenderingContext2D *this, char *value);
92  char *(*getFillStyle)(CanvasRenderingContext2D *this);
93  void (*setStrokeStyle)(CanvasRenderingContext2D *this, char *value);
94  char *(*getStrokeStyle)(CanvasRenderingContext2D *this);
95  void (*beginPath)(CanvasRenderingContext2D *this);
96  void (*closePath)(CanvasRenderingContext2D *this);
97  void (*moveTo)(CanvasRenderingContext2D *this, double x, double y);
98  void (*lineTo)(CanvasRenderingContext2D *this, double x, double y);
99  void (*bezierCurveTo)(CanvasRenderingContext2D *this, double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
100  void (*quadraticCurveTo)(CanvasRenderingContext2D *this, double cpx, double cpy, double x, double y);
101  void (*arc)(CanvasRenderingContext2D *this, double x, double y, double radius, double startAngle, double endAngle);
102  void (*arcTo)(CanvasRenderingContext2D *this, double x1, double y1, double x2, double y2, double radius);
103  void (*ellipse)(CanvasRenderingContext2D *this, double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle);
104  void (*rect)(CanvasRenderingContext2D *this, double x, double y, double width, double height);
105  void (*fill)(CanvasRenderingContext2D *this);
106  void (*stroke)(CanvasRenderingContext2D *this);
107  void (*clip)(CanvasRenderingContext2D *this);
108  int (*isPointInPath)(CanvasRenderingContext2D *this, double x, double y);
109  int (*isPointInStroke)(CanvasRenderingContext2D *this, double x, double y);
110  void (*rotate)(CanvasRenderingContext2D *this, double angle);
111  void (*scale)(CanvasRenderingContext2D *this, double x, double y);
112  void (*translate)(CanvasRenderingContext2D *this, double x, double y);
113  void (*transform)(CanvasRenderingContext2D *this, double a, double b, double c, double d, double e, double f);
114  void (*setTransform)(CanvasRenderingContext2D *this, double a, double b, double c, double d, double e, double f);
115  void (*resetTransform)(CanvasRenderingContext2D *this);
116  void (*setGlobalAlpha)(CanvasRenderingContext2D *this, double value);
117  double (*getGlobalAlpha)(CanvasRenderingContext2D *this);
118  void (*setGlobalCompositeOperation)(CanvasRenderingContext2D *this, char *value);
119  char *(*getGlobalCompositeOperation)(CanvasRenderingContext2D *this);
120  void (*save)(CanvasRenderingContext2D *this);
121  void (*restore)(CanvasRenderingContext2D *this);
122  HTMLCanvasElement *(*getCanvas)(CanvasRenderingContext2D *this);
123 };
124 
148 {
149  struct
150  {
152  char *id;
153  } private;
158  int (*getHeight)(HTMLCanvasElement *this);
163  int (*getWidth)(HTMLCanvasElement *this);
168  void (*setHeight)(HTMLCanvasElement *this, int height);
173  void (*setWidth)(HTMLCanvasElement *this, int width);
180  CanvasRenderingContext2D *(*getContext)(HTMLCanvasElement *this, char *contextType);
181 };
182 
206 HTMLCanvasElement *createCanvas(char *name);
207 
213 void freeCanvas(HTMLCanvasElement *canvas);
214 
215 #endif
void(* fillText)(CanvasRenderingContext2D *this, char *text, double x, double y, double maxWidth)
Definition: canvas.h:77
HTMLCanvasElement * createCanvas(char *name)
Definition: canvas.c:49
Definition: canvas.h:54
void freeCanvas(HTMLCanvasElement *canvas)
Definition: canvas.c:535
Definition: canvas.h:147
void(* strokeText)(CanvasRenderingContext2D *this, char *text, double x, double y, double maxWidth)
Definition: canvas.h:79