本文整理匯總了Python中rect.Rect.write_raw_coords方法的典型用法代碼示例。如果您正苦於以下問題:Python Rect.write_raw_coords方法的具體用法?Python Rect.write_raw_coords怎麽用?Python Rect.write_raw_coords使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rect.Rect
的用法示例。
在下文中一共展示了Rect.write_raw_coords方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _NodeCursor
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import write_raw_coords [as 別名]
#.........這裏部分代碼省略.........
self.first_child = self.npool[nodei + 1]
self.index = index
def is_leaf(self):
return self.rect.swapped_x
def has_children(self):
return not self.is_leaf() and 0 != self.first_child
def holds_leaves(self):
if 0 == self.first_child:
return True
else:
return self.has_children() and self.get_first_child().is_leaf()
def get_first_child(self):
fc = self.first_child
c = _NodeCursor(self.root, 0, NullRect, 0, 0)
c._become(self.first_child)
return c
def leaf_obj(self):
if self.is_leaf():
return self.root.leaf_pool[self.first_child]
else:
return None
def _save_back(self):
rp = self.rpool
recti = self.index * 4
nodei = self.index * 2
if self.rect is not NullRect:
self.rect.write_raw_coords(rp, recti)
else:
rp[recti] = 0
rp[recti + 1] = 0
rp[recti + 2] = 0
rp[recti + 3] = 0
self.npool[nodei] = self.next_sibling
self.npool[nodei + 1] = self.first_child
def nchildren(self):
i = self.index
c = 0
for x in self.children(): c += 1
return c
def insert(self, leafo, leafrect):
index = self.index
# tail recursion, made into loop:
while True:
if self.holds_leaves():
self.rect = self.rect.union(leafrect)
self._insert_child(_NodeCursor.create_leaf(self.root, leafo, leafrect))
self._balance()
# done: become the original again
self._become(index)
return
else:
# Not holding leaves, move down a level in the tree: