| 81 | } |
| 82 | |
| 83 | void ColourPanel::updateTexture(const MyGUI::Colour& _colour) |
| 84 | { |
| 85 | size_t size = 32; |
| 86 | |
| 87 | MyGUI::uint8* pDest = static_cast<MyGUI::uint8*>(mTexture->lock(MyGUI::TextureUsage::Write)); |
| 88 | |
| 89 | for (size_t j = 0; j < size; j++) |
| 90 | for (size_t i = 0; i < size; i++) |
| 91 | { |
| 92 | float x = (float)i / size; |
| 93 | float y = (float)j / size; |
| 94 | *pDest++ = MyGUI::uint8((1.0f - y) * (_colour.blue * x + (1.0f - x)) * 255); // B |
| 95 | *pDest++ = MyGUI::uint8((1.0f - y) * (_colour.green * x + (1.0f - x)) * 255); // G |
| 96 | *pDest++ = MyGUI::uint8((1.0f - y) * (_colour.red * x + (1.0f - x)) * 255); // R |
| 97 | *pDest++ = 255; // A |
| 98 | } |
| 99 | |
| 100 | // Unlock the pixel buffer |
| 101 | mTexture->unlock(); |
| 102 | } |
| 103 | |
| 104 | void ColourPanel::notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) |
| 105 | { |