ldraw.py

Wed, 20 Dec 2017 17:25:09 +0200

author
Santeri Piippo
date
Wed, 20 Dec 2017 17:25:09 +0200
changeset 6
6da1e81c5652
parent 4
8eb83f200486
permissions
-rw-r--r--

Added code to compute areas of triangles and quadrilaterals

4
8eb83f200486 color -> colour
Santeri Piippo
parents: 3
diff changeset
1 class Colour:
3
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
2 def __init__(self, index):
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
3 self.index = int(index, 0)
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
4 def __str__(self):
4
8eb83f200486 color -> colour
Santeri Piippo
parents: 3
diff changeset
5 if self.is_direct_colour():
8eb83f200486 color -> colour
Santeri Piippo
parents: 3
diff changeset
6 # write direct colours with hex codes
3
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
7 return '0x%07X' % self.index
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
8 else:
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
9 return str(self.index)
4
8eb83f200486 color -> colour
Santeri Piippo
parents: 3
diff changeset
10 def is_direct_colour(self):
3
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
11 return self.index >= 0x2000000

mercurial