Skip to content

Commit

Permalink
examples: add perlin noise
Browse files Browse the repository at this point in the history
  • Loading branch information
arrufat committed Oct 22, 2024
1 parent 18ba479 commit 32a3b10
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
3 changes: 2 additions & 1 deletion examples/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = buildModule(b, "face_alignment", target, optimize);
_ = buildModule(b, "colorspace", target, optimize);
_ = buildModule(b, "face_alignment", target, optimize);
_ = buildModule(b, "perlin", target, optimize);

const fmt_step = b.step("fmt", "Run zig fmt");
const fmt = b.addFmt(.{
Expand Down
1 change: 1 addition & 0 deletions examples/lib/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h2>Examples</h2>
<ul>
<li><a href="colorspace.html">Colorspace</a></li>
<li><a href="face-alignment.html">Face aligment</a></li>
<li><a href="perlin.html">Perlin noise</a></li>
</ul>
</main>
<script src="main.js"></script>
Expand Down
2 changes: 0 additions & 2 deletions examples/lib/main.js

This file was deleted.

10 changes: 4 additions & 6 deletions examples/lib/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
position: relative;
}

.grid-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-gap: 20px;
}

#form {
width: 300px;
margin: 10px;
Expand All @@ -30,6 +24,10 @@
top: 0px;
}

#canvas {
border: 1px solid black;
}

#video {
position: absolute;
}
Expand Down
5 changes: 2 additions & 3 deletions examples/src/js.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const gpa = std.heap.wasm_allocator;

pub const js = struct {
extern "js" fn log(ptr: [*]const u8, len: usize) void;
Expand Down Expand Up @@ -29,10 +28,10 @@ pub fn logFn(
}

export fn alloc(len: usize) [*]u8 {
const slice = gpa.alloc(u8, len) catch @panic("OOM");
const slice = std.heap.wasm_allocator.alloc(u8, len) catch @panic("OOM");
return slice.ptr;
}

export fn free(ptr: [*]const u8, len: usize) void {
gpa.free(ptr[0..len]);
std.heap.wasm_allocator.free(ptr[0..len]);
}

0 comments on commit 32a3b10

Please sign in to comment.