ldraw.py

Mon, 11 Dec 2017 00:46:35 +0200

author
Santeri Piippo
date
Mon, 11 Dec 2017 00:46:35 +0200
changeset 3
1dc58f44d556
parent 2
50d3086070df
child 4
8eb83f200486
permissions
-rw-r--r--

Can now write dat files, added direct color handling

3
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
1 class Color:
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):
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
5 if self.is_direct_color():
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
6 # write direct colors with hex codes
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)
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
10 def is_direct_color(self):
1dc58f44d556 Can now write dat files, added direct color handling
Santeri Piippo
parents: 2
diff changeset
11 return self.index >= 0x2000000

mercurial