shithub: patch

ref: 28f0259d48be125dd16b74ae81d0a23dc430a08a
dir: /fplot-col/

View raw version
diff -r 2eab60542a43 sys/src/cmd/fplot.c
--- a/sys/src/cmd/fplot.c	Fri Nov 27 10:51:16 2020 +0100
+++ b/sys/src/cmd/fplot.c	Fri Nov 27 21:58:23 2020 +0100
@@ -119,7 +119,7 @@
 double ymin = -10, ymax = 10;
 double gymin, gymax;
 int icolors[] = {
-	DBlack,
+	0x777777FF,
 	0xCC0000FF,
 	0x00CC00FF,
 	0x0000CCFF,
@@ -475,7 +475,7 @@
 		lr = rectsubpt(lr, Pt(0, lr.min.y - ny));
 	}
 	if(rectinrect(lr, screen->r) && (lr.min.x > x || lr.max.x <= x)){
-		string(screen, lr.min, display->black, ZP, display->defaultfont, buf);
+		string(screen, lr.min, colors[0], ZP, display->defaultfont, buf);
 		return 1;
 	}
 	return 0;
@@ -497,7 +497,7 @@
 		lr = rectsubpt(lr, Pt(lr.min.x - nx, 0));
 	}
 	if(rectinrect(lr, screen->r) && (lr.min.y > y || lr.max.y <= y)){
-		string(screen, lr.min, display->black, ZP, display->defaultfont, buf);
+		string(screen, lr.min, colors[0], ZP, display->defaultfont, buf);
 		return 1;
 	}
 	return 0;
@@ -564,25 +564,25 @@
 		x = deconvx(&screen->r, 0);
 	else
 		x = screen->r.min.x+5;
-	line(screen, Pt(x, screen->r.min.y), Pt(x, screen->r.max.y), Endarrow, 0, 0, display->black, ZP);
+	line(screen, Pt(x, screen->r.min.y), Pt(x, screen->r.max.y), Endarrow, 0, 0, colors[0], ZP);
 	if(ymin < 0 && ymax > 0)
 		y = deconvy(&screen->r, 0);
 	else
 		y = screen->r.max.y-5;
-	line(screen, Pt(screen->r.min.x, y), Pt(screen->r.max.x, y), 0, Endarrow, 0, display->black, ZP);
+	line(screen, Pt(screen->r.min.x, y), Pt(screen->r.max.x, y), 0, Endarrow, 0, colors[0], ZP);
 	nx = ticks(xmin, xmax, &dx, &mx);
 	tickfmt(dx, mx, nx, fmt);
 	for(i = 0; i <= nx; i++){
 		p = deconvx(&screen->r, dx*i+mx);
 		if(xticklabel(fmt, dx*i+mx, p, x, y))
-			line(screen, Pt(p, y), Pt(p, y-5), 0, 0, 0, display->black, ZP);
+			line(screen, Pt(p, y), Pt(p, y-5), 0, 0, 0, colors[0], ZP);
 	}
 	ny = ticks(ymin, ymax, &dy, &my);
 	tickfmt(dy, my, ny, fmt);
 	for(i = 0; i <= ny; i++){
 		p = deconvy(&screen->r, dy*i+my);
 		if(yticklabel(fmt, dy*i+my, p, x, y))
-			line(screen, Pt(x, p), Pt(x+5, p), 0, 0, 0, display->black, ZP);
+			line(screen, Pt(x, p), Pt(x+5, p), 0, 0, 0, colors[0], ZP);
 	}
 }
 
@@ -630,7 +630,7 @@
 	xmax = xmax_;
 	ymin = ymin_;
 	ymax = ymax_;
-	draw(screen, screen->r, display->white, nil, ZP);
+	draw(screen, screen->r, display->black, nil, ZP);
 	drawgraphs();
 }
 
@@ -644,7 +644,7 @@
 	ymax = zoomst[nzoomst - 1].ymax;
 	zoomst = realloc(zoomst, sizeof(FRectangle) * --nzoomst);
 	if(zoomst == nil && nzoomst != 0) sysfatal("realloc: %r");
-	draw(screen, screen->r, display->white, nil, ZP);
+	draw(screen, screen->r, display->black, nil, ZP);
 	drawgraphs();
 }
 
@@ -759,7 +759,6 @@
 	parsefns(argc, argv);
 	if(cflag) {
 		imagedata = emalloc(picx * picy * 3);
-		memset(imagedata, 0xFF, picx * picy * 3);
 		print("%11s %11d %11d %11d %11d ", "r8g8b8", 0, 0, picx, picy);
 		r.min.x = r.min.y = 0;
 		r.max.x = picx;
@@ -776,6 +775,7 @@
 		picy = Dy(screen->r);
 		pixels = emalloc(picx * picy);
 		alloccolors();
+		draw(screen, screen->r, display->black, nil, ZP);
 		drawgraphs();
 		for(;;) {
 			switch(event(&e)) {
@@ -783,7 +783,7 @@
 				if((e.mouse.buttons & 1) != 0)
 					zoom();
 				if(((lbut|e.mouse.buttons) & 2) != 0){
-					draw(screen, screen->r, display->white, nil, ZP);
+					draw(screen, screen->r, display->black, nil, ZP);
 					drawgraphs();
 				}
 				if((e.mouse.buttons & 2) != 0)
@@ -802,7 +802,7 @@
 						zoomst[nzoomst++] = (FRectangle){xmin, xmax, ymin, ymax};
 						ymin = gymin-0.05*(gymax-gymin);
 						ymax = gymax+0.05*(gymax-gymin);
-						draw(screen, screen->r, display->white, nil, ZP);
+						draw(screen, screen->r, display->black, nil, ZP);
 						drawgraphs();
 					}
 					break;