Information Technology - Computer Programming - Source Code - Homebrew - Open Source - Software - Hardware - 8 bit - 16 bit - 32 bit - 64 bit - x86 - x64 - DOS - Windows - Linux - Arduino - Embedded - Development - Retro - Vintage - Math - Science - History - Hobby - Beginners - Professionals - Experiment - Research - Study - Fun - Games

Traffic Light

Share your Net Basic creations here.
Post Reply
User avatar
Brian
Posts: 15
Joined: Mon Dec 11, 2023 2:19 pm

Traffic Light

Post by Brian »

This program simulates a British road traffic light. For those not familiar with the workings of the British traffic light system the following website will highlight the lighting sequence required to simulate a traffic light.

https://theorytest.org.uk/traffic-lights/

Code: Select all

1 REM Traffic Light
2 HTML
4 LET x = 15
6 LET y = 206
8 PRINT "<svg width = '150' height = '210' style = 'background-color:lightskyblue;'>"
10 PRINT "<text x = '"; x; "' y = '"; y; "' font-size = '5' fill = '#1E90FF'>LENS 2024</text>"
12 LET x = 60
14 LET y = 201
16 LET width = 40
18 LET height = 6
20 PRINT "<rect x = '"; x; "' y = '"; y; "' width = '"; width; "' height = '"; height; "'  fill = 'black' />"
22 LET x = 77
24 LET y = 81
26 LET width = 6
28 LET height = 120
30 PRINT "<rect x = '"; x; "' y = '"; y; "' width = '"; width; "' height = '"; height; "'  fill = 'black' />"
32 LET x = 77
34 LET y = 81
36 LET width = 6
38 LET height = 120
40 PRINT "<rect x = '"; x; "' y = '"; y; "' width = '"; width; "' height = '"; height; "'  fill = 'black' />"
42 LET x = 64
44 LET y = 13
46 LET width = 32
48 LET height = 68
50 PRINT "<rect x = '"; x; "' y = '"; y; "' width = '"; width; "' height = '"; height; "'  fill = 'black' />"
52 LET cx = 80
54 LET cy = 25
56 LET r = 8
58 PRINT "<circle cx = '"; cx; "' cy = '"; cy; "' r = '"; r; "' stroke ='grey' stroke-width = '1' fill = 'none' />"
60 LET cx = 80
62 LET cy = 47
64 PRINT "<circle cx = '"; cx; "' cy = '"; cy; "' r = '"; r; "' stroke ='grey'; stroke-width = '1'; fill = 'none' />"
66 LET cx = 80
68 LET cy = 69
70 PRINT "<circle cx = '"; cx; "' cy = '"; cy; "' r = '"; r; "' stroke ='grey'; stroke-width = '1'; fill = 'none' />"
72 LET cx = 80
74 LET cy = 25
76 LET r = 7
78 PRINT "<circle cx = '"; cx; "' cy = '"; cy; "' r = '"; r; "' style='fill: #ff0000' ><animate attributeName='visibility' attributeType='XML' values='visible;hidden;visible' keyTimes='0; 0.4; 1' dur='15s' repeatCount='indefinite'></circle>"
80 LET cx = 80
82 LET cy = 47
84 PRINT "<circle cx = '"; cx; "' cy = '"; cy; "' r = '"; r; "' style='fill: #ffa500' ><animate attributeName='visibility' attributeType='XML' values='hidden;visible;hidden;visible;hidden' keyTimes='0; 0.266; 0.4; 0.8; 1' dur='15s' repeatCount='indefinite'></circle>"
86 LET cx = 80
88 LET cy = 69
90 PRINT "<circle cx = '"; cx; "' cy = '"; cy; "' r = '"; r; "' style='fill: #00ff00' ><animate attributeName='visibility' attributeType='XML' values='hidden;visible;hidden;hidden' keyTimes='0; 0.4; 0.8; 1' dur='15s' repeatCount='indefinite'></circle>"
92 PRINT "</svg>"
94 END
Attachments
Traffic Light.png
Traffic Light.png (3.05 KiB) Viewed 4244 times
Post Reply