Commit cfb170e
Added DIGITALRAIN_INTENSITY setting to control digital rain density (#191)
* fix for clock.py display date-time overlapping
* Added adjustable setting for density and frequency
SUMMARY OF MODIFICATIONS AND CURRENT SCRIPT BEHAVIOR
---------------------------------------------------
1. NEW SETTING: DIGITALRAIN_INTENSITY
- Added at the top of the script:
DIGITALRAIN_INTENSITY = 5
- Range: 1 (sparse/light) → 9 (dense/heavy)
- Purpose: Controls both the number of "digital rain" drops per spawn and the spawn frequency.
2. MODIFIED increase_population()
- Original:
def increase_population():
blue_pilled_population.append([randint(0, device.width), 0, gauss(1.2, 0.6)])
- Modified:
def increase_population():
drops_per_tick = max(1, int(DIGITALRAIN_INTENSITY * 0.5))
for _ in range(drops_per_tick):
blue_pilled_population.append([randint(0, device.width), 0, gauss(1.2, 0.6)])
- Effect: The number of drops added per spawn scales with intensity.
- Intensity 1 → 1 drop per spawn
- Intensity 9 → 4 drops per spawn (capped to prevent screen saturation)
3. NEW HELPER FUNCTION: should_spawn(clock)
- Original spawn condition:
if clock % 5 == 0 or clock % 3 == 0:
increase_population()
- Modified:
def should_spawn(clock):
interval = max(1, 10 - DIGITALRAIN_INTENSITY)
return clock % interval == 0
...
if should_spawn(clock):
increase_population()
- Effect: Spawn frequency dynamically scales with intensity.
- Intensity 1 → interval = 9 ticks (sparse rain)
- Intensity 9 → interval = 1 tick (heavy rain)
- Combined with drop-per-tick scaling, ensures heavy rain remains dynamic without filling the screen entirely.
4. OTHER CODE
- All other original behavior preserved:
- Color gradient in wrd_rgb is unchanged
- Speed of each drop controlled by gauss(1.2, 0.6)
- Maximum population still capped at device.width * 8
- Framerate regulated at 10 fps
- Canvas rendering logic unchanged
- KeyboardInterrupt handling preserved
5. HOW THE SCRIPT WORKS NOW
- Loop increments clock each tick
- On each tick:
a) Render all current drops on the canvas with their colors
b) Move each drop downward according to its speed
c) Determine if new drops should spawn using should_spawn(clock)
- If yes, spawn drops_per_tick new drops
d) Trim blue_pilled_population if it exceeds max_population
- Result: Digital rain density and intensity scale with the DIGITALRAIN_INTENSITY setting, giving smooth, adjustable visual effect without saturation or static appearance.
6. TUNABLE EFFECTS
- Adjust DIGITALRAIN_INTENSITY (1–9) to control visual density and dynamic behavior:
- 1 = very light rain
- 5 = balanced medium rain
- 9 = heavy rain, still dynamic, screen not static
* Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* corrected formatting on matrix_intensity.py code
qa: commands[0]> flake8
./examples/matrix_intensity.py:24:1: E302 expected 2 blank lines, found 1
./examples/matrix_intensity.py:84:1: E305 expected 2 blank lines after class or function definition, found 1
./examples/matrix_intensity.py:90:1: E265 block comment should start with '# '
./examples/matrix_intensity.py:91:1: W391 blank line at end of file
* Update matrix_intensity.py
Added 'device.width -1' to enhance display effect of digital rain.
Addressed and corrected the line spacing errors:
qa: commands[0]> flake8
./examples/matrix_intensity.py:24:1: E302 expected 2 blank lines, found 1
./examples/matrix_intensity.py:84:1: E305 expected 2 blank lines after class or function definition, found 1
./examples/matrix_intensity.py:90:1: E265 block comment should start with '# '
./examples/matrix_intensity.py:91:1: W391 blank line at end of file
* Fix QA transgressions
---------
Co-authored-by: Richard Hull <rm_hull@yahoo.co.uk>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent 2a9ed1e commit cfb170e
1 file changed
+93
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
0 commit comments