프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / DTI_PID / TextInfo.py @ 8b804ab7

이력 | 보기 | 이력해설 | 다운로드 (1.63 KB)

1
class TextInfo():
2
    def __init__(self, text, x, y, w, h, angle):
3
        self._text = text.replace('', '-')
4
        self.x = x
5
        self.y = y
6
        self.w = w
7
        self.h = h
8
        self.angle = angle
9

    
10
    @property
11
    def area(self):
12
        """
13
        return area of area
14
        """
15
        return self.w*self.h
16

    
17
    def contains(self, pt):
18
        if len(pt) == 2:
19
            if pt[0] < self.x: return False
20
            if pt[0] > self.x + self.w: return False
21
            if pt[1] < self.y: return False
22
            if pt[1] > self.y + self.h: return False
23
        elif len(pt) == 4:
24
            minx = pt[0]
25
            miny = pt[1]
26
            maxx = pt[2]
27
            maxy = pt[3]
28

    
29
            if minx < self.x: return False
30
            if maxx > self.x + self.w: return False
31
            if miny < self.y: return False
32
            if maxy > self.y + self.h: return False
33

    
34
        return True
35

    
36
    @property
37
    def center(self):
38
        """
39
        return center of text
40
        """
41
        return (self.getX() + self.getW()*0.5, self.getY() + self.getH()*0.5)
42

    
43
    def setText(self, text):
44
        self._text = text
45

    
46
    def getText(self):
47
        return self._text
48

    
49
    def setX(self, x):
50
        self.x = x
51

    
52
    def getX(self):
53
        return int(self.x)
54

    
55
    def setY(self, y):
56
        self.y = y
57

    
58
    def getY(self):
59
        return int(self.y)
60

    
61
    def setW(self, w):
62
        self.w = w
63

    
64
    def getW(self):
65
        return int(self.w)
66

    
67
    def setH(self, h):
68
        self.h = h
69

    
70
    def getH(self):
71
        return int(self.h)
72

    
73
    def setAngle(self, angle):
74
        self.angle = angle
75

    
76
    def getAngle(self):
77
        return self.angle