commit f1ad0a3d06dd0b45cc7ae31fea913ba2d7eb42e4
parent 2578bf3ce0ff67bef9712aed45b924d3acb1c7c9
Author: William Casarin <jb55@jb55.com>
Date:   Fri,  3 Aug 2018 16:10:11 -0700
nice ball
Diffstat:
| M | main.c |  |  | 6 | +++--- | 
| M | render.c |  |  | 48 | +++++++++++++++++++++++++++++++++++------------- | 
2 files changed, 38 insertions(+), 16 deletions(-)
diff --git a/main.c b/main.c
@@ -46,7 +46,7 @@ int main()
 
 	struct node test_nodes[] = { {
 		.alias = "@jb55",
-		.color = { { 255, 0, 0, 0 } },
+		.color = { { 1.0, 0, 0, 1.0 } },
 	} };
 
 	ln.nodes = test_nodes;
@@ -126,8 +126,8 @@ int main()
 		glViewport(0, 0, fbWidth, fbHeight);
 		if (premult)
 			glClearColor(0, 0, 0, 0);
-		else
-			glClearColor(0.3f, 0.3f, 0.32f, 1.0f);
+		else // base16-onedark bg color ;)
+			glClearColor(0x28 / 255.0, 0x2c / 255.0, 0x34 / 255.0, 1.0f);
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
 			GL_STENCIL_BUFFER_BIT);
 
diff --git a/render.c b/render.c
@@ -5,28 +5,50 @@
 
 void draw_node(NVGcontext *vg, struct node *node)
 {
-	const float r = 50.0;
-	const float pos = 100.0;
+	const float r = 20.0;
+	const float pos = 500.0;
+
+	/* const float h = r; */
+	/* const float w = r; */
+	/* const float x = pos; */
+	/* const float y = pos; */
+	/* const float kr = (int)(h * 0.35f); */
+	/* const float cy = y + (int)(h * 0.5f); */
 
-	const float h = r;
-	const float w = r;
-	const float x = pos;
-	const float y = pos;
-	const float kr = (int)(h * 25.0f);
-	const float cy = y + (int)(h * 5.0f);
 
 	NVGpaint bg;
 
 	nvgSave(vg);
+	nvgTranslate(vg, pos, pos);
+
+	NVGcolor node_color =
+		nvgRGBAf(node->color.r, node->color.g, node->color.b,
+			 node->color.a);
 
-	bg = nvgRadialGradient(vg, x + (int)(pos * w), cy + 1, kr - 3, kr + 3,
-			       nvgRGBA(0, 0, 0, 64), nvgRGBA(0, 0, 0, 0));
+	NVGcolor blend =
+		nvgRGBAf(0, 0, 0, 0.5);
+
+	const float light = 2.0f;
+	bg = nvgRadialGradient(vg, -light, -light, 0, r+2.0, node_color, blend);
 	nvgBeginPath(vg);
-	nvgCircle(vg, pos, pos, r);
-	nvgPathWinding(vg, NVG_HOLE);
+	nvgCircle(vg, 0, 0, r);
+	/* nvgPathWinding(vg, NVG_HOLE); */
+
+	nvgStrokeWidth(vg, 3.0f);
+	nvgStrokeColor(vg, nvgRGBf(0.1, 0.1, 0.1));
+	/* nvgStroke(vg); */
+
 	nvgFillPaint(vg, bg);
 	nvgFill(vg);
-	nvgText(vg, x + r / 2.0, y + r + 5.0, node->alias, NULL);
+
+
+	nvgFontSize(vg, 18.0f);
+	nvgFontFace(vg, "sans");
+	nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_TOP);
+	/* nvgTextMetrics(vg, NULL, NULL, &lineh); */
+	nvgFillColor(vg, node_color);
+	nvgText(vg, -r, r, node->alias, NULL);
+
 	nvgRestore(vg);
 }