Package wx :: Package lib :: Package colourchooser :: Module pypalette :: Class PyPalette
[frames | no frames]

Type PyPalette

object --+                
         |                
    Object --+            
             |            
    EvtHandler --+        
                 |        
            Window --+    
                     |    
                Canvas --+
                         |
                        PyPalette


The Pure-Python Palette

The PyPalette is a pure python implementation of a colour palette. The palette implementation here imitates the palette layout used by MS Windows and Adobe Photoshop.

The actual palette image has been embedded as an XPM for speed. The actual reverse-engineered drawing algorithm is provided in the GeneratePaletteBMP() method. The algorithm is tweakable by supplying the granularity factor to improve speed at the cost of display beauty. Since the generator isn't used in real time, no one will likely care :) But if you need it for some sort of unforeseen realtime application, it's there.


Method Summary
  __init__(self, parent, id)
Creates a palette object.
  DrawBuffer(self)
Draws the palette XPM into the memory buffer.
  GeneratePaletteBMP(self, file_name, granularity)
The actual palette drawing algorithm.
  GetValue(self, x, y)
Returns a colour value at a specific x, y coordinate pair.
  HighlightPoint(self, x, y)
Highlights an area of the palette with a little circle around the coordinate point

Property Summary

Class Variable Summary
int HORIZONTAL_STEP = 2                                                                     
int VERTICAL_STEP = 4                                                                     

Instance Method Details

__init__(self, parent, id)
(Constructor)

Creates a palette object.

Overrides:
wx.lib.colourchooser.canvas.Canvas.__init__

DrawBuffer(self)

Draws the palette XPM into the memory buffer.

Overrides:
wx.lib.colourchooser.canvas.Canvas.DrawBuffer

GeneratePaletteBMP(self, file_name, granularity=1)

The actual palette drawing algorithm.

This used to be 100% reverse engineered by looking at the values on the MS map, but has since been redone Correctly(tm) according to the HSV (hue, saturation, value) colour model by Charl P. Botha <http://cpbotha.net/>.

Speed is tweakable by changing the granularity factor, but that affects how nice the output looks (makes the vertical blocks bigger. This method was used to generate the embedded XPM data.

GetValue(self, x, y)

Returns a colour value at a specific x, y coordinate pair. This is useful for determining the colour found a specific mouse click in an external event handler.

HighlightPoint(self, x, y)

Highlights an area of the palette with a little circle around the coordinate point


Class Variable Details

HORIZONTAL_STEP

Type:
int
Value:
2                                                                     

VERTICAL_STEP

Type:
int
Value:
4                                                                     

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:11:11 2007 http://epydoc.sf.net