Created
October 10, 2021 12:21
-
-
Save rikka0w0/de54d3fa17341aee7d648ed9f8729398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ash | |
# This script will draw color gradient on the framebuffer | |
# http://seenaburns.com/2018/04/04/writing-to-the-framebuffer/ | |
# fbset --show | |
# cat /sys/class/graphics/fb0/bits_per_pixel | |
fbdev=/dev/fb0 | |
width=320 | |
height=240 | |
bpp=2 | |
# rgb565 | |
# color="\xe0\x07" green | |
pixel() | |
{ | |
local xx=$1 # [0, width-1] | |
local yy=$2 # [0, height-1] | |
local r=$3 # [0, 255] | |
local g=$4 # [0, 255] | |
local b=$5 # [0, 255] | |
local r=$((r>>3)) | |
local g=$((g>>2)) | |
local b=$((b>>3)) | |
local r5g6b5=$(( (r<<11) | (g<<5) | (b) )) | |
local hw=$(((r5g6b5>>8) & 0xFF)) | |
local lw=$((r5g6b5 & 0xFF)) | |
printf \\$(printf '%03o' $lw)\\$(printf '%03o' $hw) | \ | |
dd of=$fbdev bs=$bpp seek=$(($yy * $width + $xx)) &>/dev/null | |
} | |
for x in $(seq 0 1 $((width-1))); do | |
for y in $(seq 0 1 $((height-1))); do | |
r=$((255*x/width)) | |
g=$((255*y/height)) | |
b=0 | |
pixel $x $y $r $g $b | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment