Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
68
6.12.3 The drawing functions
6.12.3.1 Drawlines
We draw some "flowers" made of lines at different angles centered on the same point. First set up the line width and
line end, write some information and then draw the flower.
/* Draw 4 "flowers" with lines of different width */
MM_U32 DrawLines(UTIL_CONTEXT *putCtx)
{
MM_U32 ret = MML_OK;
MM_FLOAT f, cx, cy, px, py, s, c;
/* Set the line end to round */
utLineEnd(putCtx, UT_LINE_END_BUTT);
px = 5;
py = 0;
/* The the paint color */
utColor(putCtx, 255, 255, 255, 255);
/* Change the line width to 0.5 pixel */
utLineWidth(putCtx, 0.6f);
/* Print a text as comment */
UTIL_SUCCESS(ret, utTextOut(putCtx, (MM_S32)px, (MM_S32)py, "Width 0.6"));
cx = 30 + px;
cy = 50 + py;
/* Draw lines in a loop */
for
(f = 0; f < 180; f+= 9.0f)
{
c = 30 * cosf(f*DegreeToPI);
s = 30 * sinf(f*DegreeToPI);
UTIL_SUCCESS(ret, utLinef(putCtx, cx - c, cy - s, cx + c, cy + s));
}
Repeat with different line widths at different positions on the screen.
/* repeat the code with different offsets and line width */
px += 80;
utLineWidth(putCtx, 1.0f);
UTIL_SUCCESS(ret, utTextOut(putCtx, (MM_S32)px, (MM_S32)py, "Width 1.0"));
cx = 30 + px;
cy = 50 + py;
for
(f = 0; f < 180; f+= 9.0f)
{
c = 30 * cosf(f*DegreeToPI);