Skip to main content

Posts

Showing posts from September, 2012

CSS Selectors

Pattern Meaning Described in section First defined in CSS level * any element Universal selector 2 E an element of type E Type selector 1 E[foo] an E element with a "foo" attribute Attribute selectors 2 E[foo="bar"] an E element whose "foo" attribute value is exactly equal to "bar" Attribute selectors 2 E[foo~="bar"] an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar" Attribute selectors 2 E[foo^="bar"] an E element whose "foo" attribute value begins exactly with the string "bar" Attribute selectors 3 E[foo$="bar"] an E element whose "foo" att...

Creating arrow edges using CSS

Before we start, we have to understand the concept behind  " border " Basically, borders render like this: #sampleStyle{ border-top : 25px solid #a71d95; border-right : 25px solid #1da2a7; border-bottom: 25px solid #70a71d; border-left : 25px solid #c10902; width :60px; heigth:60px; } If we compress the content area, i.e) make width and height values to "0px" #sampleStyle{ border-top : 25px solid #a71d95; border-right : 25px solid #1da2a7; border-bottom: 25px solid #70a71d; border-left : 25px solid #c10902; width :0px; heigth:0px; } If we want right arrow , make all  border-color  except  border-left-color  to  transparent #sampleStyle{ border-top : 25px solid #a71d95; border-right : 25px solid #1da2a7; border-bottom: 25px solid #70a71d; border-left : 25px solid #c10902; width :0px; heigth:0px; } Example: .arrow_box { position: relative; ...

Personal Diary - A Mini Project Written in Turbo C With Graphical Interface

A Simple Personal Diary written in Turbo C with Graphical User Interface Features, Birthday Reminder Notes Address Book The main part of the project is UI 'GUI.h' header file includes texbox, message-box and more custom graphical functions  ' Dairy.h' header file includes functionality of Personal Dairy ' Dairyload.c' includes loadingscreen, login screen, installation check etc 'Dairy.c' - execution stats here

3D Projection

I hope you will remember  engineering graphics in your first year of engineering, This basic idea will be useful in understanding the concept.  Usually projection is nothing but the representation of a 3D object in a 2D form with the angle we view. Basically we represent a 3D object in a 2D form with three basic views Front View Top View Side View In the following code, the user is asked to enter the co-ordinates for a 2D object and with the depth we enter it will generate a 3D object. For example , consider a cube - the view you see without a depth will be a square. Note: In computer graphics the co-ordinates start from top-left (0,0) of your screen CODE : #include <stdio.h> #include <stdlib.h> #include <graphics.h> #include <conio.h> int ARRAY_SIZE; int array_max(int *arr, int returnIndex); int array_min(int *arr, int returnIndex); void draw3d(int sides, int *x, int *y, int depth); void drawFrontView(int sides, int *x, int *y);...

3D Rotation

#include <stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> #include<math.h> void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d); void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d) { int i,j,k=0; for(j=0;j<2;j++) { for(i=0;i<fs;i++) { if(i!=fs-1) { line(x[i]+tx+k,y[i]+ty-k,x[i+1]+tx+k,y[i+1]+ty-k); } else line(x[i]+tx+k,y[i]+ty-k,x[0]+tx+k,y[0]+ty-k); } k=d; } for(i=0;i<fs;i++) { line(x[i]+tx,y[i]+ty,x[i]+tx+d,y[i]+ty-d); } } void main() { int gd=DETECT,gm; int x[20],y[20],x1[20],y1[20],tx=0,ty=0,i,j,k,fs,temp,d,a; float theta; initgraph(&gd,&gm,""); printf("No of sides (front view only) : "); scanf("%d",&fs); printf("Co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } printf("Depth :"); scanf("%d",&d); draw3d(fs,x,y,tx,ty,d); printf("translation (x,y),rotate...

3D Scaling

#include <stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> #include<math.h> void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d); void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d) { int i,j,k=0; for(j=0;j<2;j++) { for(i=0;i<fs;i++) { if(i!=fs-1) line(x[i]+tx+k,y[i]+ty-k,x[i+1]+tx+k,y[i+1]+ty-k); else line(x[i]+tx+k,y[i]+ty-k,x[0]+tx+k,y[0]+ty-k); } k=d; } setfillstyle(1,15); for(i=0;i<fs;i++) { line(x[i]+tx,y[i]+ty,x[i]+tx+d,y[i]+ty-d); } } void main() { int gd=DETECT,gm; int x[20],y[20],x1[20],y1[20],tx=0,ty=0,i,j,k,fs,temp,d,xm,ym; float theta; initgraph(&gd,&gm,""); printf("no of sides (front view only) : "); scanf("%d",&fs); printf("co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } printf("Depth :"); scanf("%d",&d); draw3d(fs,x,y,tx,ty,d); printf("magni...

3D Translation

