Bu sayfadaki yazılar
Sayfanın metni
Sayfa 144
void Plot(POINT2D *p2dPoint, unsigned char color); void DrawLine(int x1, int y1, int x2, int y2, unsigned char color); void DrawLine(POINT2D *p2dPoint1, POINT2D *p2dPoint2, unsigned char color); void DrawLine(RECT *rctRect, unsigned char color); void DrawRectangle(int x1, int y1, int x2, int y2, unsigned char color); void DrawRectangle(POINT2D *p2dPoint1, POINT2D *p2dPoint2, unsigned char color); void DrawRectangle(RECT *rctRect, unsigned char color); void DrawCircle(int cx, int cy, int r, unsigned char color); void DrawCircle(POINT2D *p2dPoint, int r, unsigned char color); void FillRectangle(int x1, int y1, int x2, int y2, unsigned char color); void FillRectangle(POINT2D *p2dPoint1, POINT2D *p2dPoint2, unsigned char color); void FillRectangle(RECT *rctRect, unsigned char color); void FillCircle(int cx, int cy, int r, unsigned char color); void FillCircle(POINT2D *p2dPoint, int r, unsigned char color);
/** * Ana Fonksiyon */ void main() { // Değişken tanımları int x, y, i; POINT2D myPoint1; POINT2D myPoint2(40, 40); RECT myRect1; myPoint1.setX(30); myPoint1.setY(30);
// 320x200 256 renk ekran moduna geç SetScreen(VGA13);
// Palet oluştur // 0 - 63 kırmızı tonları (0 : en koyu @siyah@; 63 : en açık @kırmızı@) // 64 - 127 yeşil tonları (64 : en koyu @siyah@; 127 : en açık @yeşil@) // 128 - 191 mavi tonları (128 : en koyu @siyah@; 191 : en açık @mavi@) // 192 - 255 gri tonları (192 : en koyu @siyah@; 255 : en açık @beyaz@) for(i = 0; i <= 63; i++) SetColor(i, i, 0, 0); // kırmızı for(i = 64; i <= 127; i++) SetColor(i, 0, (i - 64), 0); // yeşil for(i = 128; i <= 191; i++) SetColor(i, 0, 0, (i - 128)); // mavi for(i = 192; i <= 255; i++) SetColor(i, (i - 192), (i - 192), (i - 192)); // gri
// Ekrana birkaç örnek nokta bas Plot(30, 40, 234); // Birinci kullanım biçimi Plot(&myPoint1, 60); // İkinci kullanım biçimi Plot(&myPoint2, 92); Plot(&POINT2D(40, 30), 182); // Üçüncü kullanım biçimi
// Ekrana birkaç örnek çizgi çek // Çizgilerin başlangıç ve bitişlerini plot ile işaretle
// Çizgi 1 myPoint1.setX(80); myPoint1.setY(150); myPoint2.setX(213); myPoint2.setY(48); DrawLine(&myPoint1, &myPoint2, 63); Plot(&myPoint1, 255); Plot(&myPoint2, 255);
// Çizgi 2 myPoint1.setX(80); myPoint1.setY(48); myPoint2.setX(213); myPoint2.setY(150); DrawLine(&myPoint1, &myPoint2, 63); Plot(&myPoint1, 255);
Klavyeyle gezinmek için ← ve → tuşları.
Sayfa 145
Plot(&myPoint2, 255);
// Çizgi 3 myPoint1.setX(40); myPoint1.setY(110); myPoint2.setX(77); myPoint2.setY(121); myRect1 = &RECT(&myPoint1, &myPoint2); DrawLine(&myRect1, 63); Plot(&myPoint1, 255); Plot(&myPoint2, 255);
// Çizgilerden bir daire çiz for(i = 0; i < 512; i++) { x = 250 + 55 * cos((float)i / 256 * M_PI); y = 100 + 55 * sin((float)i / 256 * M_PI); DrawLine(250, 100, x, y, x + y); }
// Ekrana birkaç örnek dikdörtgen çiz
// Dikdörtgen 1 DrawRectangle(70, 170, 10, 183, 49);
// Dikdörtgen 2 myPoint1.setX(80); myPoint1.setY(160); myPoint2.setX(95); myPoint2.setY(190); DrawRectangle(&myPoint1, &myPoint2, 117);
// Dikdörtgen 3 myRect1.setX1(170); myRect1.setY1(160); myRect1.setX2(105); myRect1.setY2(190); DrawRectangle(&myRect1, 185);
// Ekrana birkaç örnek içi dolu dikdörtgen çiz
// İçi Dolu Dikdörtgen 1 FillRectangle(68, 172, 12, 181, 49);
// İçi Dolu Dikdörtgen 2 myPoint1.setX(85); myPoint1.setY(165); myPoint2.setX(90); myPoint2.setY(185); FillRectangle(&myPoint1, &myPoint2, 127);
// İçi Dolu Dikdörtgen 3 myRect1.setX1(250); myRect1.setY1(165); myRect1.setX2(310); myRect1.setY2(185); FillRectangle(&myRect1, 63);
// Ekrana birkaç örnek çember çiz
// Çember 1 DrawCircle(100, 100, 20, 255);
// Diğer iç içe dizilmiş çemberler myPoint1 = &POINT2D(150, 40); for(i = 0; i < 30; i++) DrawCircle(&myPoint1, i, i * 12);
// Ekrana birkaç örnek daire çiz
// Daire 1 FillCircle(100, 100, 18, 44);
// Diğer iç içe dizilmiş daireler myPoint1 = &POINT2D(96, 30); for(i = 20; i >= 0; i--)