NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

fill.py (1349B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\drawingpolygon\components\fill.py
      2 from drawingpolygon.drawingelement import DrawingElement
      3 from carbonui.primitives.base import ScaleDpi
      4 from carbonui.primitives.polygon import Polygon as UiPolygon
      5 
      6 class PolygonFill(DrawingElement, UiPolygon):
      7 
      8     def ApplyAttributes(self, attributes):
      9         super(PolygonFill, self).ApplyAttributes(attributes)
     10         self.is_complete = False
     11 
     12     def is_available(self):
     13         return self.renderObject is not None
     14 
     15     def execute_only_if_available(function):
     16 
     17         def wrapper(self, *args, **kwargs):
     18             if self.is_available():
     19                 return function(self, *args, **kwargs)
     20 
     21         return wrapper
     22 
     23     @execute_only_if_available
     24     def add_vertex(self, x, y):
     25         self.AddPoint(ScaleDpi(x), ScaleDpi(y), self.color.GetRGBA())
     26 
     27     @execute_only_if_available
     28     def remove_vertex(self, index):
     29         self.RemovePoint(index)
     30         if self.is_complete:
     31             self.Triangulate()
     32 
     33     @execute_only_if_available
     34     def update_vertex(self, index, x, y):
     35         self.UpdatePoint(index, ScaleDpi(x), ScaleDpi(y))
     36         if self.is_complete:
     37             self.Triangulate()
     38 
     39     @execute_only_if_available
     40     def complete(self):
     41         self.is_complete = True
     42         self.Triangulate()