📄 n6100.c
字号:
if(num>ystop){
num--;
continue;
}
else return;
}
else if(ystart<ystop){
if(num<ystop){
num++;
continue;
}
else return;
}
}
}
for(num=xstart;;){
ilong=ystart+((num-xstart)*deline);
setBox(num,num,ilong,ilong);
//write(ForGroundColor,DATA);
//write(ForGroundColor,DATA);
write(HighByte(ForGroundColor),DATA);
write(LowByte(ForGroundColor),DATA);
if(xstart>xstop){
if(num>xstop){
num--;
continue;
}
else return;
}
else if(xstart<xstop){
if(num<xstop){
num++;
continue;
}
else return;
}
}
}
void _N6100::circle(int xstart,int ystart,int radius,float linewidth){
int x,y,xx,yy,rr1,rr2;
float result;
for(x=xstart-radius;x<=xstart+radius;x++)
for(y=ystart-radius;y<=ystart+radius;y++){
xx=(x-xstart);
yy=(y-ystart);
result=xx*xx+yy*yy;
xx=(radius-linewidth);
yy=(radius+0.5);
rr1=xx*xx;
rr2=yy*yy;
if(result>=rr1&&result<=rr2){
setBox(x,x,y,y);
//write(ForGroundColor,DATA);
//write(ForGroundColor,DATA);
write(HighByte(ForGroundColor),DATA);
write(LowByte(ForGroundColor),DATA);
}
}
}
void _N6100::rectangle(int xstart,int ystart,int width,int height,unsigned char fill){
int i=width*height;
setBox(xstart,xstart+width-1,ystart,ystart+height-1);
while(i--){
write(fill,DATA);
write(fill,DATA);
}
}
void _N6100::setBox(int xstart,int xstop,int ystart,int ystop){
write(ROWSET,COMMAND);
write(ystart,DATA);
write(ystop,DATA);
write(CLUSET,COMMAND);
write(xstart,DATA);
write(xstop,DATA);
write(RAMWRITE,COMMAND);
}
void _N6100::clear(){
int size=17150;
write(ROWSET,COMMAND);
write(0,DATA);
write(131,DATA);
write(CLUSET,COMMAND);
write(0,DATA);
write(131,DATA);
write(RAMWRITE,COMMAND);
//setBox(0,0,131,131);
while(size--){
//write(ScrGroundColor,DATA);
//write(ScrGroundColor,DATA);
write(HighByte(ScrGroundColor),DATA);
write(LowByte(ScrGroundColor),DATA);
}
}
_N6100::_N6100(unsigned int BackGroundColor,unsigned int ForGroundColor,unsigned int ScrGroundColor){
xcurrent=2;
ycurrent=2;
this->BackGroundColor=BackGroundColor;
this->ForGroundColor=ForGroundColor;
this->ScrGroundColor=ScrGroundColor;
alignment=left;
precision=10000;
init();
//clear();
}
_N6100 & _N6100::operator <<(char *str){
printf(0.1,str);
return *this;
}
_N6100 & _N6100::operator <<(int num){
printf(0.1,itoa(num));
return *this;
}
_N6100 & _N6100::operator <<(float num){
char *str=new char[11];
int i=(int)num;
int n=(int)((num-i)*precision);
strcpy(str,itoa(i));
if(precision){
strcat(str,".");
strcat(str,itoa(n));
}
printf(0.1,str);
delete str;
return *this;
}
_N6100 & _N6100::operator <<(Point point){
setBox(point.x,point.x,point.y,point.y);
//write(ForGroundColor,DATA);
//write(ForGroundColor,DATA);
write(HighByte(ForGroundColor),DATA);
write(LowByte(ForGroundColor),DATA);
return *this;
}
_N6100 & _N6100::operator <<(Line lin){
line(lin.xstart,lin.ystart,lin.xstop,lin.ystop);
return *this;
}
_N6100 & _N6100::operator <<(WaveLine wavlin){
int height=0;
int i=0;
bool add=false;
while(i<wavlin.length){
if(!wavlin.vertical)
*this<<Point(wavlin.xstart+height,wavlin.ystart+i);
else
*this<<Point(wavlin.xstart+i,wavlin.ystart+height);
//*this<<Point(wavlin.xstart+i,wavlin.ystart);
if(height==wavlin.height)
add=false;
else if(height==-wavlin.height)
add=true;
height+=add?1:-1;
i+=1;
}
return *this;
}
_N6100 & _N6100::operator <<(Rectangle rec){
if(!rec.fillcolor)
rectangle(rec.xstart,rec.ystart,rec.width,rec.height,ForGroundColor);
else
rectangle(rec.xstart,rec.ystart,rec.width,rec.height,rec.fillcolor);
if(rec.linewidth)
rectangle(rec.xstart+rec.linewidth,rec.ystart+rec.linewidth,rec.width-rec.linewidth-rec.linewidth,rec.height-rec.linewidth-rec.linewidth,ScrGroundColor);
return *this;
}
_N6100 & _N6100::operator <<(Circle cir){
circle(cir.xstart,cir.ystart,cir.radius,cir.linewidth);
return *this;
}
_N6100 & _N6100::operator <<(set setp){
switch(setp.name){
case ForGColor:this->ForGroundColor=setp.color;break;
case BackGColor:this->BackGroundColor=setp.color;break;
case XCurrent:this->xcurrent=setp.position;break;
case YCurrent:this->ycurrent=setp.position;break;
case ScrGColor:this->ScrGroundColor=setp.color;break;
case Left:this->alignment=left;break;
case Right:this->alignment=right;break;
case Center:this->alignment=center;break;
case Precision:this->precision=setp.color;
}
return *this;
}
_N6100 & _N6100::operator <<(invalidate inv){
rectangle(inv.xstart,inv.ystart,inv.width,inv.height,this->ScrGroundColor);
return *this;
}
_N6100 & _N6100::operator <<(char ch){
char str[]={ch,0};
printf(0.1,str);
return *this;
}
_N6100 & _N6100::operator >>(char *str){
strcpy(buffer.buffer,str);
return *this;
}
_N6100 & _N6100::operator <<(_N6100 *str){
printf(0.1,buffer.buffer);
return *this;
}
void _N6100::waveLine(){
int x;
int y;
*this<<Point(10,10);
for(x=0;x<100;x++){
y=pow(x,2)/100;
setBox(x,x,y,y);
//write(ForGroundColor,DATA);
//write(ForGroundColor,DATA);
write(HighByte(ForGroundColor),DATA);
write(LowByte(ForGroundColor),DATA);
}
}
_N6100 cout(Color::White,Color::Black,Color::White);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -