-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcartesian_oval_figure.py
82 lines (63 loc) · 1.9 KB
/
cartesian_oval_figure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from PyGraphing import Graph, Icon
from PyGraphing.graph import Font, Text
from PyGraphing.series.scatter import ScatterImage, ScatterBezier
from PySVG.Draw import Rect
class Figure(Graph):
def __init__(self, x, y):
super().__init__(500, 500)
self.x = x
self.y = y*-1 + 500
def _icon(self):
color = (255, 228, 196)
icon = Rect()
icon.fill = color
icon.fill_opacity = 1
icon.stroke = color
icon.stroke_width = 0
icon.ry = 3
return icon
def text(self):
text = Text()
text.anchor = 'start'
text.baseline = 'central'
text.font = Font('Roboto Mono', 14, '500')
text.fill_opacity = 1
text.fill = (108, 166, 173)
return text
def _set_legend(self):
self.legend.active = False
def _set_frame(self):
self.frame.active = False
self._set_xaxis()
self._set_yaxis()
def _set_xaxis(self):
self.plot.xmin = 0
self.plot.xmax = 500
def _set_yaxis(self):
self.plot.ymin = 0
self.plot.ymax = 500
def _set_plot(self):
icon = Icon(self._icon(), 5, 5)
s = ScatterImage(self.plot, 'images\\normal.png', icon, list([-1]), list([1]))
s.image.width = 500
s.image.height = 500
self.plot.add_child(s)
i = self._icon()
ii = self._icon()
ii.fill_opacity = 0
ii.stroke_width = 0
s = ScatterBezier(self.plot, Icon(ii, 5, 5), self.x, self.y)
s.line.stroke = i.stroke
s.line.stroke_width = 4
s.line.fill_opacity = 0
self.plot.add_child(s)
def set_sizes(self):
w, h = self.w, self.h
self.plot.xywh(0, 0, w, h)
def construct(self):
self.set_sizes()
self._set_legend()
self._set_frame()
self._set_plot()
self._title()
return super().construct()