Package wx :: Package lib :: Package agw :: Module cubecolourdialog

[frames | no frames]

## Module wx.lib.agw.cubecolourdialog

The CubeColourDialog is an alternative implementation of wx.ColourDialog, and it offers different functionalities with respect to the default wxPython one. It can be used as a replacement of wx.ColourDialog with exactly the same syntax and methods.

Some features:

- RGB components may be controlled using spin controls or with mouse gestures on a 3D RGB cube, with the 3 components laying on the X, Y, Z axes;
- HSB components may be controlled using spin controls or with mouse gestures on a 2D colour wheel;
- Brightness has its own vertical slider to play with;
- The colour alpha channel can be controlled using another vertical slider, or via spin control;
- The colour alpha channel controls can be completely hidden at startup or the choice to use the alpha channel can be left to the user while playing with the dialog, via a simple wx.CheckBox;
- The "old colour" and "new colour" are displayed in two small custom panel, which support alpha transparency and texture;
- CubeColourDialog displays also the HTML colour code in hexadecimal format;
- When available, a corresponding "Web Safe" colour is generated using a 500 web colours "database" (a dictionary inside the widget source code). Web Safe colours are recognized by all the browsers;
- When available, a corresponding "HTML name" for the selected colour is displayed, by using the same 500 web colours "database";
- When available, a corresponding "Microsoft Access Code" for the selected colour is displayed, by using the same 500 web colours "database".

And much more.

License And Version:

CubeColourDialog is freeware and distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 15 Oct 2008, 10.00 GMT

Version 0.2.

Classes
`AlphaCtrl` | Implements the drawing, mouse handling and sizing routines for the alpha channel control.
`BaseLineCtrl` | Base class used to hold common code for the Alpha channel control and the brightness palette control.
`BasePyControl` | Base class used to hold common code for the HSB colour wheel and the RGB colour cube.
`BrightCtrl` | Implements the drawing, mouse handling and sizing routines for the brightness palette control.
`Colour` | This is a subclass of wx.Colour, which adds Hue, Saturation and Brightness capability to the base class.
`ColourPanel` | Simple custom class used to display "old" and "new" colour panels, with alpha blending capabilities.
`CubeColourDialog` | This is the CubeColourDialog main class implementation.
`CustomPanel` |
`HSVWheel` | Implements the drawing, mouse handling and sizing routines for the HSV colour wheel.
`LineDescription` | Simple class to store description and constants for a line in 2D space.
`RGBCube` | Implements the drawing, mouse handling and sizing routines for the RGB cube colour.

Function Summary
| ``AngleFromPoint`(pt, center)` Returns the angle between the x-axis and the line connecting the center and the point pt.
| ``deg2rad`(x)` Transforms degrees into radians.
| ``Distance`(pt1, pt2)` Returns the distance between 2 points.
| ``DrawCheckerBoard`(dc, rect, checkColour, box)` Draws a checkerboard on a wx.DC.
| ``FindC`(line)` Internal function.
| ``Intersection`(line1, line2)` Calculates the intersection point between 2 lines.
| ``PointOnLine`(pt1, pt2, length, maxLen)` Internal function.
| ``PtFromAngle`(angle, sat, center)` Given the angle with respect to the x-axis, returns the point based on the saturation value.
| ``rad2deg`(x)` Transforms radians into degrees.
| ``RestoreOldDC`(dc, oldPen, oldBrush, oldMode)` Restores the old settings for a wx.DC.
| ``rgb2html`(colour)` Transforms a RGB triplet into an html hex string.
| ``scaletomax`(x)` Normalize a value as a function of the radius.
| ``Slope`(pt1, pt2)` Calculates the slope of the line connecting 2 points.
| ``toscale`(x)` Normalize a value as a function of the radius.

Function Details

### AngleFromPoint(pt, center)

Returns the angle between the x-axis and the line connecting the center and the point pt.

### deg2rad(x)

Transforms degrees into radians.

### Distance(pt1, pt2)

Returns the distance between 2 points.

### DrawCheckerBoard(dc, rect, checkColour, box=5)

Draws a checkerboard on a wx.DC. Used for the Alpha channel control and the colour panels.

### FindC(line)

Internal function.

### Intersection(line1, line2)

Calculates the intersection point between 2 lines.

### PointOnLine(pt1, pt2, length, maxLen)

Internal function.

### PtFromAngle(angle, sat, center)

Given the angle with respect to the x-axis, returns the point based on the saturation value.

### rad2deg(x)

Transforms radians into degrees.

### RestoreOldDC(dc, oldPen, oldBrush, oldMode)

Restores the old settings for a wx.DC.

### rgb2html(colour)

Transforms a RGB triplet into an html hex string.

### scaletomax(x)

Normalize a value as a function of the radius.

### Slope(pt1, pt2)

Calculates the slope of the line connecting 2 points.

### toscale(x)

Normalize a value as a function of the radius.

Generated by Epydoc 2.1.20050511.rpd on Mon Feb 16 12:52:48 2009 | http://epydoc.sf.net