Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Acepie authored May 1, 2024
1 parent 7cd892e commit 229d942
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,33 @@ An example ball spawner

## Using the library

Add the library to your project by running the following command
To use this library you will need to build your gleam project and include it in an html file. The html file must import p5js as a module before the generated javascript file. The easiest way to do this is to load the p5js library from a CDN.

```html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ball Spawner</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script type="module">
import { main } from "./ball_spawner.js";
main();
</script>
</head>
<body></body>
</html>
```

Once you have an html file with p5js and your output module setup, add the library to your project by running the following command

```bash
gleam add p5js_gleam
```

Then add a call to the `start_sketch` function in your main function.
Then add a call to the `create_sketch` function in your main function.

```gleam
import p5js_gleam.{type P5}
Expand All @@ -52,27 +72,7 @@ pub fn main() {
}
```

Afterwards you will need to build your project and include it in an html file. The html file must import p5js as a module before the generated javascript file. The easiest way to do this is to load the p5js library from a CDN.

```html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ball Spawner</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script type="module">
import { main } from "./ball_spawner.js";
main();
</script>
</head>
<body></body>
</html>
```

To see the library in action you can serve one of the examples in the `examples` directory.
To see the library in action you can download and serve one of the examples in the `examples` directory.

## Generating FFI Bindings

Expand Down

0 comments on commit 229d942

Please sign in to comment.