Vibrating rectangles: Difference between revisions
Content added Content deleted
(Clarified point 3) |
(Added C implementation) |
||
Line 8: | Line 8: | ||
Create [https://1drv.ms/v/s!AqDUIunCqVnIg1MxKPi5DzwUbJEf Vibrating rectangles] |
Create [https://1drv.ms/v/s!AqDUIunCqVnIg1MxKPi5DzwUbJEf Vibrating rectangles] |
||
<br> |
<br> |
||
=={{header|C}}== |
|||
Dimensions of the rectangles, their number and the animation delay can be configured. Requires the [http://www.cs.colorado.edu/~main/bgi/cs1300/ WinBGIm] library. |
|||
<lang C> |
|||
#include<graphics.h> |
|||
void vibratingRectangles(int winWidth,int winHeight,int leastLength,int leastWidth,int num, int msec) |
|||
{ |
|||
int color = 1,i,x = winWidth/2, y = winHeight/2; |
|||
while(!kbhit()){ |
|||
setcolor(color++); |
|||
for(i=num;i>0;i--){ |
|||
rectangle(x - i*leastLength,y - i*leastWidth,x + i*leastLength,y + i*leastWidth); |
|||
delay(msec); |
|||
} |
|||
if(color>MAXCOLORS){ |
|||
color = 1; |
|||
} |
|||
} |
|||
} |
|||
int main() |
|||
{ |
|||
initwindow(1000,1000,"Vibrating Rectangles..."); |
|||
vibratingRectangles(1000,1000,30,15,20,500); |
|||
closegraph(); |
|||
return 0; |
|||
} |
|||
<lang> |
|||
=={{header|Javascript}}== |
=={{header|Javascript}}== |
||
HTML you'll need for testing |
HTML you'll need for testing |