Canvas is cool! - page 6

 
Vladimir Karputov:

canvas.Rectangle is not an object, it's a command to draw a bunch of pixels. It's like a gunshot - a bullet goes off, and good riddance. There's no feedback.

Thanks for the no feedback - got it.

Rashid Umarov:

There is an article titled Exploring the CCanvas class.Implementation of transparency of graphical objects, there should be a solution.

I have viewed it 217 times and it is open now, but I haven't seen any solution.

I need live example of changing canvas and frame colour in OnTick().

Thank you!

 
Vitaly Muzichenko:

Thanks for the connection - got it.

I've looked at it 217 times, and it's open now, but I haven't seen a solution.

Need a live example of changing canvas and frame colour in OnTick().

Thank you!

Based on my code, just stuck in changing the canvas colour and drawing a frame.

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   static long counter=0;
   counter++;
   if(counter%40==0)
     {
      m_canvas.Erase(ColorToARGB(clrBlue,210));
      m_canvas.Rectangle(10,10,m_canvas.Width()-10,m_canvas.Height()-10,ColorToARGB(clrRed,255));
      m_canvas.Update();
      return;
     }
   if(counter%20==0)
     {
      m_canvas.Erase(ColorToARGB(clrRed,210));
      m_canvas.Rectangle(10,10,m_canvas.Width()-10,m_canvas.Height()-10,ColorToARGB(clrBlue,255));
      m_canvas.Update();
      return;
     }
  }


Since I use colours with transparency, I specified"COLOR_FORMAT_ARGB_NORMALIZE" when creating the canvas:

//--- create canvas
   if(!m_canvas.CreateBitmapLabel("SampleCanvas",5,15,700,300,COLOR_FORMAT_ARGB_NORMALIZE))
Files:
 
Vladimir Karputov:

Based on my own code, I just put in a change of canvas colour and draw a frame.


Since I use colours with transparency, I specified"COLOR_FORMAT_ARGB_NORMALIZE" when creating the canvas:

I'll take a look now, thanks!

What I expected to get - got a long time ago, it's a barely transparent canvas with a frame and selection, but now I need to change the colours, which doesn't work.


 
Vitaly Muzichenko:

I'll have a look now, thanks!

What I expected to get - got long ago, it's a barely transparent canvas with a border and a selection, but now I need to change the colours, which doesn't work.


Probably the problem is ENUM_COLOR_FORMAT (when creating the canvas) and the method of getting the colour.

 
Vitaly Muzichenko:

In OnInit I create a canvas

Then I need to change the colour at 10:00 to grey in OnTick and return it to the original state again at 11:00.

It doesn't work:

Question:

How do I change the colour of the canvas and frame - no reference to object names?

Thank you!

I have a feeling you've messed around with the colours.

What is the meaning of this line:

ObjectSetInteger(0,"CanvasExamlple",OBJPROP_COLOR,clrNONE);

COLOR_FORMAT_ARGB_NORMALIZE does not need to fill the canvas with the background colour, but rather to fill it with zero:

canvas.Erase(0);

for it means that the canvas is completely transparent.

It is also convenient to use the 16-color representation:

for example:

0x00000000 - fully transparent black

0xFF000000 - opaque black

0xFFFFFFFFFF - opaque white

0xFFFF0000 - opaque red

0xFF00FF00 - opaque green

0xFF0000FF - opaque blue

0x8000FF00 - translucent green

0x80FFFFFFFF - translucent black

0xFF808080 - grey

etc.

 
Vladimir Karputov:

Probably a problem with ENUM_COLOR_FORMAT (when creating the kanvas) and the method of getting the colour.

Problem solved.

My code didn't have the canvas removed when I closed the terminal, so it was already on the chart on startup, so it didn't initialize, and the property changes didn't know where to apply.

Thanks all!

 
Nikolai Semko:

I have a feeling you've messed with the colours.

What's the point of that line?

ObjectSetInteger(0,"CanvasExamlple",OBJPROP_COLOR,clrNONE);

The point of the line is that without it you get this picture


If with the line, then that's right, a nice frame with my chosen colour


 
Vitaly Muzichenko:

Problem solved.

My code didn't remove the canvas when I closed the terminal, so it was already on the chart when I started, so it didn't initialise, and the property changes didn't know where to apply.

Thanks all!

Hmmm, you really can't guess where the dog is at once :)

 

Demonstration of a script with bitmap scaling

In the Ex5 file sits a fairly large BMP file as a resource.


Files:
TestScaling.ex5  784 kb
 
Nikolai Semko:

Raster Scaling Script Demonstration

No, it's really impressive.

But, you have to make some kind of useful add-on that takes advantage of all those Canvas features.

So that your developments would not suffer the same fate as the CGA adapter - a wonderful graphic adapter, misunderstood and underestimated by its contemporaries.

I myself always considered CGA to be "lame as ever" losing to Commodore 64 or Sinclair Spectrum eight-bit graphics. But recently it turned out that, simply because of lack of popularity - almost nobody used all the opportunities of this card. And there were almost no games that could compete with eight-bit home computers.

Had IBM promoted CGA, had this demo appeared in 1981 - CGA would have been much more popular, and possibly EGA would have been released later:


When I look at this screen, I can't believe that this is possible on old CGA adapter with its 16K videomemory, connected to a common household TV (RGB monitor isn't suitable for this at all. That was the idea of the developers - higher quality text on RGB monitor, but poor colour palette, but rich graphical possibilities with bad readable text on household TV with a composite input)

Reason: