Những bài DEMO của sinh viên khóa 2017 phần 1

1459

MÔN KỸ THUẬT ĐỒ HỌA MÁY TÍNH

  • Chúng ta sẽ học…
    Các thuật toán đồ họa và lập trình đồ họa
    Các cấu trúc dữ liệu đồ họa
    Màu sắc và sức nhìn của con người(human vision)
    Một số mô hình hình học–các mô hình và hiển thị
  • Đây là một môn Tin học!

BÀI DEMO CỦA SINH VIÊN KHÓA 2017 PHẦN 1

Sinh viên: Lê Trần Phước Đức
============ @@@ =========== 
#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <dos.h>
void DrawBackground(int color1, int color2)
{
 
    setfillstyle(1,color1);
    bar(0,0,2000,500);
 
    setfillstyle(1,color2);
    bar(0,500,2000,1000);
	
}
void VeRao1(int color)
{
	setfillstyle(1,color);
	bar(0,600,800,500);
	setfillstyle(1,color);
	bar(1000,600,1800,500);
	rectangle(0,600,800,500);
	rectangle(1000,600,1800,500);
}
void ThanNha1(int color)
{
	setfillstyle(1,color);
	bar(300,300,1200,550);
	setfillstyle(1,color);
	bar(400,100,1150,250);
	rectangle(300,300,1200,550);
	rectangle(400,100,1150,250);

}
void Bancong(int color)
{
	setfillstyle(1,color);
	bar(250,250,1250,300);
	rectangle(250,250,1250,300);
}
void CuaChinh(int color)
{
	setfillstyle(1,color);
	bar(850,400,950,550);
	rectangle(850,400,950,550);
}
void CuaSo1(int color)
{
	setfillstyle(1,color);
	bar(350,350,480,450);
	setfillstyle(1,color);
	bar(500,350,630,450);
	rectangle(350,350,480,450);
	rectangle(500,350,630,450);
}
void MaiNha(int color)
{
	int poly2[]={350,0,350,100,1200,100,0,1100};
	setfillstyle(1,color);
	fillpoly(3,poly2);
}
void HangCuaSo(int color)
{
	setfillstyle(1,color);
	bar(430,130,550,220);
	setfillstyle(1,color);
	bar(580,130,700,220);
	setfillstyle(1,color);
	bar(730,130,850,220);
	setfillstyle(1,color);
	bar(900,130,1100,250);
	rectangle(430,130,550,220);
	rectangle(580,130,700,220);
	rectangle(730,130,850,220);
	rectangle(899,129,1099,249);
}
void DrawSun()
{
 
    int r = 40;
    setfillstyle(1,12);
    fillellipse(10,20,r,r);
}
void DrawStar(int color)
{
	for(int i=0;i<=10000;i++)
	{
		putpixel(rand()%1920, rand()%550, color);
	}
	int r = 60;
    setfillstyle(1,color);
    fillellipse(1300,100,r,r);
}
void Buiram(int color1, int color2)
{
	int r;
	setfillstyle(1,color1);
	pieslice(100,450,0,180,100);
	setfillstyle(1,color1);
	pieslice(100,400,0,180,100);
	setfillstyle(1,color1);
	pieslice(100,350,0,180,100);
	setfillstyle(1,color2);
	bar(70,450,130,500);
}
void DrawClouds(int color)
{
	
}
void Chiacua()
{
	line(1000,130,1000,250);
}
int main(void)
{
	initwindow(1920,1080);
	//Ban Ngay
	DrawBackground(11,10);
	ThanNha1(14);
	Bancong(9);
	VeRao1(7);
	CuaChinh(3);
	CuaSo1(3);
	MaiNha(12);
	HangCuaSo(3);
	DrawSun();
	Chiacua();
	Buiram(10,6);
	delay(3000);
	//Ban Dem
	DrawBackground(0,2);
	DrawStar(14);
	ThanNha1(6);
	Bancong(8);
	VeRao1(8);
	CuaChinh(14);
	CuaSo1(14);
	MaiNha(4);
	HangCuaSo(14);
	Chiacua();
	Buiram(2,6);
	delay(30000000);
	closegraph();
}
Sinh viên: Mạch Chí Lập
========= @@@ =========
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include<iostream>
#define PI 3.14
using namespace std;
float d2r (int d)
{
    return d*PI/180.0;
}
int main()
{
    initwindow(640,480);
    int xc = 320, yc = 240, r = 200;
    int d = 270;
    settextstyle(3,0, 3);
    outtext("DH17TIN02      MachChiLap");
    while(1){
        for(int i = 0; i<=5;i++)
		{
            int x = xc + (int)(r * cos(d2r(d)));
            int y = yc + (int)(r * sin(d2r(d)));
            if (i == 0)
                moveto(x,y);
            else
                lineto(x,y);
            d+=120;
            setcolor(i+1);
        }
        d+=5;
        delay(200);
    }
    getch();
    return 0;
}
Sinh viên: Nguyễn Hoàng Tấn Cường
=========== @@@ ================
#include <conio.h>
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#include <math.h>
#include <stdio.h>

