Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {{r=1,g=0,b=0,a=1},{r=1,g=0,b=0,a=1},{r=1,g=0,b=0,a=1},{r=0,g=1,b=0,a=1},{r=0,g=1,b=0,a=1},{r=0,g=1,b=0,a=1},{r=0,g=0,b=1,a=1},{r=0,g=0,b=1,a=1},{r=0,g=0,b=1,a=1},
- {r=0,g=1,b=0,a=1},{r=0,g=1,b=0,a=1},{r=0,g=1,b=0,a=1},{r=0,g=0,b=1,a=1},{r=0,g=0,b=1,a=1},{r=0,g=0,b=1,a=1},{r=1,g=0,b=0,a=1},{r=1,g=0,b=0,a=1},{r=1,g=0,b=0,a=1},
- {r=0,g=0,b=1,a=1},{r=0,g=0,b=1,a=1},{r=0,g=0,b=1,a=1},{r=1,g=0,b=0,a=1},{r=1,g=0,b=0,a=1},{r=1,g=0,b=0,a=1},{r=0,g=1,b=0,a=1},{r=0,g=1,b=0,a=1},{r=0,g=1,b=0,a=1}}
- --489 Chars, Uncompressed values
- c1 = {r=1,g=0,b=0,a=1}
- c2 = {r=0,g=1,b=0,a=1}
- c3 = {r=0,g=0,b=1,a=1}
- --Pre set variables for the rgba values.
- {c1,c1,c1,c2,c2,c2,c3,c3,c3,
- c2,c2,c2,c3,c3,c3,c1,c1,c1,
- c3,c3,c3,c1,c1,c1,c2,c2,c2}
- --84 Chars
- --Each rgba colour value is compressed into a pre set variable for the colour.
- --E.g: c1 = {r=1,g=0,b=0,a=1}
- {{c1,3},{c2,3},{c3,3},
- {c2,3},{c3,3},{c1,3},
- {c3,3},{c1,3},{c2,3}}
- --66 Chars
- --Stores value of colour and how many times it has repeated.
- --E.g: {c1,3} = c1,c1,c1
- while k <= imgWidth*imgHeight do
- arr = image[s]
- num = arr[2]
- col = arr[1]
- for i = 1, num do
- x = x+1
- if x > imgWidth then
- y = y+1
- x = 1
- end
- this:set_sprite_texel(x-1,imgHeight-y,col.r/255,col.g/255,col.b/255,col.a/255)
- end
- k = k + num
- s = s + 1
- end
- {1,0,0,1,0,0,1,0,0,
- -1,0,0,1,0,0,-2,0,0,
- 2,0,0,-2,0,0,1,0,0}
- --60 Chars
- --Takes the first number of the string and converts it to an integer step from the previous number.
- --E.g: image[1] = c1, image[0] = nil/c0 compressed array has the first step as 1.
- --image[2] = c1, image[1] = c1 compressed array has the second step as 0. etc... All steps are from the previous entry.
- while k <= imgWidth*imgHeight do
- colCode = image[k] + (prev ~= nil and prev or 0)
- x = x + 1
- if x > imgWidth then
- y = y + 1
- x = 1
- end
- col = "c"..colCode
- k = k + 1
- prev = colCode
- this:set_sprite_texel(x-1,imgHeight-y,col.r,col.g,col.b,col.a)
- end
- --[[
- Future ideas:
- Use combination of shortening arrays by method {c1,3} and apply shortening method to values that only repeat 3 or more times. Use script to detect if the value in the table is another table or a colour variable and act accordingly.
- Use same method as above for the integer step method, may work for more repetitive arrays. (This method will probably take up more space the just using variables for the rgba values if the image is grainy and has few repeating colour sets, same with the above method.)
- ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement