Difference between revisions of "Term.blit"
From ComputerCraft Wiki
Bomb Bloke (Talk | contribs) (Created page with "{{lowercase}} {{Function |name=term.blit |args= {{Type|string}} text, {{Type|string}} text colours, {{Type|string}} background colours |api=term |addon=ComputerCraft |desc=Add...") |
Bomb Bloke (Talk | contribs) (Can use spaces as colours) |
||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
|api=term | |api=term | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Added by ComputerCraft 1.74, term.blit functions in nearly the same manner as [[term.write]](), but instead of using the current text and background colours, it accepts additional strings specifying colour codes for each individual character. | + | |desc=Added by ComputerCraft 1.74, term.blit() functions in nearly the same manner as [[term.write]](), but instead of using the current text and background colours, it accepts additional strings specifying colour codes for each individual character. Although it is no faster than term.write() in its own right, in some circumstances it can reduce code length and speed execution by removing the need to make multiple [[term.setTextColor]]() / [[term.setBackgroundColor]]() calls.<br><br> |
− | Each character in the text/background colour strings must be a valid "paint" symbol from ComputerCraft's [[Colors_%28API%29#Colors|list of colours]] (eg, "a", "3", "e", etc), | + | Each character in the text/background colour strings must be a valid "paint" symbol from ComputerCraft's [[Colors_%28API%29#Colors|list of colours]] (eg, "a" for purple, "3" for light blue, "e" for red, etc), in the same order as the text characters they are to be applied to. Spaces may also be used: in the text colour string, they'll be taken for white, whereas in the background colour string they'll be taken for black. The three strings must each be of the same length. Note that only advanced systems can render in colour - if unsupported shades are requested on a normal system, no error will occur but black will be used instead. |
|examples= | |examples= | ||
{{Example | {{Example | ||
Line 18: | Line 18: | ||
|code=term.blit("RAINBOW!","01234567","89abcdef") | |code=term.blit("RAINBOW!","01234567","89abcdef") | ||
|output=<span style="color:#F0F0F0; background-color:#999999;">R</span><span style="color:#F2B233; background-color:#4C99B2;">A</span><span style="color:#E57FD8; background-color:#B266E5;">I</span><span style="color:#99B2F2; background-color:#3366CC;">N</span><span style="color:#DEDE6C; background-color:#7F664C;">B</span><span style="color:#7FCC19; background-color:#57A64E;">O</span><span style="color:#F2B2CC; background-color:#CC4C4C;">W</span><span style="color:#4C4C4C; background-color:#000000;">!</span> | |output=<span style="color:#F0F0F0; background-color:#999999;">R</span><span style="color:#F2B233; background-color:#4C99B2;">A</span><span style="color:#E57FD8; background-color:#B266E5;">I</span><span style="color:#99B2F2; background-color:#3366CC;">N</span><span style="color:#DEDE6C; background-color:#7F664C;">B</span><span style="color:#7FCC19; background-color:#57A64E;">O</span><span style="color:#F2B2CC; background-color:#CC4C4C;">W</span><span style="color:#4C4C4C; background-color:#000000;">!</span> | ||
+ | }} | ||
+ | {{Example | ||
+ | |desc=Writes "Hello, World!", using black text on a white background. | ||
+ | |code=term.blit("Hello, World!","fffffffffffff","0000000000000") | ||
+ | |output=Hello, World! | ||
}} | }} | ||
}} | }} | ||
[[Category:API_Functions]] | [[Category:API_Functions]] |
Latest revision as of 23:42, 16 December 2015
Function term.blit | |
Added by ComputerCraft 1.74, term.blit() functions in nearly the same manner as term.write(), but instead of using the current text and background colours, it accepts additional strings specifying colour codes for each individual character. Although it is no faster than term.write() in its own right, in some circumstances it can reduce code length and speed execution by removing the need to make multiple term.setTextColor() / term.setBackgroundColor() calls. Each character in the text/background colour strings must be a valid "paint" symbol from ComputerCraft's list of colours (eg, "a" for purple, "3" for light blue, "e" for red, etc), in the same order as the text characters they are to be applied to. Spaces may also be used: in the text colour string, they'll be taken for white, whereas in the background colour string they'll be taken for black. The three strings must each be of the same length. Note that only advanced systems can render in colour - if unsupported shades are requested on a normal system, no error will occur but black will be used instead. | |
Syntax | term.blit(string text, string text colours, string background colours) |
Returns | nil |
Part of | ComputerCraft |
API | term |
Examples
Example | |
Writes the letter "a", using a blue text colour ("b"), and a brown background colour ("c"). | |
Code |
term.blit("a","b","c") |
Output | a |
Example | |
Writes RAINBOW!, making use of all colours. | |
Code |
term.blit("RAINBOW!","01234567","89abcdef") |
Output | RAINBOW! |
Example | |
Writes "Hello, World!", using black text on a white background. | |
Code |
term.blit("Hello, World!","fffffffffffff","0000000000000") |
Output | Hello, World! |