204 views
in GUI Development by
I checked some of the examples of using Graphics::Canvas. I am able to draw at least in prototyper using some of the methods like DrawLine or FillRectangle. But I could not make DrawText render anything. Any suggestions or examples? I use EW 9.30.  Thanks.

1 Answer

0 votes
by

Hello,

following is a working example (assuming there is font resource named Application::Font). The value clipRect should correspond to the area being updated in canvas. textRect should be the area of the text inside the canvas. Crucial and possibly a little bit problematic is srcPos. It is an offset in source coordinates to arrange the text relative to the top-left corner of textRect. Therefore it is negative. This was tested with EM v14 but should work with v9.30. See also documentation:

var point srcPos = point( 0, -Application::Font.Ascent );

aCanvas.DrawText( clipRect, Application::Font, "Hello world", 0, -1, textRect, srcPos, 0, Views::Orientation.Normal, #000000FF, #000000FF, #000000FF, #000000FF, true );

Best regards

Paul Banach

by
Thanks. It is the negative offset confused me.

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...