1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-11 20:05:03 -05:00
Simba/Projects/MMLLib/pymml/mmlcolor.py

44 lines
1.2 KiB
Python
Raw Normal View History

2010-05-31 19:59:48 -04:00
from ctypes import *
from mmltypes import isiterable
from mmltypes import POINT, PPOINT, PINTEGER
from mmltypes import PascalArray
2010-05-31 19:59:48 -04:00
class ColorException(Exception):
def __init__(self, err):
Exception.__init__(self, err)
# FIXME: Complete...
class Color(object):
'''
The Color class.
'''
_mc = None
def __init__(self, MC):
self._mc = MC
self._initialiseDLLFuncs()
def find(self, box, color):
x, y = (c_int(-1), c_int(-1))
self._mc.dll.findColor(byref(x), byref(y), color, *box)
return (x, y)
def findAll(self, box, color):
ptr = PPOINT()
self._mc.dll.findColors(byref(ptr), color, *box)
arr = PascalArray(POINT, ptr, self._mc)
print 'Length:', len(arr)
# for i in range(len(arr)):
# print i, arr[i].x, arr[i].y
return arr
2010-05-31 19:59:48 -04:00
def _initialiseDLLFuncs(self):
2010-05-31 20:03:25 -04:00
self._mc.dll.findColor.restype = c_int
2010-05-31 19:59:48 -04:00
self._mc.dll.findColor.argtypes = [PINTEGER, PINTEGER, c_int, c_int,
c_int, c_int, c_int]
self._mc.dll.findColors.restype = c_int
self._mc.dll.findColors.argtypes = [POINTER(PPOINT), c_int, c_int,
c_int, c_int, c_int]