📄 gui_basic.lst
字号:
C51 COMPILER V7.50 GUI_BASIC 09/11/2007 21:56:45 PAGE 13
737 1 draw_x0 = draw_x1 = draw_x2 = draw_x3 = center_x;
738 1 draw_y0 = draw_y1 = center_y + radius_y;
739 1 draw_y2 = draw_y3 = center_y - radius_y;
740 1
741 1
742 1 GUI_Point(draw_x0, draw_y0, color); // 画y轴上的两个端点
743 1 GUI_Point(draw_x2, draw_y2, color);
744 1
745 1 while( (radius_yy*xx) < (radius_xx*yy) )
746 1 { if(di<0)
747 2 { di+= radius_yy2*(2*xx+3);
748 3 }
749 2 else
750 2 { di += radius_yy2*(2*xx+3) + 4*radius_xx - 4*radius_xx*yy;
751 3
752 3 yy--;
753 3 draw_y0--;
754 3 draw_y1--;
755 3 draw_y2++;
756 3 draw_y3++;
757 3 }
758 2
759 2 xx ++; // x轴加1
760 2
761 2 draw_x0++;
762 2 draw_x1--;
763 2 draw_x2++;
764 2 draw_x3--;
765 2
766 2 GUI_Point(draw_x0, draw_y0, color);
767 2 GUI_Point(draw_x1, draw_y1, color);
768 2 GUI_Point(draw_x2, draw_y2, color);
769 2 GUI_Point(draw_x3, draw_y3, color);
770 2 }
771 1
772 1 di = radius_xx2*(yy-1)*(yy-1) + radius_yy2*xx*xx + radius_yy + radius_yy2*xx - radius_xx2*radius_yy;
773 1 while(yy>=0)
774 1 { if(di<0)
775 2 { di+= radius_xx2*3 + 4*radius_yy*xx + 4*radius_yy - 2*radius_xx2*yy;
776 3
777 3 xx ++; // x轴加1
778 3 draw_x0++;
779 3 draw_x1--;
780 3 draw_x2++;
781 3 draw_x3--;
782 3 }
783 2 else
784 2 { di += radius_xx2*3 - 2*radius_xx2*yy;
785 3 }
786 2
787 2 yy--;
788 2 draw_y0--;
789 2 draw_y1--;
790 2 draw_y2++;
791 2 draw_y3++;
792 2
793 2 GUI_Point(draw_x0, draw_y0, color);
794 2 GUI_Point(draw_x1, draw_y1, color);
795 2 GUI_Point(draw_x2, draw_y2, color);
796 2 GUI_Point(draw_x3, draw_y3, color);
797 2 }
798 1 }
C51 COMPILER V7.50 GUI_BASIC 09/11/2007 21:56:45 PAGE 14
799
800
801 /****************************************************************************
802 * 名称:GUI_EllipseFill()
803 * 功能:画正椭圆,并填充。给定椭圆的四个点的参数,最左、最右点的x轴坐标值为x0、x1,最上、最下点
804 * 的y轴坐标为y0、y1。
805 * 入口参数: x0 最左点的x坐标值
806 * x1 最右点的x坐标值
807 * y0 最上点的y坐标值
808 * y1 最下点的y坐标值
809 * color 填充颜色
810 * 出口参数:无
811 * 说明:操作失败原因是指定地址超出有效范围。
812 ****************************************************************************/
813 void GUI_EllipseFill(uint32 x0, uint32 x1, uint32 y0, uint32 y1, TCOLOR color)
814 { int32 draw_x0, draw_y0; // 刽图点坐标变量
815 1 int32 draw_x1, draw_y1;
816 1 int32 draw_x2, draw_y2;
817 1 int32 draw_x3, draw_y3;
818 1 int32 xx, yy; // 画图控制变量
819 1
820 1 int32 center_x, center_y; // 椭圆中心点坐标变量
821 1 int32 radius_x, radius_y; // 椭圆的半径,x轴半径和y轴半径
822 1 int32 radius_xx, radius_yy; // 半径乘平方值
823 1 int32 radius_xx2, radius_yy2; // 半径乘平方值的两倍
824 1 int32 di; // 定义决策变量
825 1
826 1 /* 参数过滤 */
827 1 if( (x0==x1) || (y0==y1) ) return;
828 1
829 1 /* 计算出椭圆中心点坐标 */
830 1 center_x = (x0 + x1) >> 1;
831 1 center_y = (y0 + y1) >> 1;
832 1
833 1 /* 计算出椭圆的半径,x轴半径和y轴半径 */
834 1 if(x0 > x1)
835 1 { radius_x = (x0 - x1) >> 1;
836 2 }
837 1 else
838 1 { radius_x = (x1 - x0) >> 1;
839 2 }
840 1 if(y0 > y1)
841 1 { radius_y = (y0 - y1) >> 1;
842 2 }
843 1 else
844 1 { radius_y = (y1 - y0) >> 1;
845 2 }
846 1
847 1 /* 计算半径乘平方值 */
848 1 radius_xx = radius_x * radius_x;
849 1 radius_yy = radius_y * radius_y;
850 1
851 1 /* 计算半径乘4值 */
852 1 radius_xx2 = radius_xx<<1;
853 1 radius_yy2 = radius_yy<<1;
854 1
855 1 /* 初始化画图变量 */
856 1 xx = 0;
857 1 yy = radius_y;
858 1
859 1 di = radius_yy2 + radius_xx - radius_xx2*radius_y ; // 初始化决策变量
860 1
C51 COMPILER V7.50 GUI_BASIC 09/11/2007 21:56:45 PAGE 15
861 1 /* 计算出椭圆y轴上的两个端点坐标,作为作图起点 */
862 1 draw_x0 = draw_x1 = draw_x2 = draw_x3 = center_x;
863 1 draw_y0 = draw_y1 = center_y + radius_y;
864 1 draw_y2 = draw_y3 = center_y - radius_y;
865 1
866 1
867 1 GUI_Point(draw_x0, draw_y0, color); // 画y轴上的两个端点
868 1 GUI_Point(draw_x2, draw_y2, color);
869 1
870 1 while( (radius_yy*xx) < (radius_xx*yy) )
871 1 { if(di<0)
872 2 { di+= radius_yy2*(2*xx+3);
873 3 }
874 2 else
875 2 { di += radius_yy2*(2*xx+3) + 4*radius_xx - 4*radius_xx*yy;
876 3
877 3 yy--;
878 3 draw_y0--;
879 3 draw_y1--;
880 3 draw_y2++;
881 3 draw_y3++;
882 3 }
883 2
884 2 xx ++; // x轴加1
885 2
886 2 draw_x0++;
887 2 draw_x1--;
888 2 draw_x2++;
889 2 draw_x3--;
890 2
891 2 GUI_Point(draw_x0, draw_y0, color);
892 2 GUI_Point(draw_x1, draw_y1, color);
893 2 GUI_Point(draw_x2, draw_y2, color);
894 2 GUI_Point(draw_x3, draw_y3, color);
895 2
896 2 /* 若y轴已变化,进行填充 */
897 2 if(di>=0)
898 2 { GUI_HLine(draw_x0, draw_y0, draw_x1, color);
899 3 GUI_HLine(draw_x2, draw_y2, draw_x3, color);
900 3 }
901 2 }
902 1
903 1 di = radius_xx2*(yy-1)*(yy-1) + radius_yy2*xx*xx + radius_yy + radius_yy2*xx - radius_xx2*radius_yy;
904 1 while(yy>=0)
905 1 { if(di<0)
906 2 { di+= radius_xx2*3 + 4*radius_yy*xx + 4*radius_yy - 2*radius_xx2*yy;
907 3
908 3 xx ++; // x轴加1
909 3 draw_x0++;
910 3 draw_x1--;
911 3 draw_x2++;
912 3 draw_x3--;
913 3 }
914 2 else
915 2 { di += radius_xx2*3 - 2*radius_xx2*yy;
916 3 }
917 2
918 2 yy--;
919 2 draw_y0--;
920 2 draw_y1--;
921 2 draw_y2++;
922 2 draw_y3++;
C51 COMPILER V7.50 GUI_BASIC 09/11/2007 21:56:45 PAGE 16
923 2
924 2 GUI_Point(draw_x0, draw_y0, color);
925 2 GUI_Point(draw_x1, draw_y1, color);
926 2 GUI_Point(draw_x2, draw_y2, color);
927 2 GUI_Point(draw_x3, draw_y3, color);
928 2
929 2 /* y轴已变化,进行填充 */
930 2 GUI_HLine(draw_x0, draw_y0, draw_x1, color);
931 2 GUI_HLine(draw_x2, draw_y2, draw_x3, color);
932 2 }
933 1 }
934 #endif
935
936
937
938
939 #if GUI_FloodFill_EN==1
/****************************************************************************
* 名称:GUI_ReadLeftPoint()
* 功能:找出指定点左边最近的非color点。
* 入口参数: x0 指定点的x坐标值
* y0 指定点的y坐标值
* color 指定颜色值
* 出口参数:返回该点的x轴坐标值。
* 说明:若没有找出,则返回最左的x坐标0。
****************************************************************************/
uint32 GUI_ReadLeftPoint(uint32 x0, uint32 y0, TCOLOR color)
{ uint32 i;
TCOLOR bakc;
for(i=x0-1; i>0; i--)
{ GUI_ReadPoint(i, y0, &bakc);
if( GUI_CmpColor(bakc,color)==0 ) return(i+1); // 若找到,则返回
}
GUI_ReadPoint(i, y0, &bakc);
if( GUI_CmpColor(bakc,color)==0 ) return(1); // 若找到,则返回
return(0);
}
/****************************************************************************
* 名称:GUI_ReadRightPoint()
* 功能:找出指定点右边最近的非color点。
* 入口参数: x0 指定点的x轴坐标值
* y0 指定点的y轴坐标值
* color 指定颜色值
* 出口参数:返回该点的x轴坐标值。
* 说明:若没有找出,则返回最右的x坐标GUI_LCM_XMAX。
****************************************************************************/
uint32 GUI_ReadRightPoint(uint32 x0, uint32 y0, TCOLOR color)
{ uint32 i;
TCOLOR bakc;
for(i=x0+1; i<GUI_LCM_XMAX; i++)
{ GUI_ReadPoint(i, y0, &bakc);
if( GUI_CmpColor(bakc,color)==0 ) return(i-1); // 若找到,则返回
}
return(GUI_LCM_XMAX);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -