OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 18-08-2006, 15:30
Tomasz Tomasz is offline
Junior Member
 
Join Date: Aug 2006
Posts: 21
Default cdrOnMarginOfShape

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
Reply With Quote
  #2  
Old 20-08-2006, 09:22
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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 may notice the third parameter "HotArea" which is the size of a square around the point you are testing to include in outline intersection. By default (if it is -1), the current zoom level is used and the area would be a few screen pixels around the point. This is the same way the UI works (when you click a mouse on outline, you might not click exactly on the right pixel, but still would expect the object to be selected).

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...
Reply With Quote
  #3  
Old 21-08-2006, 13:38
Tomasz Tomasz is offline
Junior Member
 
Join Date: Aug 2006
Posts: 21
Default Well, it doesn't seem to work properly...

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
Reply With Quote
  #4  
Old 21-08-2006, 21:42
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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...
Reply With Quote
  #5  
Old 28-08-2006, 12:07
Tomasz Tomasz is offline
Junior Member
 
Join Date: Aug 2006
Posts: 21
Default

Thanks Alex!

Now I understand (At least I think so).

Tomasz
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT -5. The time now is 00:18.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com