📄 ugldemo.c
字号:
uglBatchStart(gc);
uglLineStyleSet(gc, UGL_LINE_STYLE_DASHED);
index = 0;
for (i = 0; i < numRandomPoints / 2; i++)
{
uglForegroundColorSet(gc, colorTable[ i % 16].uglColor);
uglLine(gc, randomData[index], randomData[index + 1],
randomData[index + 2], randomData[index + 3]);
index += 4;
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
/* Wide solid lines */
ClearScreen(gc);
uglBatchStart(gc);
index = 0;
for (i = 0; i < numRandomPoints / 2; i++)
{
uglForegroundColorSet(gc, colorTable[ i % 15 + 1].uglColor);
uglLineWidthSet(gc, (i % 6) + 1);
uglLine(gc, randomData[index], randomData[index + 1],
randomData[index + 2], randomData[index + 3]);
index += 4;
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
/* Wide dashed lines */
ClearScreen(gc);
uglBatchStart(gc);
uglLineStyleSet(gc, UGL_LINE_STYLE_DASHED);
index = 0;
for (i = 0; i < numRandomPoints / 2; i++)
{
uglForegroundColorSet(gc, colorTable[ i % 15 + 1].uglColor);
uglLineWidthSet(gc, (i % 6) + 1);
uglLine(gc, randomData[index], randomData[index + 1],
randomData[index + 2], randomData[index + 3]);
index += 4;
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
/* Filled rectangles */
ClearScreen(gc);
uglBatchStart(gc);
index = 0;
for (i = 0; i < numRandomPoints / 2; i++)
{
int left = min(randomData[index], randomData[index + 2]);
int right = max(randomData[index], randomData[index + 2]);
int top = min(randomData[index + 1], randomData[index + 3]);
int bottom = max(randomData[index + 1], randomData[index + 3]);
uglForegroundColorSet(gc, colorTable[ i % 15 + 1].uglColor);
uglBackgroundColorSet(gc, colorTable[ 15 - (i % 15)].uglColor);
uglLineWidthSet(gc, (i % 6) + 1);
uglRectangle(gc, left, top , right, bottom);
index += 4;
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
/* Rectangles filled with a pattern */
ClearScreen(gc);
uglBatchStart(gc);
uglFillPatternSet(gc, patternDdb);
index = 0;
for (i = 0; i < numRandomPoints / 15; i++)
{
int left = min(randomData[index], randomData[index + 2]);
int right = max(randomData[index], randomData[index + 2]);
int top = min(randomData[index + 1], randomData[index + 3]);
int bottom = max(randomData[index + 1], randomData[index + 3]);
uglForegroundColorSet(gc, colorTable[ i % 15 + 1].uglColor);
uglBackgroundColorSet(gc, colorTable[ 15 - (i % 15)].uglColor);
uglLineWidthSet(gc, i % 6 + 1);
uglRectangle(gc, left, top , right, bottom);
index += 4;
}
uglFillPatternSet(gc, 0);
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
/* Filled polygons */
ClearScreen(gc);
uglBatchStart(gc);
index = 0;
for (i = 0; i < numRandomPoints / 10; i++)
{
uglForegroundColorSet(gc, colorTable[ i % 15 + 1].uglColor);
uglBackgroundColorSet(gc, colorTable[ 15 - (i % 15)].uglColor);
randomData[index + 18] = randomData[index];
randomData[index + 19] = randomData[index + 1];
uglPolygon(gc, 10, &randomData[index]);
index += 20;
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
#endif
#if 1
/* Polygons filled with a pattern */
ClearScreen(gc);
uglBatchStart(gc);
uglFillPatternSet(gc, patternDdb);
index = 0;
for (i = 0; i < numRandomPoints / 22; i++)
{
uglForegroundColorSet(gc, colorTable[ i % 15 + 1].uglColor);
uglBackgroundColorSet(gc, colorTable[ 15 - (i % 15)].uglColor);
uglLineWidthSet(gc, i % 4 + 1);
randomData[index + 18] = randomData[index];
randomData[index + 19] = randomData[index + 1];
uglPolygon(gc, 10, &randomData[index]);
index += 20;
}
uglFillPatternSet(gc, 0);
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
#endif
/* Text */
ClearScreen(gc);
uglBatchStart(gc);
y = 0;
textpage = 0;
tmp = 0;
for (i = 0; i < 100; i++)
{
uglForegroundColorSet(gc, colorTable[ i % 15 + 1].uglColor);
uglBackgroundColorSet(gc, colorTable[ 15 - (i % 15)].uglColor);
switch (i % 3)
{
case 0:
uglFontSet(gc, fontSystem);
uglTextSizeGet(fontSystem, UGL_NULL, &tmp, -1, fontTestText);
break;
case 1:
uglFontSet(gc, fontDialog);
uglTextSizeGet(fontDialog, UGL_NULL, &tmp, -1, fontTestText);
break;
case 2:
uglFontSet(gc, fontFixed);
uglTextSizeGet(fontFixed, UGL_NULL, &tmp, -1, fontTestText);
break;
}
uglTextDraw(gc, 0, y, -1, fontTestText);
y += tmp;
if (y >= displayHeight)
{
y = 0;
textpage++;
}
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
#if 1
/* Filled Ellipses */
ClearScreen(gc);
uglBatchStart(gc);
index = 0;
for (i = 0; i < numRandomPoints / 2; i++)
{
int left = min(randomData[index], randomData[index + 2]);
int right = max(randomData[index], randomData[index + 2]);
int top = min(randomData[index + 1], randomData[index + 3]);
int bottom = max(randomData[index + 1], randomData[index + 3]);
uglForegroundColorSet(gc, colorTable[ i % 16].uglColor);
uglBackgroundColorSet(gc, colorTable[ 15 - (i % 15)].uglColor);
uglEllipse(gc, left, top, right, bottom, 0, 0, 0, 0);
index += 4;
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
/* Pie Shapes */
ClearScreen(gc);
uglBatchStart(gc);
index = 0;
for (i = 0; i < numRandomPoints / 4; i++)
{
int left = min(randomData[index], randomData[index + 2]);
int right = max(randomData[index], randomData[index + 2]);
int top = min(randomData[index + 1], randomData[index + 3]);
int bottom = max(randomData[index + 1], randomData[index + 3]);
uglForegroundColorSet(gc, colorTable[ i % 16].uglColor);
uglBackgroundColorSet(gc, colorTable[ 15 - (i % 15)].uglColor);
uglEllipse(gc, left, top, right, bottom,
randomData[index + 4], randomData[index + 5],
randomData[index + 6], randomData[index + 7]);
index += 8;
}
uglBatchEnd(gc);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
/* Stretch Blits */
ClearScreen(gc);
uglBitmapStretchBlt(gc,stdDdb,0,0,31,31,UGL_NULL,100,100,200,150);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
ClearScreen(gc);
uglBitmapStretchBlt(gc,stdDdb,0,0,31,31,UGL_NULL,100,100,150,200);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
ClearScreen(gc);
uglBitmapStretchBlt(gc,stdDdb,0,0,31,31,UGL_NULL,0,0,
displayWidth-1, displayHeight-1);
if(pauseDemo(mode) < 0)
{
cleanUp(mode);
return;
}
ClearScreen(gc);
#endif
/* Clean Up */
cleanUp(mode);
/*复位VGA*/
/*vgaInit();
vgaHrdInit();*/
return;
}
void showchinese(void)
{
UGL_FONT_DRIVER_ID fontDrvId;
UGL_FONT_DEF fontDef;
UGL_FONT_ID fontBanner;
UGL_DEVICE_ID devId;
UGL_GC_ID gc;
/*
UGL_WCHAR *text0 = "上李邕\0";
UGL_WCHAR *text1 = "作者李白";
UGL_WCHAR *text2 = "大鹏一日同风起,扶摇直上九万里。";
UGL_WCHAR *text3 = "假令风歇时下来,犹能簸却沧溟水。";
UGL_WCHAR *text4 = "时人见我恒殊调,闻余大言皆冷笑。";
UGL_WCHAR *text5 = "宣父犹能畏后生,丈夫未可轻年少。";
*/
UGL_WCHAR *text0 = "evoc";
UGL_WCHAR *text1 = "kuangyaowen";
UGL_WCHAR *text2 = "kuangyaowen";
UGL_WCHAR *text3 = "kuangyaowen";
UGL_WCHAR *text4 = "vxworks";
UGL_WCHAR *text5 = "vxworks";
if (uglInitialize() == UGL_STATUS_ERROR)
{
return;
}
uglDriverFind(UGL_DISPLAY_TYPE,0,(UGL_UINT32*)&devId);
uglDriverFind(UGL_FONT_ENGINE_TYPE, 0, (UGL_UINT32*)&fontDrvId);
gc = uglGcCreate(devId);
if(uglFontFindString(fontDrvId, "familyName=Song", &fontDef) == UGL_STATUS_ERROR)
{
printf("\nBanner's uglFontFindString failed.\n");
}
if ((fontBanner = uglFontCreate(fontDrvId, &fontDef)) == UGL_NULL)
{
printf("Font not found. Exiting.\n");
exit (1);
}
uglColorAlloc (devId, &colorTable[BLACK].rgbColor, UGL_NULL,
&colorTable[BLACK].uglColor, 1);
uglColorAlloc(devId, &colorTable[BLUE].rgbColor, UGL_NULL,
&colorTable[BLUE].uglColor, 1);
uglColorAlloc(devId, &colorTable[YELLOW].rgbColor, UGL_NULL,
&colorTable[YELLOW].uglColor, 1);
uglColorAlloc(devId, &colorTable[WHITE].rgbColor, UGL_NULL,
&colorTable[WHITE].uglColor, 1);
uglBatchStart(gc);
uglBackgroundColorSet(gc, colorTable [YELLOW].uglColor);
uglForegroundColorSet(gc, colorTable [BLUE].uglColor);
uglBatchEnd(gc);
uglFontSet(gc, fontBanner);
uglBatchStart(gc);
uglTextDrawW(gc, 250, 100, strlen(text0), (UGL_WCHAR *)text0);
uglTextDrawW(gc, 300, 150, strlen(text1), (UGL_WCHAR *)text1);
uglTextDrawW(gc, 150, 200, strlen(text2), (UGL_WCHAR *)text2);
uglTextDrawW(gc, 150, 250, strlen(text3), (UGL_WCHAR *)text3);
uglTextDrawW(gc, 150, 300, strlen(text4), (UGL_WCHAR *)text4);
uglTextDrawW(gc, 150, 350, strlen(text5), (UGL_WCHAR *)text5);
uglBatchEnd(gc);
printf("after textdraw!\n");
#if 1
uglDeinitialize();
#endif
/*复位VGA*/
/*vgaInit();
vgaHrdInit();*/
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -