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

கட்டற்றமென்பொருள் பற்றிய மாத மின்இதழ்

உலகெங்கிலும் உள்ள தமிழ் மக்களுக்கு கணினிதொழில்நுட்பத்தை பற்றி அறிமுகம் செய்யும் கணியம் என்ற புதிய மாத மின்னிதழை வெளியிடுவதில் பெருமகிழ்ச்சி அடைகிறோம். கணினி கற்க ஆங்கிலம் தடையாக இருந்த காலம் மாறி தொழில்னுட்பங்கள் யாவும் தமிழில் பெருகும் இந்த காலத்தில் மென்பொருள் பற்றிய நுட்பங்களை தமிழில் வழங்குவதில் பெருமை கொள்கிறோம். இந்த இதழின் கட்டுரைகள் : கட்டற்ற மென்பொருள் லினக்ஸ் பயனர் குழு – ஓர் அறிமுகம் உபுண்டு நிறுவுதல்

அழகான ASCII எழுத்துகளை டெர்மினலில் உருவாக்க

நம்முடைய மொபைலில் ascii smsகளை பார்த்து பிறருக்கும் அனுப்பி மகிழ்ந்திருப்போம். வெறும் எழுத்துகளை வைத்துகொண்டு படங்களை உருவாக்குவது மிகவும் கடினமான காரியம். குனு/லினக்ஸில் சில டூல்கள் இது போல அழகான ASCII எழுத்துகளையும், படங்களையும் உருவாக்க நமக்கு உதவுகிறது.  FIGLET   இதனை உபுண்டுவில் நிறுவ   $ sudo apt-get install figlet என கொடுத்து நிறுவி கொள்ளவும். உங்கள் பெயரினை ascii யில் பார்க்க டெர்மினலில் $ figlet 'hello'  என கொடுத்து பாருங்கள். _          _ _       | |__   ___| | | ___  | '_ \ / _ \ | |/ _ \ | | | |  __/ | | (_) | |_| |_|\___|_|_|\___/ எப்புடி.??  அடுத்து சில படங்களை ascii யாக மாற்றுவது என பார்போம்.  இதற்கு பல டூல்கள் இருக்கின்றது. உதாரணத்திற்கு aview, jp2a jp2a நிறுவ $ sudo apt-get install jp2a எதாவது ஒரு இமேஜை மாற்ற( இமேஜ் jpg பார்மட்டில் இருக்க வேண்டும்)   $ jp2a sample.jpg இப்போது asciiஇல் தெரியும்.

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