Skip to content

Commit

Permalink
devlog
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Sep 17, 2024
1 parent 02c5e90 commit 0ce7f38
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions content/en-US/devlog/index.smd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,40 @@
// an example of a correct date string.
---

# [2024-09-16]($section.id('2024-09-16'))

Author: Andrew Kelley

I've been porting stb_truetype.h to Zig on the side. Check out this snippet:

```c
{
float sum = 0;
for (i=0; i < result->w; ++i) {
float k;
int m;
sum += scanline2[i];
k = scanline[i] + sum;
k = (float) STBTT_fabs(k)*255 + 0.5f;
m = (int) k;
if (m > 255) m = 255;
result->pixels[j*result->stride + i] = (unsigned char) m;
}
}
```
⬇️
```zig
{
var sum: f32 = 0;
for (scanline, scanline2, result.pixels[j*result.stride..][0..result.w]) |s, s2, *p| {
sum += s2;
p.* = @min(@abs(s + sum)*255 + 0.5, 255);
}
}
```

Ahh, much better.

# [Zig tokenizer updated to use labeled switch statements]($section.id('2024-09-11'))

Author: Andrew Kelley
Expand Down

0 comments on commit 0ce7f38

Please sign in to comment.