Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drawing Tools Subs or Functions with Demo
#57
MidInk~& Function
Blend color 2 into color 1 by a fraction, usually it's the fractional distance of color 2 center or edge to color 1 center or edge.


Sometime the most handy routines are the simplest Smile

Code: (Select All)
_Title "midInk test" 'B+ 2019-04-18 remake 2025-04-30

Const xmax = 800
Const ymax = 600
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 250, 60

horizon% = Int(ymax * .6)
For i = 550 To 0 Step -1 '                      the sun
    FC3 400, horizon%, i, midInk~&(255, 255, 0, 50, 50, 208, i / 550)
Next

For i = horizon% To ymax '              the land
    Line (0, i)-(xmax, i), midInk~&(200, 200, 60, 45, 48, 0, (i - horizon%) / (ymax - horizon%))
Next
Sleep

' blend 2 colors according to fractional distance of 2nd to first color
Function midInk~& (r1%, g1%, b1%, r2%, g2%, b2%, fr##)
    midInk~& = _RGB32(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##)
End Function

Sub FC3 (cx As Long, cy As Long, r As Long, clr~&) ' fill circle #3 mod
    Dim As Long r2, x, y ' for Option _Explicit
    If r < 1 Then Exit Sub
    Line (cx - r, cy)-(cx + r, cy), clr~&, BF
    r2 = r * r
    Do
        y = y + 1
        x = Sqr(r2 - y * y)
        Line (cx - x, cy + y)-(cx + x, cy + y), clr~&, BF
        Line (cx - x, cy - y)-(cx + x, cy - y), clr~&, BF
    Loop Until y = r
End Sub


   
b = b + ...
Reply


Messages In This Thread
RE: Drawing Tools Subs or Functions with Demo - by bplus - 04-30-2025, 11:50 AM



Users browsing this thread: 1 Guest(s)