my problems is all about c++ in computer graphics, this is the following problems:
1. Create a program that plots random colors,lines and position
2. Create a program that plots random rectangles,colors and size
3. Create a program that plots random circles,colors and size
i have already the sample psedocode, just edit some parts of the program.
#define WORD unsigned short
#define DWORD unsigned long
#define VIDEO_SEG 0xA000
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
void GMode()
{
union REGS regs;
regs.h.ah=0x00;
regs.h.al=0x13;
int86(0x10,®s,®s);
}
void TMode()
{
union REGS regs;
regs.h.ah=0x00;
regs.h.al=0x03;
int86(0x10,®s,®s);
}
int Plot (int x,int y,int color)
{
union REGS regs;
regs.h.ah=0x0C;
regs.h.al=color;
regs.x.cx=x;
regs.x.dx=y;
int86(0x10,®s,®s);
return 0;
}
void PutPixel( WORD x, WORD y, BYTE color )
{
asm {
mov di,VIDEO_SEG
mov es,di
mov ax,320
mul [y]
add ax,[x]
mov di,ax
mov al,[color]
mov es:[di],al
}
}
void plotpixel(int x1,int x2, int y2, BYTE color)
{
int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py,y1,vga;
dx=x2-x1;
dy=y2-y1;
dxabs=abs(dx);
dyabs=abs(dy);
sdx=sgn(dx);
sdy=sgn(dy);
x=dyabs>>1;
y=dyabs>>1;
px=x1;
py=y1;
VGA[(py<<8)+(py<<6)+px]=color;
if(dxabs>=dyabs)
{
for(i=0;i<dxabs;i++)
{
y+=dyabs;
if(y>=dxabs)
{
y-=dxabs;
py+=sdy;
}
px+=sdx;
put_pixel(px,py,color);
}
}
else
{
for(i=0;i<dyabs;i++)
{
x+=dxabs;
if(x>dyabs)
{
x-=dyabs;
px+=sdx;
}
py+=sdy;
plot_pixel(px,py,color);
}
}
}
You can remake the program as long it prints what question is given
stated above. I ned this 3 program after 2 days plz help me and also
add comments in each lines in order for me to understand every lines.
Advance ty il check this tommorow. |