use "canvas" use "std" w = 800 h = 600 window("Animate line", w, h) // Крайние точки линии x1 = rand(w) y1 = rand(h) x2 = rand(w) y2 = rand(h) // Направление движения d1x = rand() d1y = -rand() d2x = rand() d2y = rand() // Очищаем экран color(rand(#FFFFFF)) frect(0,0,w,h) hue = 0 run = 1 while run { if checkhoriz(x1) d1x = -d1x if checkhoriz(x2) d2x = -d2x if checkvert(y1) d1y = -d1y if checkvert(y2) d2y = -d2y x1 = x1 + d1x x2 = x2 + d2x y1 = y1 + d1y y2 = y2 + d2y hue = hue + 0.0001 if (hue >= 1) hue = 0 sethsbcolor(hue) line(x1, y1, x2, y2) repaint() sleep(10) if keypressed() == VK_ESCAPE run = 0 } def checkhoriz(px) return (px >= w || px < 0) def checkvert(py) return (py >= h || py < 0) def floor(v) return v - v % 1 def sethsbcolor(h1) { qr = h1 * 6 // временно для расчёта hueindex = floor(qr) % 6 f = qr - floor(qr) if hueindex == 0 color(255, f*255, 0) else if hueindex == 1 color(255 - f*255, 255, 0) else if hueindex == 2 color(0, 255, f*255) else if hueindex == 3 color(0, 255-f*255, 255) else if hueindex == 4 color(f*255, 0, 255) else if hueindex == 5 color(255, 0, 255-f*255) }