Загрузка...

Функция, рисующая амперметр


void ampermetr(int x1,int y1,int x2,int y2){

int x3,y3;

switch(pozition(x1,y1,x2,y2)){

case 1:

if(x2>x1){

y2=y1;

x3=x1+(x2-x1)/2;

line(x1,y1,x3-10,y1);

line(x3+10,y2,x2,y2);

circle(x3,y1,10);

outtextxy(x3-3,y1-3,"A");

}

if(x2<x1){

x3=x2+(x1-x2)/2;

y2=y1;

line(x2,y2,x3-10,y2);

line(x3+10,y1,x1,y2);

circle(x3,y2,10);

outtextxy(x3-3,y2-3,"A");

}

break;

case 2:

if(y1<y2){

y3=y1+(y2-y1)/2;

x2=x1;

line(x1,y1,x1,y3-10);

line(x1,y3+10,x2,y2);

circle(x1,y3,10);

outtextxy(x1-3,y3-3,"A");

}

if(y1>y2){

y3=y2+(y1-y2)/2;

x2=x1;

line(x1,y1,x1,y3+10);

line(x2,y3-10,x2,y2);

circle(x1,y3,10);

outtextxy(x1-3,y3-3,"A");

}

break;

case 3:

if(x2>x1){

y2=y1-(x2-x1);

x3=x1+(x2-x1)/2;

y3=y1+(y2-y1)/2;

line(x1,y1,x3-7,y3+7);

line(x3+7,y3-7,x2,y2);

circle(x3,y3,10);

outtextxy(x3-3,y3-3,"A");

}

if(x2<x1){

y2=y1+(x1-x2);

x3=x2+(x1-x2)/2;

y3=y1+(y2-y1)/2;

line(x1,y1,x3+7,y3-7);

line(x3-7,y3+7,x2,y2);

circle(x3,y3,10);

outtextxy(x3-3,y3-3,"A");

}

break;

case 4:

if(x2>x1){

y2=y1+(x2-x1);

x3=x1+(x2-x1)/2;

y3=y1+(y2-y1)/2;

line(x1,y1,x3-7,y3-7);

line(x3+7,y3+7,x2,y2);

circle(x3,y3,10);

outtextxy(x3-3,y3-3,"A");

}

if(x2<x1){

y2=y1-(x1-x2);

x3=x2+(x1-x2)/2;

y3=y2+(y1-y2)/2;

line(x1,y1,x3+7,y3+7);

line(x3-7,y3-7,x2,y2);

circle(x3,y3,10);

outtextxy(x3-3,y3-3,"A");

}

break;

}

}

Загрузка...