Log In  

Cart #stripe_print-0 | 2022-07-14 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Hi All,

This is just a quick util method for printing in multiple colours per line of pixel. Its probably been done many time before but this is just my take on it.

The function in question is 41 tokens:

function stripe(txt, x, y, cols)
    local w = print(txt,x,y,0)
    for i=1,#cols do

cols is an array of colours which should be at least as large as the height of the text being printed. For normal text this will be 5 values, but if split into multiple lines or you print bigger text then you need more values.

In the cart I've demonstrated some uses of it including a scrolling table that could be used as an effect.

P#114291 2022-07-14 09:59

Superb work here, @SquidLight ! I can definitely see the animated SCROLL working in future carts. Gold star effort.

Here is your STRIPE function even smaller:

function stripe(t,x,y,c)for i=0,#c do clip(0,y+i,128,y+i)print(t,x,y,c[i+1])end end

83-characters compared to the original 120-characters.

The real gem you have here is THIS:

add(scroll, deli(scroll,1))

What an interesting and compact way to rotate an array !

P#114313 2022-07-14 20:43

@dw817 thanks for this. I see you've opted to clip the whole line which makes sense for optimisation purposes.

The scrolling I didn't really pay too much attention to. It just seemed to rotate an array you needed an object ref since deli did both provide an object ref and removed from the table I thought it made sense.

P#114352 2022-07-15 12:51 ( Edited 2022-07-15 12:53)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-05-29 19:08:47 | 0.026s | Q:15