--- /dev/null
+#include "color.h"
+#include "opt.h"
+
+Color color(float r, float g, float b)
+{
+ return opt.srgb ? Color(r, g, b) : linear_to_srgb(Color(r, g, b));
+}
+
+Color linear_to_srgb(const Color &c)
+{
+ const float inv_gamma = 1.0f / 2.2f;
+ return Color(pow(c.x, inv_gamma), pow(c.y, inv_gamma), pow(c.z, inv_gamma));
+}
+
+Color srgb_to_linear(const Color &c)
+{
+ const float gamma = 2.2f;
+ return Color(pow(c.x, gamma), pow(c.y, gamma), pow(c.z, gamma));
+}