Some background on what I am using this chart for.
I'm using FloatCanvas in my client for Thousand Parsec -
http://www.thousandparsec.net (tpclient-pywx). You can see a screenshot
of my latest work here ->
http://www.thousandparsec.net/~tim/Screenshot-1.png
What I want to do, is display on the starmap little pie graphs which
show the concentration of resources in each system. The size of the pie
will show the relative amount of resource in each system (big == more
resources, smaller == less resources), while the pie pieces show the
break down (IE Red == Resource 1, Blue == Resource 2).
Thus the pie graph's diameter doesn't change relative to the zoom level.
> A few style issues (of this is going to get included in FloatCanvas,
> which I'd like it to -- I'm not sure if it should be a demo or another
> standard Object -- hmmm.
I'm afraid I'm in the tab camp. Feel free to convert to 4 spaces if you
want to include in the FloatCanvas core.
On another note, I also have the following objects,
* "PolygonStatic" which is like a point in that it never changes
size, just it position. (You can see it used for the little ship
icons and the Red arrow).
* "RelativePoint" exactly like a normal point but can also have a
*pixel* offset. (I use this to draw the little orbit dots in the
above screenshots.)
Are either of them useful to you?
> * you used tabs for indentation! as mixing tabs and spaces is a
> serious no-no, I've followed what is now standard Python practice:
> indentation is four spaces.
>
> * I'm a strong believer in "duck typing" -- i.e., I never check the
> types of inputs -- if they behave as I want, then what more do I need to
> know? Also, in this construction:
I use to be a believer in "duck typing", then none of my software ended
up working in strange cases. I now do quite a bit of type checking (and
I have found it is often best to subclass the real types).
That is of course all mute as you are the FloatCanvas maintainer and you
are free to do what ever you prefer :)
> if isinstance(args, dict):
> ObjectList.append(ArcPoint(EndXY, StartXY, CenterXY,
> **args))
> elif isinstance(args, (list, tuple)):
> ObjectList.append(ArcPoint(EndXY, StartXY, CenterXY,
> *args))
>
> I don't see how args could be a dict, but even if you want that
> flexibility, it's better to try to use it as one, then catch the error
> if it's not -- that way, someone could pass a "dict-like" object
> successfully.
I'm actually using a dict in the demo :)
PieBitsEqual = (
(10, {'LineColor':'Red', 'FillColor':'Red'}),
(10, {'LineColor':'Blue', 'FillColor':'Blue'}),
(10, {'LineColor':'Green', 'FillColor':'Green'}))
Technically you could subclass dict and you would also pass that test. I
actually don't know any other way to tell apart a dict from a list. Both
have getitem methods.
> FloatCanvas makes strong use of numpy, which as the very handy:
> N.asarray() function. What is does is try to turn the inputs in to the
> kind of array you specify, that way you then know you have an array, but
> the user can pass in a large number of possible inputs. If they do pass
> in an array, then there is no copying done.
I got lazy :)
> * You could probably use numpy for some of the other calculations --
> not going to make a noticeable performance difference here, but I prefer
> the syntax -- less looping, fewer errors.
I don't use numpy often, so feel free to improve it.
> more to come...
>
> -Chris
Okay cool.
Tim Ansell
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas