• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to trim a bezier path?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to trim a bezier path?


  • Subject: Re: How to trim a bezier path?
  • From: Alastair Houghton <email@hidden>
  • Date: Fri, 9 Dec 2005 20:08:56 +0000

On 7 Dec 2005, at 16:10, Scott Thompson wrote:

On Dec 7, 2005, at 8:50 AM, Jim Marschke wrote:

But that means every time I want to draw the path I have to recreate it. That can take a while when I have thousands of points -- and multiple paths. The path itself seems to be a great storage area, and when I resize I just do a transform rather than rebuilding. There are easy ways to append data to a path, I was hoping someone knew of a way to remove data.

Jim

A much better strategy would be to filter the 10,000 points depending on how you plan to display them. In the example above, you could choose every 10th point, or average 10 points, or any of a number of other strategies to generate a path of only 1000 points.

I'm going to chip in here because I've seen people screw this up time after time. You absolutely cannot just choose every 10th point unless you're certain that your data has only small frequency components at over one tenth of the collection frequency. If you don't pay attention to this, you'll display completely the wrong graph (lots of sample editors do this, which is quite inexcusable because they are written by people who should know better; you can see the effect as you zoom in/out of the sample data).

You *do* need to process the data a bit; a simple way to do this is to "minimax" the points you're amalgamating, by which I mean you find the minimum value and the maximum value, and draw a line between those two. This means you can skip lots of intermediate points whilst keeping the display sensible. Alternatively you could use a digital filter (the specification for which depends on your application), or even use a combination (e.g. you might draw a light- coloured line using the minimax approach, then mark in the 95th percentile in a darker colour).

Also, if you're finding that NSBezierPath is too slow (e.g. because your data set is very large), you could try OpenGL. The latter is hardware accelerated and because it doesn't give the same image quality guarantees that Core Graphics does, it can be a lot faster for this type of application.

(Apologies if you know all this already, but it's an oft-overlooked gotcha when drawing graphs with more horizontal points than pixels.)

Kind regards,

Alastair.

--
http://www.alastairs-place.net


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >How to trim a bezier path? (From: Jim Marschke <email@hidden>)
 >Re: How to trim a bezier path? (From: Scott Thompson <email@hidden>)
 >Re: How to trim a bezier path? (From: Jim Marschke <email@hidden>)
 >Re: How to trim a bezier path? (From: Scott Thompson <email@hidden>)

  • Prev by Date: Double click in NSTableView and bindings. Anything special?
  • Next by Date: Re: What is the best/simplest/proper way to make right mouse click "do" left mouse click as well in NSTableView
  • Previous by thread: Re: How to trim a bezier path?
  • Next by thread: Re: How to trim a bezier path?
  • Index(es):
    • Date
    • Thread