New article: Studying the CCanvas Class. How to Draw Transparent Objects

Back to topics list To post a new topic, please log in or register
avatar
Moderator
72392
MetaQuotes 2015.03.05 14:12
 

New article Studying the CCanvas Class. How to Draw Transparent Objects has been published at mql5.com:

Do you need more than awkward graphics of moving averages? Do you want to draw something more beautiful than a simple filled rectangle in your terminal? Attractive graphics can be drawn in the terminal. This can be implemented through the CСanvas class, which is used for creating custom graphics. With this class you can implement transparency, blend colors and produce the illusion of transparency by means of overlapping and blending colors.

Drawing in MetaTrader 5 is simple and you need to know only a few nuances. One of the nuances is how the terminal screen is designed. More precisely, we are interested in the way the graphics are output on the screen. For example, a chart can be displayed in the foreground or in the background. Color output on the screen will depend on the chart display. Some graphical objects may change color in the overlapping or intersection areas.

Before proceeding directly to drawing using the CCanvas class, let's analyze some definitions related to color processing. For example, let's find out the meaning of the Alpha channel.

In my opinion, implementation of transparency is the most important technology, which can vivify an image. For example, transparency can be used to implement a more attractive interface with smooth color transition or shadows. Shadow adds up dimension to a graphical object and visually softens the object edges.


5. The Illusion of Transparency

Now we can proceed to the practical implementation of transparency.

Let us draw a number of filled rectangles (script "xor.mq5"). To illustrate the difference of color processing methods, let us apply three non-overlapping horizontal canvases on top of the chart.

The first one is processed using COLOR_FORMAT_XRGB_NOALPHA, the second one - COLOR_FORMAT_ARGB_RAW and the third one - COLOR_FORMAT_ARGB_NORMALIZE. Then we gradually change the transparency from 255 (fully opaque) to 0 (fully transparent). Let's call our script "Illusion.mq5".

The video shows how the script "Illusion.mq5" works:


Fig. 11. Work of script illusion.mq5

Author: Karputov Vladimir

avatar
34
nerd-fold_12 2015.03.19 19:26 #
 
thank u this video is very helpful !!!!
Back to topics list  

To add comments, please log in or register