You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-18Lines changed: 34 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,28 @@
1
1
# wefx
2
2
3
-
Wefx is a simple graphics library for drawing using C, WASM ([Web Assembly][webassembly]), and an [HTML canvas][htmlcanvas]. It aims to serve a similar purpose as [gfx][gfx], but provide an introduction to using C and WASM. Wefx is meant to be a teaching / learning tool for C and graphics. Wefx is not using OpenGL /
4
-
WebGL or anything like that. It is doing very basic pixel manipulation and
5
-
has very simple functions to draw pixels and lines.
3
+
Wefx is a simple graphics library for drawing using C11, WASM
4
+
([Web Assembly][webassembly]), and an [HTML canvas][htmlcanvas].
5
+
It aims to serve a similar purpose as [gfx][gfx], but provide an introduction
6
+
to using C and WASM. Wefx is meant to be a teaching / learning tool for C and
7
+
graphics. Wefx is not using OpenGL / WebGL or anything like that. It is doing
8
+
very basic pixel manipulation and has very simple functions to draw pixels and
9
+
lines.
6
10
7
-
You can also [download the documentation](https://raw.githubusercontent.com/robrohan/wefx/main/docs/manual.pdf)
If you are using Ubuntu, you can run `make init` to install the correct version of clang and tools. If you are on another system, you will have to install `clang` yourself.
18
+
If you are using Ubuntu, you can run `make init` to install the correct
19
+
version of clang and tools. If you are on another system, you will have to
20
+
install `clang` yourself.
14
21
15
-
Once installed, `make build` should compile `examples/example0.c` into WASM (if there are no errors). If successful, and if you have python installed, you can run `make serve` to start a simple HTTP server and browse to http://localhost:8000 to view wasm output.
22
+
Once installed, `make build` should compile `examples/example0.c` into WASM
23
+
(if there are no errors). If successful, and if you have python installed, you
24
+
can run `make serve` to start a simple HTTP server and browse to
25
+
http://localhost:8000 to view wasm output.
16
26
17
27
## Using The Project
18
28
@@ -41,8 +51,9 @@ You'll need the following programs installed:
41
51
- make (optional - MacOS and Linux)
42
52
- (optional) python3
43
53
44
-
On MacOS or Linux these tools should be available already, or easily
45
-
installed with homebrew (`brew install`), or Apt (`apt install`), or your local package manager.
54
+
On MacOS or Linux these tools should be available already, or easily installed
55
+
with homebrew (`brew install`), or Apt (`apt install`), or your local package
56
+
manager.
46
57
47
58
### Compiling
48
59
@@ -71,7 +82,9 @@ directly from your file system (this is just how wasm loading works).
71
82
If you try to open the `index.html` file directly you will get an error
72
83
like:
73
84
74
-
> Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///xxxxx/build/wefx.wasm. (Reason: CORS request not http).
85
+
> Cross-Origin Request Blocked: The Same Origin Policy disallows reading the
86
+
> remote resource at file:///xxxxx/build/wefx.wasm. (Reason: CORS request not
87
+
> http).
75
88
76
89
A basic http server comes with python3, and the make file will run that
77
90
server if you run:
@@ -91,9 +104,9 @@ to see the compiled code.
91
104
---
92
105
93
106
If you already have a favorite server (for example I use
94
-
[busboy](https://github.com/robrohan/busboy)), you can use that serve to
95
-
serve the `build` directory instead, and then run the `make build` command
96
-
to replace the wasm file as you play around.
107
+
[busboy](https://github.com/robrohan/busboy)), you can use that serve to serve
108
+
the `build` directory instead, and then run the `make build` command to replace
109
+
the wasm file as you play around.
97
110
98
111
For example in one shell I run:
99
112
@@ -112,15 +125,16 @@ And then simply refresh the browser to see changes.
112
125
### Writing Code
113
126
114
127
If just teaching / learning about graphics, you'll only need to edit the
115
-
[./examples/example0.c](./examples/example0.c) file. There are two entry
116
-
points into that file:
128
+
[./examples/example0.c](./examples/example0.c) file. There are two entry points
129
+
into that file:
117
130
118
131
| Function | Usage |
119
132
| ---------| -----|
120
133
|init()| Called once at the start of the app|
121
134
|main_loop(time)| Called every frame with time being time since app start|
122
135
123
-
You can also add your own entry files in the examples directory, and then pass them to the build script using the _MAIN_ variable. For example:
136
+
You can also add your own entry files in the examples directory, and then pass
137
+
them to the build script using the _MAIN_ variable. For example:
124
138
125
139
```{sh}
126
140
make build MAIN=examples/example1.c
@@ -132,7 +146,8 @@ This will build the WASM file using `example1.c` as the entry point.
132
146
133
147
#### API
134
148
135
-
The API calls try to emulate [gfx][gfx] as much as possible. Here are a few currently supported functions (see the documentation for a full reference):
149
+
The API calls try to emulate [gfx][gfx] as much as possible. Here are a few
150
+
currently supported functions (see the documentation for a full reference):
136
151
137
152
| Function | Does |
138
153
| ---------| -----|
@@ -145,7 +160,8 @@ The API calls try to emulate [gfx][gfx] as much as possible. Here are a few curr
145
160
146
161
#### Coordinate System
147
162
148
-
The coordinate system in newer versions has changed to reflect most other drawing styles. The system works thusly:
163
+
The coordinate system in newer versions has changed to reflect most other
0 commit comments