A nice clock picture

xiaoxiao2021-03-06  14

Idea and basic source code from the zjliu netizen of the lavery, I just added a way to avoid flashing and ghosting phenomenon. In addition, the error message when avoiding the shutdown. Try Close All Hfig = Figure; set (Hfig, 'Numertle', ' Off '); set (Hfig,' Name ',' shows the current time table '); set (hfig,' menubar ',' none); set (Hfig, 'Color', [0.5 0.7 0.3]) a = LINSPACE (0, 6.3, 1000); x1 = 8 * cos (a); Y1 = 8 * sin (a); x2 = 7 * cos (a); Y2 = 7 * sin (a); plot (x1, y1 , 'b', 'linewidth', 1.4) Hold On Plot (x2, y2, 'b', 'linewidth', 3.5) Fill (0.4 * COS (A), 0.4 * sin (a), 'r'); Axis Off Axis ([- 10 10 -10 10]) AXIS Equal set (GCA, 'POSITION', [[0.13 0.05 0.775 0.815]]) Title (Date, 'Fontsize', 18) fork = 1: 12; XK = 9 * COS (-2 * pi / 12 * k pi / 2); yk = 9 * sin (-2 * pi / 12 * k pi / 2); Plot ([XK / 9 * 8 XK / 9 * 7], [YK / 9 * 8 YK / 9 * 7], 'Color', [0.3 0.8 0.9])% IF kh = text (XK, YK, Num2Str (K), 'Fontsize', 16, 'Color ', ... [0.9 0.3 0.8],' HorizontalaLAlignment ',' Center '); End% Calculates Ti = Clock; TH = - (Ti (4) Ti (5) / 60 Ti (6) / 3600) / 12 * 2 * pi pi / 2; xh3 = 4.0 * Cos (TH); YH3 = 4.0 * sin (TH); XH2 = XH3 / 2 0.5 * COS (TH-PI / 2); YH2 = YH3 / 2 0.5 * Sin (TH-Pi / 2); XH4 = XH3 / 2-0.5 * COS (TH-Pi / 2); YH4 = YH3 / 2-0.5 * Sin (TH-Pi / 2); HH = Fill ([0 xh2 xh3 xh4 0], [0 yh2 yh3 yh4 0], [0.6 0.5 0. 3]);% calculate the minute position Tm = - (Ti (5) Ti (6) / 60) / 60 * 2 * pi pi / 2; XM3 = 6.0 * Cos (TM); YM3 = 6.0 * sin TM); XM2 = XM3 / 2 0.5 * COS (TM-PI / 2); YM2 = YM3 / 2 0.5 * Sin (TM-Pi / 2); XM4 = XM3 / 2-0.5 * COS (TM-Pi / 2); YM4 = YM3 / 2-0.5 * sin (TM-Pi / 2); hm = Fill ([0 xm2 xm3 xm4 0], [0 ym2 ym3 ym4 0], [0.6 0.5 0.3]);% calculation Second hand position Ts = - (Ti (6)) / 60 * 2 * pi pi / 2; HS = PLOT ([0 7 * COS (TS)], [0 7 * SIN (TS)], ... ' Color ', [0.6 0.5 0.3],' LineWidth ', 3); Set (GCF,' Doublebuffer ',' on ');

转载请注明原文地址:https://www.9cbs.com/read-50582.html

New Post(0)