float t = 0.0;
float x, y,g,h;
int nx,ny;
int k = 1;
void dc()
{
  line(x+130, y-110, getmaxx()-83,35);
}

void dt()
{
  line(getmaxx()-33,h-285,getmaxx()-33,h-240);
}

void quay()
{
  int x1, y1, x2, y2;
  circle(getmaxx()-60, 50, 26);
  x1 = getmaxx()-60 - 26 * cos(t);
  y1 = 50 - 26 * sin(t);
  x2 = getmaxx()-60 + 26 * cos(t);
  y2 = 50 + 26 * sin(t);
  line(x1, y1, x2, y2);
}



void xe()
{
  line(x-50,y+30,x-15,y+6);
  line(x-50,y+30,x-75,y-40);
  line(x-75,y-40,x+45,y-120);
  line(x+45,y-120,x+70,y-50);
  line(x+70,y-50,x+13,y-11);

  line(x+70,y-50,x+85,y-60);
  line(x+113,y-79,x+134,y-94);
  line(x+134,y-94,x+115,y-144);
  line(x+115,y-144,x+52,y-100);
}
void chu()
{
  //ve M
  line(x-45,y-10,x-50,y-25);
  line(x-50,y-25,x-41,y-18);
  line(x-41,y-18,x-39,y-32);
  line(x-39,y-32,x-34,y-17);
  //ve E
  line(x-31,y-19,x-36,y-34);
  line(x-36,y-34,x-30,y-38);
  line(x-35,y-27,x-29,y-31);
  line(x-31,y-19,x-25,y-23);
  //ve R
  line(x-22,y-25,x-27,y-40);
  line(x-27,y-40,x-21,y-41);
  line(x-21,y-41,x-19,y-35);
  line(x-19,y-35,x-24,y-30);
  line(x-24,y-30,x-17,y-28);
  //ve C
  line(x-14,y-30,x-8,y-34);
  line(x-14,y-30,x-19,y-45);
  line(x-19,y-45,x-13,y-49);

  line(x-5,y-36,x-10,y-51);
  line(x-10,y-51,x-4,y-55);
  line(x-9,y-44,x-3,y-48);
  line(x-5,y-36,x+1,y-40);
  //ve D
  line(x+4,y-42,x-2,y-57);
  line(x-2,y-57,x+5,y-59);
  line(x+5,y-59,x+9,y-48);
  line(x+3,y-42,x+9,y-48);
  //ve E
  line(x+12,y-49,x+7,y-62);
  line(x+7,y-63,x+13,y-67);
  line(x+8,y-56,x+14,y-60);
  line(x+12,y-48,x+18,y-52);
  //ve C
  line(x+21,y-54,x+27,y-58);
  line(x+21,y-54,x+16,y-69);
  line(x+16,y-69,x+22,y-73);


}

void chunhat()
{
  line(getmaxx()-53,h-240,getmaxx()-13,h-240);
  line(getmaxx()-53,h-240,getmaxx()-53,h-150);
  line(getmaxx()-53,h-150,getmaxx()-13,h-150);
  line(getmaxx()-13,h-150,getmaxx()-13,h-240);
}
void vebanhxe(float a,float b)
{
  int x1, y1, x2, y2;
  circle(a, b, 15);
  x1 = a - 15 * cos(t);
  y1 = b - 15 * sin(t);
  x2 = a + 15 * cos(t);
  y2 = b + 15 * sin(t);
  line(x1, y1, x2, y2);
    
}

int main()
{
  initwindow(650,900);
 outtextxy(50,100,"Nguyen Hoang Tan Cuong");

  line(getmaxx()-100,91,getmaxx()-82,67);
  line(76, 400, getmaxx()-100,91);
  line(76, 400, getmaxx()-100,400);
  line(getmaxx()-100,400,getmaxx()-100,91);
  x = 135;
  y = 340;
  h = y;
  g = k;
  while (!kbhit())
  {
     setcolor(YELLOW);
     vebanhxe(x,y);vebanhxe(x+100,y-68);chu();
     setcolor(BLUE);quay();
     xe(); chu();
     setcolor(RED);
     chunhat(); chu();
     setcolor(GREEN);
     dc();dt();
     delay(25);
     setcolor(BLACK);
     xe(); chu();
     vebanhxe(x,y);vebanhxe(x+100,y-68);      chunhat();dc();quay();
     t += 0.09 * (float)k;
     x += k;
     y -=k/1.5;
     h += g;
     if (x > (getmaxx() - 250 - 2) || x < 135)
     {
	 k = -k;
     }
     if (h >345 + 247 || h < 340  )
     {
	 g = -g;
     }
  }
  getch();
  closegraph();
  return 0;
}
Còn tiếp >>

BÌNH LUẬN

Vui lòng nhập bình luận của bạn
Vui lòng nhập tên của bạn ở đây