Should work on resolutions between the default 640x400 and 16K. Tested on Windows 10 and Android, various versions. Needs some (a lot of) cleanup
#!/lbin/ybasic ! Demo some ways to show purrty gradients and how they work ! All this redundant math must have made some kind of sense ! to my acute bronchitis addled little mind but I dunno what Program Colors OpenW 1 Pause 0.05 ClearW ShowPage Get_Screensize sx%, sy%, sw%, sh% Get_Geometry 1, wx%, wy%, ww%, wh% Print "Screen", sx%, sy%, sw%, sh% Print "Window", wx%, wy%, ww%, wh% ! Are there differences in the visible area between platforms? Color Color_RGB(0, 1, 0) PBox -1, -1, ww% + 2, wh% + 2 ! ShowPage ! Pause 0.1 w% = ww% / 3 For x% = 0 To w% - 1 ! Red to green ! Linear Color Color_RGB((w% - x%) / w%, x% / w%, 0) Draw 0 * w% + x%, wh% * 0 / 6 To 0 * w% + x%, wh% * 2 / 6 Color Color_RGB(1, 0, 0) Plot 0 * w% + x%, ((w% - x%) / w%) * -wh% / 3 + wh% / 3 + wh% * 0 / 6 Color Color_RGB(0, 1, 0) Plot 0 * w% + x%, (x% / w%) * -wh% / 3 + wh% / 3 + wh% * 0 / 6 ! Trig Color Color_RGB(Cos(x% * Pi / 2 / w%), Sin(x% * Pi / 2 / w%), 0) Draw 0 * w% + x%, wh% * 2 / 6 To 0 * w% + x%, wh% * 4 / 6 Color Color_RGB(1, 0, 0) Plot 0 * w% + x%, Cos(x% * Pi / 2 / w%) * -wh% / 3 + wh% / 3 + wh% * 2 / 6 Color Color_RGB(0, 1, 0) Plot 0 * w% + x%, Sin(x% * Pi / 2 / w%) * -wh% / 3 + wh% / 3 + wh% * 2 / 6 ! Green to blue ! Linear Color Color_RGB(0, (w% - x%) / w%, x% / w%) Draw 1 * w% + x%, wh% * 0 / 6 To 1 * w% + x%, wh% * 2 / 6 Color Color_RGB(0, 1, 0) Plot 1 * w% + x%, ((w% - x%) / w%) * -wh% / 3 + wh% / 3 + wh% * 0 / 6 Color Color_RGB(0, 0, 1) Plot 1 * w% + x%, (x% / w%) * -wh% / 3 + wh% / 3 + wh% * 0 / 6 ! Trig Color Color_RGB(0, Cos(x% * Pi / 2 / w%), Sin(x% * Pi / 2 / w%)) Draw 1 * w% + x%, wh% * 2 / 6 To 1 * w% + x%, wh% * 4 / 6 Color Color_RGB(0, 1, 0) Plot 1 * w% + x%, Cos(x% * Pi / 2 / w%) * -wh% / 3 + wh% / 3 + wh% * 2 / 6 Color Color_RGB(0, 0, 1) Plot 1 * w% + x%, Sin(x% * Pi / 2 / w%) * -wh% / 3 + wh% / 3 + wh% * 2 / 6 ! Blue back to red ! Linear Color Color_RGB(x% / w%, 0, (w% - x%) / w%) Draw 2 * w% + x%, wh% * 0 / 6 To 2 * w% + x%, wh% * 2 / 6 Color Color_RGB(0, 0, 1) Plot 2 * w% + x%, ((w% - x%) / w%) * -wh% / 3 + wh% / 3 + wh% * 0 / 6 Color Color_RGB(1, 0, 0) Plot 2 * w% + x%, (x% / w%) * -wh% / 3 + wh% / 3 + wh% * 0 / 6 ! Trig Color Color_RGB(Sin(x% * Pi / 2 / w%), 0, Cos(x% * Pi / 2 / w%)) Draw 2 * w% + x%, wh% * 2 / 6 To 2 * w% + x%, wh% * 4 / 6 Color Color_RGB(0, 0, 1) Plot 2 * w% + x%, Cos(x% * Pi / 2 / w%) * -wh% / 3 + wh% / 3 + wh% * 2 / 6 Color Color_RGB(1, 0, 0) Plot 2 * w% + x%, Sin(x% * Pi / 2 / w%) * -wh% / 3 + wh% / 3 + wh% * 2 / 6 Next x% w1% = ww% / 6 For x% = 0 To w1% ! Red to Yellow(?) Color Color_RGB(1, x% / w1%, 0) Draw 0 * w1% + x%, wh% * 4 / 6 To 0 * w1% + x%, wh% * 6 / 6 Color Color_RGB(1, 0, 0) Plot 0 * w1% + x%, wh% * 4 / 6 Color Color_RGB(0, 1, 0) Plot 0 * w1% + x%, (x% / w1%) * -wh% / 3 + wh% / 3 + wh% * 4 / 6 ! Yellow(?) to Green Color Color_RGB((w1% - x%) / w1%, 1, 0) Draw 1 * w1% + x%, wh% * 4 / 6 To 1 * w1% + x%, wh% * 6 / 6 Color Color_RGB(1, 0, 0) Plot 1 * w1% + x%, ((w1% - x%) / w1%) * -wh% / 3 + wh% / 3 + wh% * 4 / 6 Color Color_RGB(0, 1, 0) Plot 1 * w1% + x%, wh% * 4 / 6 ! Green to Aqua(?) Color Color_RGB(0, 1, x% / w1%) Draw 2 * w1% + x%, wh% * 4 / 6 To 2 * w1% + x%, wh% * 6 / 6 Color Color_RGB(0, 1, 0) Plot 2 * w1% + x%, wh% * 4 / 6 Color Color_RGB(0, 0, 1) Plot 2 * w1% + x%, (x% / w1%) * -wh% / 3 + wh% / 3 + wh% * 4 / 6 ! Aqua(?) to Blue Color Color_RGB(0, (w1% - x%) / w1%, 1) Draw 3 * w1% + x%, wh% * 4 / 6 To 3 * w1% + x%, wh% * 6 / 6 Color Color_RGB(0, 1, 0) Plot 3 * w1% + x%, ((w1% - x%) / w1%) * -wh% / 3 + wh% / 3 + wh% * 4 / 6 Color Color_RGB(0, 0, 1) Plot 3 * w1% + x%, wh% * 4 / 6 ! Blue to Violet(?) Color Color_RGB(x% / w1%, 0, 1) Draw 4 * w1% + x%, wh% * 4 / 6 To 4 * w1% + x%, wh% * 6 / 6 Color Color_RGB(0, 0, 1) Plot 4 * w1% + x%, wh% * 4 / 6 Color Color_RGB(1, 0, 0) Plot 4 * w1% + x%, (x% / w1%) * -wh% / 3 + wh% / 3 + wh% * 4 / 6 ! Violet(?) back to Red Color Color_RGB(1, 0, (w1% - x%) / w1%) Draw 5 * w1% + x%, wh% * 4 / 6 To 5 * w1% + x%, wh% * 6 / 6 Color Color_RGB(0, 0, 1) Plot 5 * w1% + x%, ((w1% - x%) / w1%) * -wh% / 3 + wh% / 3 + wh% * 4 / 6 Color Color_RGB(1, 0, 0) Plot 5 * w1% + x%, wh% * 4 / 6 Next x% ! Captions SetFont Right$("Living LARGE", 5) ! No effect in Windows? Color Color_RGB(0.8, 0.8, 0.8), Color_RGB(0, 0, 0, 0) Text 10, wh% * 1 / 6, "Linear" Text 10, wh% * 3 / 6, "Trig" Text 10, wh% * 5 / 6, "Brighter" ShowPage If Android? Pause 20 EndIf Print wx%, wy%, ww%, wh%, x%, w%, w1% Print Print "OK" End
Log in to post a comment.
Should work on resolutions between the default 640x400 and 16K. Tested on Windows 10 and Android, various versions. Needs some (a lot of) cleanup