[cairo] Shouldn't Cairo use/offer degrees rather than radians?

David Kastrup dak at gnu.org
Wed Jun 28 10:34:34 UTC 2017


Andreas Lobinger <lobingera at gmail.com> writes:

> Hello colleague,
>
> i'm actually not so sure, that PostScript and PDF
> interpreters/rasterizers internally deal with angles in deg, i'd
> rather expect them to use a CTM (and btw: they invented this notation)

Internally?  Sure.  We were talking about the API.

GS>dak at lola:/usr/local/tmp/lilypond$ gsnd
GPL Ghostscript 9.19 (2016-03-23)
Copyright (C) 2016 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>90 rotate
GS>matrix currentmatrix
GS<1>==
[0.0 -1.0 -1.0 0.0 0.0 842.0]
GS>180 sin
GS<1>==
0.0
GS>1e-20 sin ==
1.74532926e-22
GS>

As you can see, small numbers are printable, and specifying right angles
using degrees results in 0 for the respective elements that should be
zero.

That is more than Cairo can deliver right now.

> and maybe do what you have presented with the lillypond code (?) to
> deal in coverting from the rotation call to CTM. Which would be my
> recommendation if you see problems using cairo_rotate at exact angles:
> set the CTM manually. I do this for some use of consecutive scaling
> and actually it's quite nice to have an API for that.
>
> Feel free to provide a patch/API idea for degree interfacing. It's a
> niche problem (i know you disagree) but still might be interesting to
> others.

I think for cairo_rotate_deg it would be uncontentious since the degree
representation of the angle does not carry into the internal state.
I'll likely propose a patch along the lines of the code we use in
LilyPond.

It will take a bit experimentation to find examples where this can make
a difference.

For arcs, I don't see a similarly clear-cut approach.

-- 
David Kastrup


More information about the cairo mailing list