how can I draw into MyGUI::Canvas

Robie

19-01-2012 12:18:59

Hello everybody!
I have some question about MyGUI::Canvas... How can I draw into Canvas, I need it for drawing some diagrams and statistics.. :?
Everybody who know answer, please help

Altren

19-01-2012 14:23:48

Canvas create simple texture that you can use as pizel buffer and set pixels of such texture directly:
Here's piece of code from Demo_Colour (generates colour gradient):
void ColourPanel::updateTexture(const MyGUI::Colour& _colour)
{
size_t size = 32;

MyGUI::uint8* pDest = static_cast<MyGUI::uint8*>(mTexture->lock(MyGUI::TextureUsage::Write));

for (size_t j = 0; j < size; j++)
for (size_t i = 0; i < size; i++)
{
float x = (float)i / size;
float y = (float)j / size;
*pDest++ = MyGUI::uint8((1. - y) * (_colour.blue * x + (1. - x)) * 255); // B
*pDest++ = MyGUI::uint8((1. - y) * (_colour.green * x + (1. - x)) * 255); // G
*pDest++ = MyGUI::uint8((1. - y) * (_colour.red * x + (1. - x)) * 255); // R
*pDest++ = 255; // A
}

// Unlock the pixel buffer
mTexture->unlock();
}


Also if you are going to draw graphs. that is actually a line - you can use PolygonalSkin instead (sample in UnitTest_Spline), that let's you draw lines and splines.

Robie

19-01-2012 14:54:17

:D O, nice! thank you very much!!!! :D