#include <stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d); void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d) { int i,j,k=0; for(j=0;j<2;j++) { for(i=0;i<fs;i++) { if(i!=fs-1) line(x[i]+tx+k,y[i]+ty-k,x[i+1]+tx+k,y[i+1]+ty-k); else line(x[i]+tx+k,y[i]+ty-k,x[0]+tx+k,y[0]+ty-k); } k=d; } for(i=0;i<fs;i++) { line(x[i]+tx,y[i]+ty,x[i]+tx+d,y[i]+ty-d); } } void main() { int gd=DETECT,gm; int x[20],y[20],tx=0,ty=0,i,fs,d; initgraph(&gd,&gm,""); printf("no of sides (front view only) : "); scanf("%d",&fs); printf("co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } printf("Depth :"); scanf("%d",&d); draw3d(fs,x,y,tx,ty,d); printf("translation (x,y)"); scanf("%d%d",&tx,&ty); draw3d(fs,x,y,tx,ty,d);...

2D Shearing

#include <stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> #include<math.h> void draw2d(int,int [],int [],int,int); void main() { int gd=DETECT,gm; int x[20],y[20],x1[20],y1[20],tx=0,ty=0,i,fs,a; initgraph(&gd,&gm,""); printf("No of sides : "); scanf("%d",&fs); printf("Co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } draw2d(fs,x,y,tx,ty); printf("translation (x,y) : "); scanf("%d%d",&tx,&ty); while(1) { clrscr(); cleardevice(); printf("1. X Shear\n\n2. Y Shear\n\n3. Exit\n\n"); draw2d(fs,x,y,0,0); switch(getche()) { case '1': printf("X Shear Value : "); scanf("%d",&a); for(i=0;i<fs;i++) { x1[i]=x[i]+(a*(y[i]-ty)); y1[i]=y[i]; } break; case '2': printf("Y Shear Value : "); scanf("%d",&a); for(i=0;i<fs;i++)...

2D Scaling

#include<stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> #include<math.h> void draw2d(int,int [],int [],int,int); void main() { int gd=DETECT,gm; int x[20],y[20],tx=0,ty=0,i,fs; int mx,my; initgraph(&gd,&gm,""); printf("No of sides : "); scanf("%d",&fs); printf("Co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } draw2d(fs,x,y,tx,ty); printf("magnification (x,y) : "); scanf("%d%d",&mx,&my); for(i=0;i<fs;i++) { x[i]=x[i]*mx; y[i]=y[i]*my; } draw2d(fs,x,y,tx,ty); getch(); } void draw2d(int fs,int x[20],int y[20],int tx,int ty) { int i; for(i=0;i<fs;i++) { if(i!=(fs-1)) line(x[i]+tx,y[i]+ty,x[i+1]+tx,y[i+1]+ty); else line(x[i]+tx,y[i]+ty,x[0]+tx,y[0]+ty); } }

2D Rotation

#include <stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> #include<math.h> void draw2d(int,int [],int [],int,int); void main() { int gd=DETECT,gm; int x[20],y[20],x1[20],y1[20],tx=0,ty=0,i,fs,a; float theta; initgraph(&gd,&gm,""); printf("No of sides : "); scanf("%d",&fs); printf("Co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } draw2d(fs,x,y,tx,ty); printf("translation (x,y), Angle : "); scanf("%d%d%d",&tx,&ty,&a); theta=(float)(a*(3.14/180)); for(i=0;i<fs;i++) { x1[i]=tx+((x[i]-tx)*cos(theta))-((y[i]-ty)*sin(theta)); y1[i]=ty+((y[i]-ty)*cos(theta))+((x[i]-tx)*sin(theta)); } draw2d(fs,x1,y1,tx,ty); getch(); } void draw2d(int fs,int x[20],int y[20],int tx,int ty) { int i; for(i=0;i<fs;i++) { if(i!=(fs-1)) line(x[i]+tx,y[i]+ty,x[i+1]+tx,y[i+1]+ty); else line(x[i]+tx,y[i]+ty,...

2D Reflection

#include <stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> #include<math.h> void draw2d(int,int [],int [],int,int); void main() { int gd=DETECT,gm; int x[20],y[20],x1[20],y1[20],tx=0,ty=0,i,fs; initgraph(&gd,&gm,""); printf("No of sides : "); scanf("%d",&fs); printf("Co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } draw2d(fs,x,y,tx,ty); printf("translation (x,y) : "); scanf("%d%d",&tx,&ty); while(1) { clrscr(); cleardevice(); printf("1. X Reflection\n\n2. Y Reflection\n\n3. Exit"); draw2d(fs,x,y,0,0); switch(getche()) { case '1': for(i=0;i<fs;i++) { x1[i]=(tx+((x[i]-tx)*cos(M_PI))-((y[i]-ty)*sin(M_PI))); y1[i]=y[i]; } break; case '2': for(i=0;i<fs;i++) { x1[i]=x[i]; y1[i]=(tx+((y[i]-ty)*cos(M_PI))+((x[i]-tx)*sin(M_PI))); } break; case '3': close...