Hi Frank,
you wrote:
> I wonder how difficult it is for a non-mathematical API user to create
> an AffineMatrix2D from a degree and a center point. Please don't tell me
> this needs pen and paper, this would make the method completely useless
> to the average user (and thus I'd continue to argue it should be removed).
> If there were some service which creates such a matrix from a degree and
> a center point, then I'd vote for leaving the method in.
>
basegfx::B2DHomMatrix aMatrix;
aMatrix.rotate(nAngle);
aMatrix.scale(nScaleX,nScaleY);
aMatrix.translate(nMoveX,nMoveY);
...
canvas.setTransformation(
basegfx::unotools::affineMatrixFromHomMatrix(aMatrix));
All the expressive power you need is in B2DHomMatrix. We can even add
additional convenience functions, if you miss anything.
> > I see your point, but I don't think we need dumbing down the interface
> > more than necessary. Transformations come almost for free on the
> > canvas (both simple and normal), and make things easy that have been
> > clumsy before. Every modern graphics API has them, people who need it
> > will (quite easily) learn about them, and the rest can simply leave
> > this method alone.
>
> You are argueing from the wrong side here, IMO. The fact that affine
> transformations can be implemented easily doesn't have anything to do
> with the question whether or not to slay the user of a XSimpleFoo API :)
>
Well, given the existence of B2DHomMatrix (and
java.awt.geom.AffineTransform, BTW) - do you still think the
transformation abstraction is too complex?
> I don't know XCanvas and css.rendering in detail, but is it true that
> XSimpleCanvas, except simplifying the API, internally "only" holds the
> RenderState and the ViewState to be used for XCanvas' methods?
>
> If so, would it make sense to expose those two as attributes/methods?
>
Excellent idea, yes, makes sense.
> >>>Converting XGraphic to XBitmap is
> >>>lossy, in general (because XGraphic can also contain vector
> >>>images).
> >>
> >>That's okay - for the target audience of this interface, as I understand it.
> >
> > No, it's not. Just because an interface is simple/easy to use, it does
> > not mean it has to encourage wrong usage (please note that I'm really
> > thinking long-term here - a few years from now, scalable UI will be
> > prevalent, see Avalon/Aqua/increasingly cairo-based toolkits. I'm sure
> > you don't want ugly up-scaled bitmaps in OOo then...)
>
> I don't get your point here. Can XBitmap contain vector images? If not,
> then wouldn't it be better to use XGraphics, according to your argueing?
> /me is confused.
>
Well, if XBitmap would also contain vector data, it would be quite a
misnomer. XGraphic is a great interface (because it facilitates alien
vector formats, like EMF/WMF, SVG, etc.) to be directly rendered onto
an OutputDevice or XCanvas (without the currently necessary conversion
to a potentially lossy intermediate format). But this is really only
elegant with a disjunct service (or else every XCanvas/XSimpleCanvas
implementation would have to duplicate that functionality).
So, to summarize: except for setTransformation(), we seem to agree
largely. I'd vote for keeping it, and (if necessary) beef up the
tooling for affine transformations. Which yields:
---%<----------------------------------------------------------------
interface XSimpleCanvas: com::sun::star::uno::XInterface
{
/** Select a font.<p>
This method selects the specified font (or a close substitute)
as the current font for text output.<p>
@param sFontName
The name of the font (like e.g. Arial)
@param size
The size of the font (note that this is not the usual points
unit, but in the same coordinate system as the other rendering
operations - usually, device pixel).
@param bold
When true, selected font is bold.
@param italic
When true, selected font is italic
*/
void selectSimpleFont( [in] string sFontName, [in]double size,
[in] bool bold, [in] bool italic );
//-------------------------------------------------------------------------
/** Sets the color used by line and text operations.<p>
To disable stroking, simply set this color to something with
zero alpha (i.e. fully transparent).<p>
@param nsRgbaColor
RGBA color tuple, interpreted in the sRGB color space.
*/
void setPenColor( [in] com::sun::star::util::Color nsRgbaColor );
//-------------------------------------------------------------------------
/** Sets the fill color.<p>
To disable filling, simply set this color to something with
zero alpha (i.e. fully transparent).<p>
@param nsRgbaColor
RGBA color tuple, interpreted in the sRGB color space.
*/
void setFillColor( [in] com::sun::star::util::Color nsRgbaColor );
//-------------------------------------------------------------------------
/** Sets the clip to the specified rectangle.<p>
*/
void setRectClip( [in] ::com::sun::star::geometry::RealRectangle2D
aRect );
//-------------------------------------------------------------------------
/** Set the current transform matrix.<p>
*/
void setTransformation( [in]
::com::sun::star::geometry::AffineMatrix2D aTransform );
//-------------------------------------------------------------------------
/** Sets a single pixel on the canvas.<p>
*/
void drawPixel( [in] ::com::sun::star::geometry::RealPoint2D
aPoint );
//-------------------------------------------------------------------------
/** Draws a line on the canvas.<p>
*/
void drawLine( [in] ::com::sun::star::geometry::RealPoint2D
aStartPoint,
[in] ::com::sun::star::geometry::RealPoint2D
aEndPoint );
//-------------------------------------------------------------------------
/** Draws a rectangle on the canvas.<p>
*/
void drawRect( [in] ::com::sun::star::geometry::RealRectangle2D
aRect );
//-------------------------------------------------------------------------
/** Draws a poly-polygon on the canvas.<p>
*/
void drawPolyPolygon( [in] XPolyPolygon2D xPolyPolygon );
//-------------------------------------------------------------------------
/** Draws text on the canvas.<p>
@param aText
Text to render
@param aOutPos
Output position of the text. This is the left or right edge,
depending on nTextDirection. Output position is always
relative to the font baseline.
@param nTextDirection
A value from the <type>TextDirection</type> collection,
denoting the main writing direction for this string. The main
writing direction determines the origin of the text output,
i.e. the left edge for left-to-right and the right edge for
right-to-left text.
*/
void drawText( [in] StringContext aText,
[in] ::com::sun::star::geometry::RealPoint2D
aOutPos,
[in] byte nTextDirection );
//-------------------------------------------------------------------------
/** Draws the bitmap on the canvas.<p>
@param xBitmap
Bitmap to render
@param aLeftTop
Left, top position of the bitmap on the destination canvas.
*/
void drawBitmap( [in] XBitmap xBitmap,
[in] ::com::sun::star::geometry::RealPoint2D
aLeftTop );
//-------------------------------------------------------------------------
/** Request the associated graphic device for this canvas.<p>
A graphic device provides methods specific to the underlying
output device capabilities, which are common for all canvases
rendering to such a device. This includes device resolution,
color space, or bitmap formats.<p>
@return the associated <type>XGraphicDevice</type>.
*/
XGraphicDevice getDevice();
//-------------------------------------------------------------------------
/** Query the underlying <type>XCanvas</type>.<p>
@return the canvas interface this object is internally based
on.
*/
XCanvas getCanvas();
//-------------------------------------------------------------------------
/** Request the font metrics of the current font.<p>
@return the font metrics of the currently selected font.
*/
FontMetrics getFontMetrics();
//-------------------------------------------------------------------------
/** Retrieve currently selected font.<p>
@return the font instance that's currently used for rendering
text.
*/
XCanvasFont getCurrentFont();
//-------------------------------------------------------------------------
/** Retrieve color currently used for lines.
*/
com::sun::star::util::Color getCurrentPenColor();
//-------------------------------------------------------------------------
/** Retrieve color currently used for fills
*/
com::sun::star::util::Color getCurrentFillColor();
//-------------------------------------------------------------------------
/** Retrieve current clip rect
*/
com::sun::star::geometry::RealRectangle2D getCurrentClipRect();
//-------------------------------------------------------------------------
/** Retrieve current transformation matrix
*/
com::sun::star::geometry::AffineMatrix2D
getCurrentTransformation();
//-------------------------------------------------------------------------
/** Retrieve view state.<p>
@return the view state, that would generate matching output,
when rendering to an XCanvas instead.
*/
ViewState getCurrentViewState();
//-------------------------------------------------------------------------
/** Retrieve render state.<p>
@return the render state, that would generate matching output,
when rendering to an XCanvas instead.
*/
RenderState getCurrentRenderState();
//-------------------------------------------------------------------------
};
---%<-------------------------------------------------------------------------
Cheers,
--
Thorsten
If you're not failing some of the time, you're not trying hard enough.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]