Thank you for this kind of solution to the problem. Indeed, the rendering speed has increased. Looks like I'll have to learn the library.
I would also like to clarify the following nuance. It compiles with this formulation with a warning:
And it compiles with this one without a warning, but the speed is a bit slower.
What is more correct?)
Ah, yes, I forgot to put int. The library is geared towards double coordinates. Speed cannot drop. (int) is practically free. Less than nanosecond. You may set it so:
y = Round(Canvas.Y(price));
It won't affect speed either (+ ~1 ns), but it will position a little more accurately.
The Round function built into iCanvas returns int and is much faster than the regular round() function, but the double argument x must be within int (-2 147 483 648 <= x <= 2 147 483 647)
int Ceil (double x) { return (x-(int)x>0)?(int)x+1:(int)x; }
int Round(double x) { return (x>0)?(int)(x+0.5):(int)(x-0.5);}
int Floor(double x) { return (x>0)?(int)x:((int)x-x>0)?(int)x-1:(int)x; }
int Fabs(int x) {if (x<0) return -x; elsereturn x;}
double X(double bar){return((double)W.Left_bar-bar)*W.dx_pix;}; //The X coordinate by the bar number. The bar number must be of type double, otherwise, the bar will be interpreted as time.double X(datetime Time) //The X coordinate by the time.
{ if(tester) return X((double)iBarShift(_Symbol,_Period,Time));
elsereturn X(wBarShift(Time,W.time,_Period));}
double Y(double Price) {if(W.dy_pix==0) W.dy_pix=1; return((W.Y_max-Price)/W.dy_pix); }; //The Y coordinate by the price.double Price(int y) {return (W.Y_max-y*(W.Y_max-W.Y_min)/W.Height);}; // Price by the Y coordinatedouble Bar(double x) {return((double)W.Left_bar+1-x/(double)W.dx_pix);}; // bar number by coordinate X datetime TimePos(double x) // time by coordinate X
{
double B=Bar(x);
if (tester || W.BarsInWind == 0) iT[0]=iTime(_Symbol,_Period,(int)B);
else {if(B<0 ) iT[0]=datetime(W.time[W.BarsInWind-1]-(long)B*PeriodSeconds());
elseif(B<W.Right_bar || B>W.Left_bar) iT[0]=iTime(_Symbol,_Period,(int)B);
else iT[0]=W.time[W.BarsInWind-Floor(B)-1+(int)W.Right_bar];}
return iT[0]+int((double)PeriodSeconds()*(1-B+(int)B));
};
Take this code out of the loop and call it once before each redraw event:
Is it really more complicated than learning some library?
That's what I was saying. I'm just wondering - can you do it yourself, and not just repeat my advice? two of them are easy to output... Code, please. If you don't, I'll write it myself tomorrow when I wake up. But then I will call Fedoseev an idiot. ))
That's what I said. I'm just wondering - can you do it yourself, and not just repeat my advice? two of them are easy to output... Code, please. If you don't, I'll write it myself tomorrow when I wake up. But then I will call Fedoseev an idiot. ))
Thank you for this kind of solution to the problem. Indeed, the rendering speed has increased. Looks like I'll have to learn the library.
I would also like to clarify the following nuance. It compiles with this formulation with a warning:
And it compiles with this one without a warning, but the speed is a bit slower.
What is more correct?)
Ah, yes, I forgot to put int. The library is geared towards double coordinates.
Speed cannot drop. (int) is practically free. Less than nanosecond.
You may set it so:
It won't affect speed either (+ ~1 ns), but it will position a little more accurately.
The Round function built into iCanvas returns int and is much faster than the regular round() function, but the double argument x must be within int (-2 147 483 648 <= x <= 2 147 483 647)
Look inside iCanvas and the question goes away:
But Kanvas is much nicer to work with, you can apply transparency, it's faster and the code takes less space )):
Thank you for this kind of solution to the problem. Indeed, the rendering speed has improved. Looks like I'll have to learn the library.
I would also like to clarify the following nuance. It compiles with this formulation with a warning:
And it compiles with this one without a warning, but the speed is a bit slower.
What is more correct?)
Take this code of yours out of the loop and call it once before the loop on each repaint event:
Is it more complicated than learning some library?
Like a fish in water :)
PNB2))
Take this code out of the loop and call it once before each redraw event:
Is it really more complicated than learning some library?
That's what I was saying.
I'm just wondering - can you do it yourself, and not just repeat my advice?
two of them are easy to output...
Code, please.
If you don't, I'll write it myself tomorrow when I wake up. But then I will call Fedoseev an idiot. ))
That's what I said.
I'm just wondering - can you do it yourself, and not just repeat my advice?
two of them are easy to output...
Code, please.
If you don't, I'll write it myself tomorrow when I wake up. But then I will call Fedoseev an idiot. ))
Incredibly impressed by your ideas about me))
I'm incredibly impressed by your perceptions of me))
Less words, more action
Thank you for the examples! Very clear and informative, and not least quick.
All the graphics from the example on the kanvas in the object lists look like a single object.
Is it possible to get different tooltips (tooltips) when hovering the mouse on individual graphics items?
Or may I create a separate canvas object for each rectangle? Won't it affect the speed?
If you have time, I'm waiting for an answer, and maybe a code example.