Lines Matching refs:Swizzle
109 class Swizzle:
112 A Swizzle is a mapping from one set of channels in one format to the
124 Sometimes a Swizzle is represented by a 4-character string. In this
146 """Creates a Swizzle object from a string or array."""
148 swizzle = [Swizzle.__identity_str.index(c) for c in swizzle]
152 assert isinstance(s, int) and 0 <= s and s <= Swizzle.SWIZZLE_NONE
156 self.__list = swizzle + [Swizzle.SWIZZLE_NONE] * (4 - len(swizzle))
160 """Returns an iterator that iterates over this Swizzle.
168 """Returns a string representation of this Swizzle."""
169 return ''.join(Swizzle.__identity_str[i] for i in self.__list)
180 assert idx >= Swizzle.SWIZZLE_X and idx <= Swizzle.SWIZZLE_NONE
181 if idx <= Swizzle.SWIZZLE_W:
199 """Returns the composition of this Swizzle with another Swizzle.
204 assert isinstance(other, Swizzle)
205 return Swizzle(self[x] for x in other)
210 Since swizzling isn't necisaraly a bijection, a Swizzle can never
219 to lumanence-alpha, we use Swizzle("xxxy").inverse() or "xw__".
224 rev = [Swizzle.SWIZZLE_NONE] * 4
227 if self.__list[j] == i and rev[i] == Swizzle.SWIZZLE_NONE:
229 return Swizzle(rev)
251 swizzle -- A Swizzle from this format to rgba
260 assert isinstance(swizzle, Swizzle)
458 return self.swizzle['a'] <= Swizzle.SWIZZLE_W
462 return self.swizzle[name] <= Swizzle.SWIZZLE_W
569 swizzle = Swizzle(fields[9])