Showing posts with label GRAPHICS. Show all posts
Showing posts with label GRAPHICS. Show all posts

Wednesday, July 4, 2012

72. FRACTAL EXPLORER IN JAVA




import java.awt.*;
import java.applet.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;


public class Fractal extends Applet implements ActionListener, MouseListener, MouseMotionListener, 
AdjustmentListener, KeyListener, DocumentListener {
public static final int X = 800, Y = 550, ButX=72, ButY=26;
public static final int Min_Iter=0, Max_Iter=10000, SL_phMAX=200, SL_peMAX=400, Max_Fractal=6;
public static final double STX[]={ -2.7, -2.3, -2.5, -2.2, -5.2, 2.98 };

Tuesday, July 3, 2012

68. MIDPOINT SUBDIVISION LINE CLIPPING


//MIDPOINT SUBDIVISION LINE CLIPPING 
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<math.h>
#include<graphics.h>
typedef struct coordinate
{
int x,y;
char code[4];
}PT;
void drawwindow();
void drawline (PT p1,PT p2,int cl);
PT setcode(PT p);

Sunday, July 1, 2012

67. THICK LINE DRAWING



//THICK LINE DRAWING
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd = DETECT, gm  ;
float wy, wx, x1, y1, x2, y2;
int i, thickness;
initgraph(&gd, &gm, "C:\\TC\\BGI");
printf("Enter the co-ordinates for the line:\n");
printf("X1: ");

66. SIERPINSKI TRIANGLE IN C


//SIERPINSKI TRIANGLE IN C
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <math.h>
#include <graphics.h>
void DrawSierpinski(void);
void main(void)
{
int gd=VGA;
int gm=VGAHI;
initgraph(&gd, &gm, "C:\\tc\\bgi");
DrawSierpinski();
getch();
}

65. MANDELBROT SET IN C


#include <stdio.h>
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <alloc.h> 
int MX, MY; 
int MC; /* max color */
void init( void )
{
  int gd = 0, gm = VGALO;
  initgraph( &gd, &gm, "c:\\tc\\bgi");
} 
void initPalette( void )
{ int i;

Saturday, June 30, 2012

64. DDA LINE DRAWING


//DDA LINE DRAWING
#include<stdio.h>
#include<graphics.h>
#include<math.h>
main()
{
float x,y,x1,y1,x2,y2,dx,dy,length;
int i,gd,gm;
clrscr();
printf("Enter the value of x1 :\t");
scanf("%f",&x1);
printf("Enter the value of y1 :\t");
scanf("%f",&y1);

63. BRESENHAM LINE DRAWING


//BRESENHAM LINE DRAWING
#include<stdio.h>
#include<graphics.h>
#include<math.h>
main()
{
float x,y,x1,y1,x2,y2,dx,dy,e;
int i,gd,gm;
clrscr();
printf("Enter the value of x1 :\t");
scanf("%f",&x1);
printf("Enter the value of y1 :\t");
scanf("%f",&y1);
printf("Enter the value of x2 :\t");
scanf("%f",&x2);

Wednesday, June 27, 2012

59. DDA CIRCLE DRAWING IN C


//DDA CIRCLE DRAWING
#include<stdio.h>
#include<graphics.h>
#include<math.h>
main()
{
float x1,y1,x2,y2,startx,starty,epsilon;
int gd,gm,i,val,cx,cy;
int r;
clrscr();
clrscr();
printf("Enter the center coordinates of a circle :"); 
scanf("%d%d",&cx,&cy); 
clrscr();

58. BEIZER CURVE IN C


//BEIZER CURVE
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int x,y,z;
void main()
{
float u;
int gd,gm,ymax,i,n,c[4][3];
for(i=0;i<4;i++) { c[i][0]=0; c[i][1]=0; }
printf("\n\n Enter four points : \n\n");
for(i=0; i<4; i++)
{
printf("\t X%d Y%d : ",i,i);
scanf("%d %d",&c[i][0],&c[i][1]);
}

Tuesday, June 26, 2012

57. LIANG BARSKY LINE CLIPPING


//LIANG BARSKY LINE CLIPPING
#include<graphics.h>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int gd, gm ;
int x1 , y1 , x2 , y2 ;
int wxmin,wymin,wxmax, wymax ;
float u1 = 0.0,u2 = 1.0 ;
int p1 , q1 , p2 , q2 , p3 , q3 , p4 ,q4 ;
float r1 , r2 , r3 , r4 ;
int x11 , y11 , x22 , y22 ;
clrscr();
printf("Enter the windows left xmin , top boundry ymin\n");
scanf("%d%d",&wxmin,&wymin);
printf("Enter the windows right xmax ,bottom boundry ymax\n");
scanf("%d%d",&wxmax,&wymax);

56. COHEN SUTHERLAND LINE CLIPPING


//COHEN SUTHERLAND LINE CLIPPING
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<graphics.h>
typedef struct coordinate
{
int x,y;
char code[4];
}PT;
void drawwindow();
void drawline (PT p1,PT p2,int cl);
PT setcode(PT p);
int visibility (PT p1,PT p2);
PT resetendpt (PT p1,PT p2);
main()
{

55. SUTHERLAND HODGEMAN POLYGON CLIPPING


//SUTHERLAND HODGEMAN POLYGON CLIPPING
#include<stdio.h>
#include<graphics.h>
#include<math.h>
typedef struct
{
float x;
float y;
}PT;
int n;
main()
{
int i,j,gd,gm;
PT d,p1,p2,p[20],pi1,pi2,pp[20];
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"");
printf("Enter coordinates (left,top) of point1 : ");
scanf("%f%f",&p1.x,&p1.y);
printf("Enter coordinates (right,bottom) of point2 : ");
scanf("%f%f",&p2.x,&p2.y);
printf("Enter the number of vertex : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{

54. FLOOD FILL & BOUNDARY FILL ALGORITHM


//FLOOD FILL WITH EIGHT CONNECTED REGIONS
#include<stdio.h>
#include<graphics.h>
main()
{
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
rectangle(50,50,100,100);
flood(55,55,4,15);
getch();
closegraph();
}
flood(seed_x,seed_y,foreground_col,background_col)
{

53. MIDPOINT CIRCLE DRAWING


//MIDPOINT CIRCLE
#include<stdio.h>
#include<graphics.h>
#include<math.h>
main()
{
float d;
int gd,gm,x,y,cy,cx;
int r;
clrscr();
printf("Enter the center coordinates of a circle :"); 
scanf("%d%d",&cx,&cy); 
clrscr();
printf("Enter the radius of a circle :");
scanf("%d",&r);
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TC\\BGI");
x = 0;
y = r;

52. BRESENHAM CIRCLE DRAWING


//BRESENHAM CIRCLE
#include<stdio.h>
#include<graphics.h>
#include<math.h>
main()
{
float d;
int gd,gm,x,y,cy,cx;
int r;
clrscr();
printf("Enter the center coordinates of a circle :");
scanf("%d%d",&cx,&cy);
clrscr();
printf("Enter the radius of a circle :");
scanf("%d",&r);
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TC\\BGI");
x = 0;
y = r;

Monday, June 25, 2012

46. KOCH CURVE GENERATOR IN JAVA


//KOCH CURVE GENERATOR
import java.awt.*;
import java.awt.event.*;
public class Koch extends Frame
{  public static void main(String[] args){new Koch();}
   Koch()
   {  super("Koch. Click the mouse button to increase the level");
      addWindowListener(new WindowAdapter()
         {public void windowClosing(
                 WindowEvent e){System.exit(0);}});
      setSize (600, 500);
      add("Center", new CvKoch());
      show();
    }
}

Sunday, June 24, 2012

39. CONVERSION OF COLOR MODELS


//CONVERSION OF COLOR MODELS
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float r,g,b,y,i,c,m,h,s,v;
int ch;
clrscr();
do
{

38. 2D REFLECTION & SHEAR IN C


//2D REFLECTION & SHEAR
#include<stdio.h>
#include<process.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void disp(int n,float c[][3])
{
float maxx,maxy;
int i;
maxx=getmaxx();
maxy=getmaxy();
maxx=maxx/2;
maxy=maxy/2;
i=0;
while(i<n-1)
{

37. 2D TRANSFORMATIONS IN C


//2D TRANSFORMATIONS
#include<stdio.h>
#include<process.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void disp(int n,float c[][3])
{
float maxx,maxy;
int i;
maxx=getmaxx();
maxy=getmaxy();
maxx=maxx/2;
maxy=maxy/2;
i=0;

36. MIDPOINT ELLIPSE DRAWING ALGORITHM

//MIDPOINT ELLIPSE DRAWING ALGORITHM
#include<stdio.h>
#include<graphics.h>
#include<math.h>
main()
{
long d1,d2;
int i,gd,gm,x,y;
long rx, ry, rxsq,rysq,tworxsq,tworysq,dx,dy;
/* Read the radius x and y
---------------------------- */
printf("Enter the x radius of the ellipse :");
scanf("%ld",&rx);
printf("Enter the y radius of the ellipse :");
scanf("%ld",&ry);