Making a crowdsourced project on Canvas - page 20

 

Compared these formulas, different results indeed. I also compared the speeds.

The left half is made up of three different colour layers, with 128 transparency everywhere. The colours are mixed by the terminal.

The top right one is made in one layer, blended according to the English wiki.

Bottom right in one layer, according to Russian wiki.


Comparison of terminal and English wiki by screenshot (terminal from above)


Comparing formulas by resources saved to file (English from above)


It takes a lot of time to create a resource, compared to calculating the colour and filling the array up to 10 times, probably no point in dealing with OCL.

PS Seems like a good idea, you can photoshop in MT bang on :)

Files:
script.mq5  4 kb
 
People who know the CCanvas class, can you tell me if it's possible to create a gradient there? For example, for a rectangle to turn it into a button? I've been wanting to ask that for a long time).
 
Реter Konow:
People who know the CCanvas class, can you tell me if it's possible to create a gradient there? For example, for a rectangle to turn it into a button? I've been wanting to ask that for a long time).
There is.
 
Artyom Trishkin:
Check.

Are there any examples of buttons drawn with Canvas? I don't recall seeing any. I've seen some very cool buttons, but they were based on source images, and I haven't seen any fully kanvas-drawn ones...
 
Реter Konow:

Are there any examples of buttons drawn with Kanawas? I don't recall seeing any. I've seen some very cool buttons, but they were based on source images, and I haven't seen a fully kanvas-drawn one...
Read Anatoly's description of his graphic library - about informational elements, if memory serves me correctly.
 
Artyom Trishkin:
Read Anatoly's description of his graph library - about information elements, if my memory serves me correctly.

I'll try to find it...
 
Found it. The tooltip element uses a gradient. But I haven't understood if it's possible to set a different colour and transparency for each gradient line. I'll have to go through kanvas at my leisure. I am curious...
 
Реter Konow:
People who know the CCanvas class, can you tell me if it's possible to create a gradient there? For example, for a rectangle to turn it into a button? I've been wanting to ask that for a long time).
Hi Peter!
I don't see any problem with the gradient.
Here's a simple clear example of a script that goes through all the colours and draws a changing gradient coloured square dynamically.
Just for it to work, you need to move array m_pixels[] in Canvas.mqh to public
public:
   uint              m_pixels[];               // array of pixels
#include <Canvas\Canvas.mqh>
void OnStart()
  {
   CCanvas Grad;

   color col;
   if(!Grad.CreateBitmapLabel(0,0,"Grad",100,100,256,256,COLOR_FORMAT_XRGB_NOALPHA)) Print("Error creating canvas: ",GetLastError());
   for(int r=0; r<256; r++) // red
     {
      int j=0;
      // заполняем цветной градиентный квадрат
      for(int b=0; b<256; b++) // blue
         for(int g=0; g<256; g++) // green
           {
            col=(color)(((r&0x0000FF)<<16)|((g&0x0000FF)<<8)|(b&0x0000FF)); // формируем цвет RGB
            Grad.m_pixels[j]=col; // рисуем точку с текущим цветом
            j++;
           }
      Grad.Update();
      Sleep(20);  // Подождем для плавности
     }
  }
Files:
Gradient.mq5  2 kb
 
Nikolai Semko:
Hi Peter!
I don't see any problem with the gradient.
Here's a simple example of a script that goes through all the colours and draws a gradient coloured square.
Just for it to work, you need to move array m_pixels[] in Canvas.mqh to public


Hi Nikolai!

Thanks for the example, but that's not what I meant. I didn't make my point clearly. I meant the frame of the square, which will turn the square into a button. For that, the lines of the frame need to be different. For example, if top and left lines are light and bottom and right lines are dark, button is pressed, if it is vice versa, button will look pressed. I wanted to know how it can be done with kanvas.

The gradient called the frame lines. Maybe this is wrong...

 
Реter Konow:

Hi Nikolai!

Thanks for the example, but that's not what I meant. I didn't make my point clearly. I meant the frame of the square, which will turn the square into a button. For that, the lines of the frame need to be different. For example, if top and left lines are light and bottom and right lines are dark, button is pressed, if it is vice versa, button will look pressed. I wanted to know how it can be done with kanvas.

The gradient called the frame lines. Maybe this is wrong...


The image of the button can be formed either by loading a ready bmp image or using software drawing (there are a lot of variants). And then simply by processing the mouse events in OnChartEvent change its image.
Reason: