效果图,如果想要更改颜色,可以在代码最后一行system处修改。
#include <stdio.h>
#include <math.h>
const int max_iterations = 128;
const float stop_threshold = 0.01f;
const float grad_step = 0.01f;
const float clip_far = 10.0f;
const float PI = 3.14159265359f;
const float PI2 = 6.28318530718f;
const float DEG_TO_RAD = 3.14159265359f / 180.0f;//只能定义常量
typedef struct { float x, y; } vec2;
typedef struct { float x, y, z; } vec3;
typedef struct { float m[9]; } mat3;
const vec3 light_pos = { 20.0f, 50.0f, 20.0f };
float min(float a, float b) { return a < b ? a : b; }
float max(float a, float b) { return a > b ? a : b; }
float clamp(float f, float a, float b) { return max(min(f, b), a); }
vec2 make2(float x, float y) { vec2 r = { x, y }; return r; }
vec2 add2(vec2 a, vec2 b) { vec2 r