Login Page - Create Account

Support Board


Date/Time: Mon, 16 Sep 2024 19:48:16 +0000



Post From: Bug with DRAWING_TRIANGLE ?

[2015-09-26 08:39:18]
zencoder - Posts: 10
We really do not know what to suggest
It's not so complicated - may I try? ))

You must add to every tool flag like UsePixelCoordinates.
When you (re)draw chart or when it resized, you definitely know its real width and height in pixels (as I hope). So, on redraw or resize event you simply recalculates this "pixel" coordinates to your current "percentage scale coordinates" with simplest formula:
x = x / window(chart)width * 150
y = y / window(chart)height * 100

You will get new tools coordinates which is already familiar to your drawing engine - no any modification to last one are not required. The only small code injection before positioning any drawing.

Below is example in abstract language:
current code:
Place(tool, tool.x, tool.y)
changed to:

x = tool.x; y = tool.y;
if ( UsePixelCoordinates )
{
x = x / window(chart)width * 150
y = y / window(chart)height * 100
}
Place(tool, x, y)
or this one:

if ( UsePixelCoordinates )
{
x = x / window(chart)width * 150
y = y / window(chart)height * 100
Place(tool, x, y)
}
else Place(tool, tool.x, tool.y)

"That's all folks" as it seems to me ;)
What do you think about this idea?