📄 ugldemo.c
字号:
uglCursorInit (devId, 32, 32, displayWidth / 2, displayHeight / 2); cursorDib.width = cursorDib.height = cursorDib.stride = 32; cursorDib.hotSpot.x = cursorDib.hotSpot.y = 16; cursorDib.pImage = cursorData; cursorDib.clutSize = 2; cursorDib.pClut = cursorClut; cursorDdb = uglCursorBitmapCreate(devId, &cursorDib); uglCursorImageSet (devId, cursorDdb); uglCursorOn(devId); } /* Initialization finished, drawing begins */ ClearScreen(gc); if(pauseDemo(mode) < 0) { ClearScreen(gc); cleanUp(mode); return; } /* BitmapWrite test */ uglBitmapWrite(devId, &transDib, 0,0,31,31,UGL_DISPLAY_ID,100,100); if(pauseDemo(mode) < 0) { ClearScreen(gc); cleanUp(mode); return; } /* DDB blt */ ClearScreen(gc); uglBatchStart(gc); for (i = 0; i < 1000; i++) uglBitmapBlt(gc, stdDdb,0,0,31,31,UGL_DEFAULT_ID, randomData[i],randomData[i+1]); uglBatchEnd(gc); if(pauseDemo(mode) < 0) { ClearScreen(gc); cleanUp(mode); return; } /* TDDB blt */ ClearScreen(gc); uglBatchStart(gc); for (i = 0; i < 1000; i++) uglBitmapBlt(gc, transDdb,0,0,31,31,UGL_DEFAULT_ID, randomData[i],randomData[i+1]); uglBatchEnd(gc); if(pauseDemo(mode) < 0) { ClearScreen(gc); cleanUp(mode); return; } /* Simple lines */ ClearScreen(gc); uglBatchStart(gc); 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) { ClearScreen(gc); cleanUp(mode); return; } /* 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 % 16].uglColor); uglLine(gc, randomData[index], randomData[index + 1], randomData[index + 2], randomData[index + 3]); index += 4; } uglBatchEnd(gc); if(pauseDemo(mode) < 0) { ClearScreen(gc); 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) { ClearScreen(gc); 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) { ClearScreen(gc); 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) { ClearScreen(gc); 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) { ClearScreen(gc); 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) { ClearScreen(gc); cleanUp(mode); return; } /* 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) { ClearScreen(gc); cleanUp(mode); return; } /* Text */ ClearScreen(gc); uglBatchStart(gc); y = 0; textpage = 0; tmp = 0; for (i = 0; i < 1000; 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) { ClearScreen(gc); cleanUp(mode); return; } /* 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) { ClearScreen(gc); 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) { ClearScreen(gc); cleanUp(mode); return; } /* Stretch Blits */ ClearScreen(gc); uglBitmapStretchBlt(gc,stdDdb,0,0,31,31,UGL_NULL,100,100,200,150); if(pauseDemo(mode) < 0) { ClearScreen(gc); cleanUp(mode); return; } ClearScreen(gc); uglBitmapStretchBlt(gc,stdDdb,0,0,31,31,UGL_NULL,100,100,150,200); if(pauseDemo(mode) < 0) { ClearScreen(gc); cleanUp(mode); return; } ClearScreen(gc); uglBitmapStretchBlt(gc,stdDdb,0,0,31,31,UGL_NULL,0,0, displayWidth-1, displayHeight-1); if(pauseDemo(mode) < 0) { ClearScreen(gc); cleanUp(mode); return; } ClearScreen(gc); /* Clean Up */ cleanUp(mode); return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -