summaryrefslogtreecommitdiff
path: root/sys/src/cmd/plot/libplot
diff options
context:
space:
mode:
authoran2qzavok <an2qzavok@gmail.com>2022-10-22 16:23:51 +0000
committerOri Bernstein <ori@eigenstate.org>2022-10-22 16:23:51 +0000
commit585365f5bbffae93eac3f1a4ba476aa0cab3f95d (patch)
tree8d268b5edb458d654283dd03158919119fc7072a /sys/src/cmd/plot/libplot
parentdfee08d50df674cd76f74320bc9c8bc6a4a95f1e (diff)
plot: fix disc and circle operations
Discs and circles were drawn on screen directly and later erased by offscreen buffer. This change puts them in line with other operations, which draw to offscreen first and to screen when necessary
Diffstat (limited to 'sys/src/cmd/plot/libplot')
-rw-r--r--sys/src/cmd/plot/libplot/circ.c2
-rw-r--r--sys/src/cmd/plot/libplot/disk.c2
-rw-r--r--sys/src/cmd/plot/libplot/machdep.c23
-rw-r--r--sys/src/cmd/plot/libplot/mplot.h2
4 files changed, 27 insertions, 2 deletions
diff --git a/sys/src/cmd/plot/libplot/circ.c b/sys/src/cmd/plot/libplot/circ.c
index 53337117c..3f2c6eb15 100644
--- a/sys/src/cmd/plot/libplot/circ.c
+++ b/sys/src/cmd/plot/libplot/circ.c
@@ -8,5 +8,5 @@ void circ(double xc, double yc, double r){
rad=SCR(-r);
else
rad=SCR(r);
- ellipse(screen, p, rad, rad, 0, getcolor(e1->foregr), ZP);
+ m_circ(p, rad, e1->foregr);
}
diff --git a/sys/src/cmd/plot/libplot/disk.c b/sys/src/cmd/plot/libplot/disk.c
index 47b39012b..4221d9c90 100644
--- a/sys/src/cmd/plot/libplot/disk.c
+++ b/sys/src/cmd/plot/libplot/disk.c
@@ -8,5 +8,5 @@ void plotdisc(double xc, double yc, double r){
rad=SCR(-r);
else
rad=SCR(r);
- fillellipse(screen, p, rad, rad, getcolor(e1->foregr), ZP);
+ m_disc(p, rad, e1->foregr);
}
diff --git a/sys/src/cmd/plot/libplot/machdep.c b/sys/src/cmd/plot/libplot/machdep.c
index 64a2d7f91..191de27fc 100644
--- a/sys/src/cmd/plot/libplot/machdep.c
+++ b/sys/src/cmd/plot/libplot/machdep.c
@@ -34,6 +34,29 @@ m_clrwin(int x0, int y0, int x1, int y1, int c)
if(offscreen != screen && !buffer)
draw(screen, xlr(Rect(x0, y0, x1+1, y1+1)), getcolor(c), nil, ZP);
}
+
+/*
+ * Draw circle at point p with radius rad in color c
+ */
+void
+m_circ(Point p, int rad, int c)
+{
+ ellipse(offscreen, p, rad, rad, 0, getcolor(c), ZP);
+ if (offscreen != screen && !buffer)
+ ellipse(screen, p, rad, rad, 0, getcolor(c), ZP);
+}
+
+/*
+ * Draw disc (filled circle) at point p with radius rad in color c
+ */
+void
+m_disc(Point p, int rad, int c)
+{
+ fillellipse(offscreen, p, rad, rad, getcolor(c), ZP);
+ if (offscreen != screen && !buffer)
+ fillellipse(screen, p, rad, rad, getcolor(c), ZP);
+}
+
/*
* Draw text between pointers p and q with first character centered at x, y.
* Use color c. Centered if cen is non-zero, right-justified if right is non-zero.
diff --git a/sys/src/cmd/plot/libplot/mplot.h b/sys/src/cmd/plot/libplot/mplot.h
index 6137a62c4..bf8df253b 100644
--- a/sys/src/cmd/plot/libplot/mplot.h
+++ b/sys/src/cmd/plot/libplot/mplot.h
@@ -36,6 +36,8 @@ int mapminx, mapminy, mapmaxx, mapmaxy; /* centered square */
*/
#include "../plot.h"
void m_clrwin(int, int, int, int, int);
+void m_circ(Point, int, int);
+void m_disc(Point, int, int);
void m_finish(void);
void m_initialize(char *);
int m_text(int, int, char *, char *, int, int, int);