![]() |
#1
|
|||
|
|||
![]()
Hello guys,
I am new to the forum. I have been using CorelDRAW since version 3.0 and I used to write some simple scripts (later vba macros) to facilitate most boring actions. Recently I found myself puzzled by IsOnShape property. I have noticed, that it returns cdrOnMarginOfShape value not only when the given coordinates are exactly on the shape outline, but also when they are near enough. It is some sort of hot spot around the curve. Is there any way to eliminate that? That is, is it possible to reduce the occurence of cdrOnMarginOfShape to the cases, when the coordinates are exactly on the outline, not just in the victinity of it? Cheers Tomasz |
#2
|
||||
|
||||
![]()
Yes, there is. The full syntax of the command is as follows:
Code:
Function IsOnShape(ByVal x As Double, ByVal y As Double, [ByVal HotArea As Double = -1]) As cdrPositionOfPointOverShape You can this hot area to be, say, 0.001 mm. Setting it to zero will almost guaranteed to fail because of many things, such as, Bezier calculations are always approximation. It's not an exact science. Even if you could determine if a point is exactly on the curve (which you can't), calculation precision could easily throw off your checks and yield incorrect result. I would suggest to use a very small, but non-zero hot area when doing any kind of checks like that... |
#3
|
|||
|
|||
![]()
Thanks Alex!
How could I omit it?! ![]() So the the function IsOnShape is related to the onscreen bitmap representation of the shape only? Is there any other way to tell if the given position is located inside shape of outside shape? Tomasz |
#4
|
||||
|
||||
![]()
No, of course not. No bitmaps. It is really vector math here.. However if you don't specify the HotArea parameter, it is chosen to be what the UI normally does - a few pixels on the screen, translated into the document coordinates using the current zoom level. Look at it this way - when you do the selection with the mouse, there is a threshold of a few pixels around the mouse pointer (I don't know, maybe a square of 4x4 pixels). Let's imagine that your screen is 1024x768 and it shows the whole A4 page (around 300 mm high). Let's subtract the menu/toolbars/status bar - we'll have about 500 pixels vertically left to display the drawing. So, 300 mm in 500 pixels will make each pixel about 0.6 mm. So, with this zoom level, the hot area will be 2.4 x 2.4mm. But this is only true if you do not specify the parameter. If you do specify your hot area, it will not be zoom/screen resolution related.
The only reason why it works the way it is, is yo allow a macro to behave like other tools in the UI and to eliminate the need for the VBA developer to do all those calculations involving zoom level, document window size, etc... I hope this makes sense... |
#5
|
|||
|
|||
![]()
Thanks Alex!
Now I understand (At least I think so). Tomasz |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
New macro to clip curves w.r.t. a border | Gerard Hermans | Macros/Add-ons | 0 | 09-06-2003 07:50 |