Board Logo
« midInk sub »

Welcome Guest. Please Login or Register.
Jun 22nd, 2017, 06:54am


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: midInk sub  (Read 191 times)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1050
xx midInk sub
« Thread started on: Apr 6th, 2017, 12:00pm »

For doing color transitions from one rgb to another without the need of palettes:

Code:
'midInk for JB from
'midInk test.sdlbas [B+=MGA] 2017-04-06

'how to do a bunch of color transitions WITHOUT a bunch of palettes

global H$, XMAX, YMAX
H$ = "#gr"
XMAX = 800
YMAX = 700

nomainwin

WindowWidth = XMAX + 8
WindowHeight = YMAX + 32
UpperLeftX = (1200 - XMAX) / 2  'or delete if XMAX is 1200 or above
UpperLeftY = (700 - YMAX) / 2   'or delete if YMAX is 700 or above

open "midInk Test for JB" for graphics_nsb_nf as #gr
#gr "setfocus"
#gr "trapclose quit"
#gr "down"
#gr "fill black"

loopcnt = 0
while 1
    'create 2 random rgb colors, draw frames at 10% increments
    r1 = rand(0, 255) : g1 = rand(0, 255) : b1 = rand(0, 255)
    r2 = rand(0, 255) : g2 = rand(0, 255) : b2 = rand(0, 255)
    for i = 10 to 1 step -1
        call midInk r1, g1, b1, r2, g2, b2, i*10
        #gr "place ";XMAX/2 - 200 - i*10;" ";YMAX/2 - 200 - i*10
        #gr "boxfilled ";XMAX/2 + 200 + i*10 + 1;" ";YMAX/2 + 200 + i*10 + 1
    next
    select case loopcnt mod 3
    case 0 : r = 255 : g = 0 : b = 0
    case 1 : r = 0 : g = 255 : b = 0
    case 2 : r = 0 : g = 0 : b = 255
    end select
    for i = 200 to 2 step  -1
        call midInk 255, 255, 255, r, g, b, 100 - i/2  'flip the percent
        #gr "place ";XMAX/2;" ";YMAX/2;"; circlefilled ";i
    next
    call pause 300
    loopcnt = loopcnt + 1
wend
wait

'featured sub
'ink the color that is percent between the first color and 2nd color
sub midInk r1, g1, b1, r2, g2, b2, percent
    dr = (r2 - r1) / 100 : dg = (g2 - g1) / 100 : db = (b2 - b1) / 100
    #H$ "color ";r1 + dr * percent;" ";g1 + dg * percent;" ";b1 + db * percent
    #H$ "backcolor ";r1 + dr * percent;" ";g1 + dg * percent;" ";b1 + db * percent
end sub

function rand(n1, n2)
    if n1 > n2 then hi = n1 : lo = n2 else hi = n2 : lo = n1
    rand = int((hi - lo + 1) * rnd(0)) + lo
end function

sub pause mil   'tsh version has scan built-in
    t0 = time$("ms")
    while time$("ms") < t0 + mil : scan : wend
end sub

sub quit H$
    close #H$
    end
end sub 
« Last Edit: Apr 6th, 2017, 1:41pm by bplus » User IP Logged

B+
code
Member in Training
ImageImage


member is offline

Avatar




Homepage PM


Posts: 21
xx Re: midInk sub
« Reply #1 on: Apr 6th, 2017, 4:55pm »

I runned the code ...and see a lot of colors... Great !
Greetings,
Frederik shocked
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls