[Y-devel] shapes?

Mikko Rantalainen mira at cc.jyu.fi
Wed Feb 25 10:35:14 GMT 2004


> Date: Tue, 24 Feb 2004 12:18:12 -0500
> From: Aaron <drizzt321 at phpfreaks.com>
> 
> I don't think anybody has started work on, or thought about shapes, but 
> what about them? I've been poking around trying to figure out how I 
> would implement an ellipse/oval(that and line and rectangle are the base 
> shapes in most places), but I'm having a little bit of trouble seeing 
> where exactly I would fit the pieces together. For example, where 
> exactly would I have the work of putting each pixel on the screen? I 
> think the painter, but I haven't quite gotten how to specifically 
> extend/implement/use it to have it put stuff up on the screen. I would 
> like some guidence from those of you who have been poking around in the 
> source and are more familiar with the APIs and such.

Let's not repeat the same mistakes the X did and implement real 
bezier curves instead of only lines, rectangles and axis oriented 
ellipse. A nice API would have only a line sequence method and a 
polygon method and both take bezier curves as parameters. Something 
like how OpenGL draws lines and polygons, but with bezier curves 
instead of lines between vertexes. Perhaps an option to select 
border style with a brush.

I haven't looked at the actual code, but perhaps the following gives 
you an idea how I think this should work:

BezierSequence* startCurve(Point* p, Handle* h);
starts a sequence of bezier curves. p and h are structures or arrays 
with two floating point numbers. p is vector from origin to end 
point of the curve and h is vector from p pointing where the curve 
should go.

void appendCurve(BezierSequence* s, Point* p, Handle* h);
appends bezier curve started by startCurve() by appending a control 
point with a handle to it. If the curve is further appended with 
this method the resulting middle point connection will be smooth. 
Perhaps add an another method for making corners in the curve sequence.

Brush* createBrush(Size* s, Color* c, Model* m);
creates a brush of some kind. Basic brush could be a round spot, but 
perhaps we could have different models for galligraphic lines or 
something like that.

void drawBezierSequence(BezierSequence* s, Brush* b);
draws bezier sequence border line with a brush.

void fillBezierSequence(BezierSequence* s, Brush* b, Texture* t);
fills the area limited by bezier sequence with the texture t and 
draws the border line with the brush b. Perhaps add a flag to tell 
if the sequence encloses the area clockwise or counter-clockwise. 
Should the API allow texture t to be scaled/rotated/positioned?

These require a bit work but the first implementation doesn't need 
to have perfect quality. In the future, the implementation can be 
fixed to include anti-aliased border lines with proper transcludency 
so that the border line correctly mixes with the graphics "below" it.

I think many graphics adapters have some HW support for drawing 2D 
bezier curves so the graphics API should expose similar features or 
we'll have unneeded performance problems in the future.

Has there been some decisions about the cordinate system used? I 
hope it isn't fixed to pixels so that the UI can easily scale when 
we have 200dpi displays after a couple of years.

-- 
Mikko



More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved