Skip to main content

First Graphic program in C

Current semester i have a Computer Graphics as a subject.
Here is my first program that implements the
bresenham's circle drawing algorithm to draw a circle
and with some lines i created a smiley : )

#include "stdio.h"
#include "graphics.h"

void brecircle(xc,yc,r)
{

int x,y,p;
x=0;
y=r;
putpixel(xc+x,yc-y,1);

p=3-(2*r);

for(x=0;x<=y;x++)
{
if (p<0)
{
y=y;
p=(p+(4*x)+6);
}
else
{
y=y-1;

p=p+((4*(x-y)+10));
}

putpixel(xc+x,yc-y,15);
putpixel(xc-x,yc-y,15);
putpixel(xc+x,yc+y,15);
putpixel(xc-x,yc+y,15);
putpixel(xc+y,yc-x,15);
putpixel(xc-y,yc-x,15);
putpixel(xc+y,yc+x,15);
putpixel(xc-y,yc+x,15);
}
}

int main() {
  int x,y;
  int gd = DETECT, gm=0;
  initgraph(&gd,&gm,"");
  x=getmaxx()/2;
  y=getmaxy()/2;
  brecircle(x,y,150);
  brecircle(x-50,y-50,19);
  brecircle(x+50,y-50,19);
  line(x,y,x+20,y+20);
  line(x,y,x-20,y+20);
  line(x-20,y+20,x+20,y+20);
  line(x-40,y+50,x+40,y+50);
  getch();
  closegraph();
  return 0;
}

output:

Comments

Post a Comment

Popular posts from this blog

ரிதம்பாக்ஸில் ரேடியோ மிர்ச்சி

உபுண்டு 12.04ல் bansheeயை தூக்கிவிட்டு மறுபடியும் rhythmbox default இசைப்பானாக இடம்பெற்றுள்ளது. ரிதம்பாக்ஸ்ல் bansheeயை விட பல அம்சங்கள் குறைவுதான். ஏன் banshee ஐ எடுத்தார்கள் என்று  சரியாக புரியவில்லை. என்னதான் high-bitrateல் பாடல்கள் இருந்தாலும் fm கேட்பது ஒரு மகிழ்ச்சிதான். சில வருடங்களுக்கு முன்பு எங்கள் தெருக்களில் சூரியன் fm, ரேடியோ மிர்ச்சி போன்றவை தான் என்னை எழுப்பும்.

need your response

It has been a long time... my rest hours are reduced i only sleep for 5 to 6 hours a day.. so i can't post frequently.. sorry friends.. my university is a good place to refine myself. yes..! thoughts about my programming computers are refined there.. i always wanted share my experience.. but i feared of thinking that it will helpful for you or not.. most of us don't like to hear stories of others. so i stopped blogging and of course having less time.. i have earned some good friends there... who are interested in open-source technology.. very few of us only know the linux platform.. this semester mini project also in open softwares like mysql, postgrey sql i will start blogging my experience if you are interested.. regards, Mani G

உபுண்டு டெர்மினலில் இருந்து இலவசமாக sms அனுப்பலாம்

இன்று டெர்மினலில் இருந்து எப்படி இலவசமாக sms அனுப்புவது என்று பார்க்கலாம். way2sms சென்று sms அனுப்புவதற்கு அந்த தளத்தின் விளம்பரங்களை தாண்டிதான் அனுப்ப வேண்டியிருக்கிறது. விளம்பரங்களை பார்க்கமால் சுலபமாக இந்த script ஐ பயன்படுத்தி இலவசமாக sms அனுப்பலாம். இதற்கு முதலில் way2sms ன் பயனராக இருக்க வேண்டும். இல்லை என்றால way2sms.com சென்று ஒரு அக்கவுண்டினை தொடங்கிகொள்ளவும். username, password  வேண்டும்.