Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CG migration from QD




On Jan 31, 2005, at 5:38 PM, Edwards, Waverly wrote:

I'm currently looking at migrating from Quickdraw to CoreGraphics.
I've been reading Quartz 2D References today and I'm not too clear on current limitations of CG.

My app will be drawing thousands of polygons and lines, circles, squares, etc (but mostly polygons) to represent a map (roads, bodies of water, interstates, cities, states etc)

I am not finding any API's for polygon drawing

To draw a polygon you would construct a path using CGContextMoveToPoint followed by a number of calls to CGContextAddLineToPoint. Stop at the last point and use CGContextClosePath.

A way to test what polygon my mouse is currently over.

There are a number of ways to do this. One is demonstrated in the Carbon Sketch sample where you basically create a one point square, draw each polygon into the context, and detect whether or not the polygon colors the context at that point.

Another way to handle it is to use the geometry of the polygon and the mouse location to detect if the mouse goes down in the polygon. This is probably the fastest mechanism. Just search the web for point in polygon tests.

A way to test if an object is within a particular region ( a free hand lasso or rectangle)

For each of your objects, keep a bounding rectangle of that shape and determine whether or not that rectangle intersects the selection area.


CG Paths don't really seem to be as effective as regions as I'm understanding them.

Depends on what you are using them for. Regions, by their very nature, live at a fixed resolution. Paths are resolution independent constructs. If you have a 70 dpi screen, and a 300 dpi printer, you can't use the same region with both of them. You can use the same path for either environment.

Pixel regions cannot represent things like antialiased edges, paths and image maps can.

There are a number of other differences.

Regions are effective in some environments, and paths are more appropriate in others.

As it stands now, it does not look like a good idea to even try using CG as all the functionality associated with QD does not exist within CG.

It might help if you gave more information about what functionality you are talking about. If I am reading your complaints properly, however, much of the functionality you are looking for is more appropriately handled by libraries outside of Core Graphics.

The difference is that Core Graphics is rather strictly directed at drawing and not much else. QuickDraw, on the other hand, had a tight integration with the windowing system that caused some non-drawing functionality to creep into that library. There are other systems, outside of Core Graphics, which support the same functionality that the older Mac OS integrated into QuickDraw.


Am I overlooking something or should I wait to see what will be added to CG in future OS releases?

I suspect you expect Core Graphics to be more than a drawing library and it simply is not designed to be. Please offer more information about what you want to do and we can probably point you to additional resources.

Scott
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >CG migration from QD (From: "Edwards, Waverly" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.