Fun fact!
Linum’s logo is defined by the following double inequality:
And it can be rendered using the C code and command below:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <math.h>
#define SIZE 4096
double map(double val) {
return 2 * (val / (SIZE - 1)) - 1;
}
uint8_t lerp(double c, double t) {
return UCHAR_MAX * ((1 - t) + t * c);
}
uint32_t color(double t) {
uint32_t r, g, b;
t = sqrt(t);
r = lerp(0.25, t);
g = lerp(0.50, t);
b = lerp(0.75, t);
return (b << 24) | (g << 16) | (r << 8) | UCHAR_MAX;
}
int main(void) {
FILE *file = fopen("out.raw", "wb");
size_t size = 4 * SIZE * SIZE;
uint32_t *buffer = malloc(size);
double x, y, t, r;
int i;
if (file == NULL)
return EXIT_FAILURE;
for (size_t row = 0; row < SIZE; row++) {
for (size_t col = 0; col < SIZE; col++) {
x = map(col);
y = map(row);
t = atan2(y, x);
r = sqrt(x * x + y * y);
i = SIZE * row + col;
if (r >= 0.25 * (1 - fabs(cos(2.5 * t))) &&
r <= pow(fabs(cos(2.5 * t)), 0.125))
buffer[i] = color(r);
else buffer[i] = 0;
}
}
fwrite(buffer, 4, size, file);
fclose(file);
return EXIT_SUCCESS;
}
ffmpeg -pix_fmt argb -s 4096x4096 -i out.raw -vframes 1 out.png