$(document).ready(function() { $('pre code').each(function(i, block) { hljs.highlightBlock(block); }); });

Sunday, July 11, 2010

Button for graphics program















#define HOLLOW 0
#define FILLED 1
#define INACTIVE 0
#define NORMAL 1
#define ACTIVE 2
#define SETACTIVE 3

//----------------------Button functions----------------------------//
void button(int,int,int,int);
void colorbtn(int,int,int,int);
void mainbody(int,int,int);
void finishkey(int,int);
//------------------------------------------------------------------//


void CircularBar(int x1,int y1,int x2,int y2,int TYPE,int color,int border);

////-----------------------------------------------------------------//
//Save this file as 'buttons.h' in 'bin' directory of 'tc'

#include
#include"buttons.h"
char readfile[50],writefile[50];

//---------------------BUTTON FUNCTIONS--------------------------------------//
void button(int x,int y,int len,int k)
{
int i;
//Creating Buttons
for(i=0;i
{
setfillstyle(SOLID_FILL,LIGHTGRAY);
bar(x,y,x+len,y+20);
setcolor(BLACK);
rectangle(x,y,x+len,y+20);
x=x-(len+10);
}
}

void colorbtn(int a,int b,int len,int status)
{
//0=Inactive button,1=Normal Button,2=Active button,3=All time active
if(status==INACTIVE)
setcolor(DARKGRAY);
else
setcolor(BLACK);
rectangle(a,b,a+len,b+20);

if(status==SETACTIVE)
setcolor(WHITE);
else if(status==ACTIVE)
setcolor(DARKGRAY);
else
setcolor(LIGHTGRAY);
rectangle(a+1,b+1,a+(len-1),b+19);

if(status==ACTIVE)
setcolor(WHITE);
else
setcolor(LIGHTGRAY);
line(a+2,b+2,a+(len-2),b+2);
line(a+2,b+2,a+2,b+18);
line(a+3,b+3,a+(len-3),b+3);
line(a+3,b+3,a+3,b+18);

if(status==ACTIVE)
setcolor(DARKGRAY);
else
setcolor(LIGHTGRAY);
line(a+3,b+18,a+(len-3),b+18);
line(a+(len-2),b+18,a+(len-2),b+3);
}
//*******************BUTTON FUNCTIONS END HERE*************************//

//---------------------------------------------------------------------//
//*******************Circular-Edge bar function************************//
void CircularBar(int x1,int y1,int x2,int y2,int TYPE,int color,int border)
{
int len,i,j;
int x[4],y[4];
len=(y2-y1)/10;

x[0]=x2-len,y[0]=y1+len;
x[1]=x1+len,y[1]=y1+len;
x[2]=x1+len,y[2]=y2-len;
x[3]=x2-len,y[3]=y2-len;

if(TYPE==HOLLOW)
{
color=getpixel(x1-1,y1-1);
if(color==WHITE)
border=BLACK;
else
border=WHITE;
}

for(i=0;i<4;i++)
{
for(j=0;j<=len;j++)
{
if(j==len)
setcolor(border);
else
setcolor(color);
circle(x[i],y[i],j);
}
}
setcolor(border);
line(x1,y1+len,x1,y2-len);
line(x1+len,y1,x2-len,y1);
line(x2,y1+len,x2,y2-len);
line(x1+len,y2,x2-len,y2);
setfillstyle(SOLID_FILL,color);
bar(x1+1,y1+len,x2-1,y2-len);
bar(x1+len,y1+1,x2-len,y1+len);
bar(x1+len,y2-len,x2-len,y2-1);
}

///Include this file in your programs and call its functions to produce animation effects.
//Remember, u'll hav to create logic to produce animation effects as i hav done in some of my programs.

No comments:

Post a Comment

Contact Me

Name

Email *

Message *