Adding a volume effect to the indicator lines - page 4

 
barabashkakvn:
The dots are drawn without antialiasing. I specifically chose thePixelSetAA method - drawing dots with anti-aliasing.

Try drawing a line usingPixelSetAA.

The PolylineAA method uses the LineAA method. The LineAA method uses the PixelSetAA method. By drawing a single point, you will not see the effect of antialiasing.

 
tol64:
Try drawing a line usingPixelSetAA.

Nope. No effect. No near points of smoothing. Sharp corners are like bricks:

Line with dots via PixelSetAA

 
barabashkakvn:

Nope. No effect. No near points of smoothing. Sharp corners are like bricks:

I have supplemented the previous post. Note how the above methods are implemented and use them if smoothing is needed.
 
tol64:
I have supplemented the previous message. Note how the above methods are implemented and use them if you need smoothing.
I'm not touching the line drawing method with smoothing -PolylineAA for now. I want to understand what is stated in the help aboutPixelSetAA:
PixelSetAA-Draws a point using anti-aliasing algorithm.

Since this method draws a point with anti-aliasing, I should get an image like this if I draw several points in a row:

I think this is what a lot of dots with smoothing should look like

But I don't get smooth points.

 
barabashkakvn:
I'm not touching the method of drawing a line with smoothing -PolylineAA for now. I want to understand what is stated in help aboutPixelSetAA:
PixelSetAA-Draws a point using anti-aliasing algorithm.

Since this method draws a point with anti-aliasing, I should get an image like this if I draw several points in a row:

But I don't get smooth points.

That is why I suggest that you compare the code of methods with and without antialiasing. The code is open for study.

To understand it you need to thoroughly study the algorithms used in these methods.

You could even write an article on this topic. I would be glad to read it myself. )

 
The dot can't be smoothed out, it's an 'elementary particle' in a sense )
 
komposter:
A dot can't be smoothed, it's an "elementary particle" in a sense )
So here's the question: there are two methods(PixelSet andPixelSetAA). I'm very interested inPixelSetAA- maybe I don't understand how dot smoothing works?
 
barabashkakvn:
So that's the question: there are two methods(PixelSet andPixelSetAA). Very interested inPixelSetAA- maybe I don't understand how dot smoothing works?

If all else fails, read the help ;)

PixelSet simply sets the colour of the point.

 
We read the help. And so the question is," ShouldPixelSetAA draw even a single point using anti-aliasing?". I want to hear an opinion.
 
barabashkakvn:
We read the help. And so the question is," ShouldPixelSetAA draw even a single point using anti-aliasing?". I want to hear an opinion.

The answer is: thePixelSetAA methodshould draw even a single point using antialiasing, and it does draw that single point using antialiasing. To do this, I had to look into the code of the CCanvas:

//+------------------------------------------------------------------+
//| Draw pixel with antialiasing                                     |
//+------------------------------------------------------------------+
void CCanvas::PixelSetAA(const double x,const double y,const uint clr)
  {
   static double rr[4];
   static int    xx[4];
   static int    yy[4];
//--- preliminary calculations
   int    ix=(int)MathRound(x);
   int    iy=(int)MathRound(y);
   double rrr=0;
   double k;
   double dx=x-ix;
   double dy=y-iy;
   uchar  a,r,g,b;
   uint   c;
//--- no need for anti-aliasing
   if(dx==0.0 && dy==0.0)
     {
      PixelSet(ix,iy,clr);
      return;
     }
//--- prepare array of pixels
   xx[0]=xx[2]=ix;
   yy[0]=yy[1]=iy;
   if(dx<0.0)
      xx[1]=xx[3]=ix-1;
   if(dx==0.0)
      xx[1]=xx[3]=ix;
   if(dx>0.0)
      xx[1]=xx[3]=ix+1;
   if(dy<0.0)
      yy[2]=yy[2]=iy-1;
   if(dy==0.0)
      yy[2]=yy[2]=iy;
   if(dy>0.0)
      yy[2]=yy[2]=iy+1;
//--- calculate radii and sum of their squares
   for(int i=0;i<4;i++)
     {
      dx=xx[i]-x;
      dy=yy[i]-y;
      rr[i]=1/(dx*dx+dy*dy);
      rrr+=rr[i];
     }
//--- draw pixels
   for(int i=0;i<4;i++)
     {
      k=rr[i]/rrr;
      c=PixelGet(xx[i],yy[i]);
      a=(uchar)(k*GETRGBA(clr)+(1-k)*GETRGBA(c));
      r=(uchar)(k*GETRGBR(clr)+(1-k)*GETRGBR(c));
      g=(uchar)(k*GETRGBG(clr)+(1-k)*GETRGBG(c));
      b=(uchar)(k*GETRGBB(clr)+(1-k)*GETRGBB(c));
      PixelSet(xx[i],yy[i],ARGB(a,r,g,b));
     }
  }

class and realized that smoothing appears only if you pass a number of type double as coordinates, and not a rounded value, but with a "tail". Something like 200.4; 125.6; 200.7.

Here's a parabola drawn with points using thePixelSetAA method and it does start drawing with antialiasing:

A parabola drawn with dots using the PixelSetAA method and it does start to be drawn with smoothing