35 lines
2.7 KiB
MQL5
35 lines
2.7 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| pcg_random_bitmap.mq5 |
|
|
//| Copyright © 2018, Amr Ali |
|
|
//| https://www.mql5.com/en/users/amrali |
|
|
//+------------------------------------------------------------------+
|
|
#include <Canvas/Canvas.mqh>
|
|
#include <Random.mqh>
|
|
//--- the random number generator object
|
|
CRandom pcg;
|
|
//+------------------------------------------------------------------+
|
|
//| Script program start function |
|
|
//+------------------------------------------------------------------+
|
|
void OnStart()
|
|
{
|
|
//--- hide the price chart
|
|
ChartSetInteger(0,CHART_SHOW,false);
|
|
//--- generate a bitmap of the random variable
|
|
string name="MyBitmap";
|
|
int width=512;
|
|
int height=512;
|
|
CCanvas can;
|
|
//---
|
|
can.CreateBitmapLabel(name,0,0,width,height,COLOR_FORMAT_XRGB_NOALPHA);
|
|
can.FillRectangle(0,0,width,height,XRGB(255,255,255));
|
|
for (int y=0; y<height; y++)
|
|
for (int x=0; x<width; x++)
|
|
{
|
|
//--- set pixel color from low-order bits
|
|
int r=pcg.RandomInteger()&0xFF;
|
|
can.PixelSet(x,y,XRGB(r,r,r));
|
|
}
|
|
//---
|
|
can.Update();
|
|
}
|
|
//+------------------------------------------------------------------+
|