MCPcopy Create free account
hub / github.com/ActiveState/code / setPenColor

Method setPenColor

recipes/Python/577674_Bitmap_Maker/recipe-577674.py:176–189  ·  view source on GitHub ↗
( self, pcolor )

Source from the content-addressed store, hash-verified

174 self.currentPen = self.fgcolor
175
176 def setPenColor( self, pcolor ):
177 oldColor = self.currentPen
178 # look for c in palette
179 pcolornum = pcolor.toLong()
180 try:
181 self.currentPen = self.palette.index( pcolornum )
182 except ValueError:
183 if len( self.palette ) < 256 :
184 self.palette.append( pcolornum )
185 self.currentPen = len( self.palette ) - 1
186 else:
187 self.currentPen = self.fgcolor
188
189 return Color.fromLong( self.palette[oldColor] )
190
191 def getPenColor( self ):
192 return Color.fromLong( self.palette[self.currentPen] )

Callers 1

create_imageFunction · 0.95

Calls 4

toLongMethod · 0.45
indexMethod · 0.45
appendMethod · 0.45
fromLongMethod · 0.45

Tested by

no test coverage detected