Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
--[[ paintutils extra functions pastebin get 7XAmsAbX pue list of extra functions: paintutils.flipY(table image) returns 'image' stretched vertically paintutils.flipX(table image) returns 'image' stretched horizontally paintutils.grayOut(table image) converts 'image' to grayscale paintutils.lighten(table image) returns 'image' but with brighter colors, suitable for transitions paintutils.darken(table image) returns 'image' but with darker colors, suitable for transitions paintutils.getSize(table image) returns the x and y sizes of 'image' paintutils.stretchImage(table image, number stretchedX, number stretchedY) returns 'image', but stretched to fit sizes 'stretchedX' and 'stretchedY'. paintutils.merge(table {image1,x,y}, table {image2,x,y}, ...) returns an image composed of image1 layered upon image2 layered upon image3 and so on. paintutils.fullScreen(number color, terminal object) returns a fullscreen picture made solidly of 'color'. sets size to current terminal or 'object' if defined. paintutils.unloadImage(table image) returns a string NFP picture made from 'image'. paintutils.autocrop(table image) returns 'image' but with the blank space cut off from the left and top. paintutils.drawImageBlit(table image, number x, number y) draws 'image' at 'x' and 'y' using term.blit. As such, it does not support transparency. You will want to merge images together before rendering. paintutils.drawImageBlitCenter(table image, number x, number y, terminal object) draws 'image' centered around 'x' and 'y'. if 'x' and 'y' aren't defined, they default to half the screen width and height respectively. 'object' can be defined to use its screen size instead. paintutils.drawImageCenter(table image, number x, number y, terminal object) same as drawImageBlitCenter, but with the normal paintutils.drawImage. 'object' can be defined to use its screen size instead. paintutils.centerWithBlankSpace(table image, number x, number y, terminal object) returns 'image', but with extra blank space to center it to 'x' and 'y'. if 'x' and 'y' aren't defined, they default to half the screen width and height respectively. 'object' can be defined to use its screen size instead. --]] local round = function(x) return x + 0.5 - (x + 0.5) % 1 end local deepCopy = function(tbl) return {table.unpack(tbl)} end local bcol, ccol = { [0]=" ",[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}, {} for k,v in pairs(bcol) do ccol[v] = k end paintutils.flipY = function(image) local output = {} for y = #image, 1, -1 do output[#output+1] = image[y] end return output end paintutils.flipX = function(image) local output,sizeX = {}, 0 for y = 1, #image do sizeX = math.max(sizeX,#image[y]) end for y = 1, #image do output[y] = {} for x = 1, sizeX do output[y][x] = deepCopy(image)[y][sizeX-(x-1)] or 0 end end return output end paintutils.grayOut = function(image) local output,grays = {},{[0] = 0,[colors.white]=colors.white,[colors.orange]=colors.lightGray,[colors.magenta]=colors.lightGray,[colors.lightBlue]=colors.lightGray,[colors.yellow]=colors.white,[colors.lime]=colors.lightGray,[colors.pink]=colors.lightGray,[colors.gray]=colors.gray,[colors.lightGray]=colors.lightGray,[colors.cyan]=colors.lightGray,[colors.purple]=colors.gray,[colors.blue]=colors.gray,[colors.brown]=colors.gray,[colors.green]=colors.lightGray,[colors.red]=colors.gray,[colors.black]=colors.black} for y = 1, #image do output[y] = {} for x = 1, #image[y] do output[y][x] = grays[image[y][x]] or image[y][x] end end return output end paintutils.lighten = function(image) local output,lighters = {},{[0] = 0,[colors.white] = colors.white,[colors.orange] = colors.yellow,[colors.magenta] = colors.pink,[colors.lightBlue] = colors.white,[colors.yellow] = colors.white,[colors.lime] = colors.white,[colors.pink] = colors.white,[colors.gray] = colors.lightGray,[colors.lightGray] = colors.white,[colors.cyan] = colors.lightBlue,[colors.purple] = colors.magenta,[colors.blue] = colors.lightBlue,[colors.brown] = colors.orange,[colors.green] = colors.lime,[colors.red] = colors.magenta,[colors.black] = colors.gray} for y = 1, #image do output[y] = {} for x = 1, #image[y] do output[y][x] = lighters[image[y][x]] or image[y][x] end end return output end paintutils.darken = function(image) local output, darkers = {},{[0]=0,[colors.white]=colors.lightGray,[colors.orange]=colors.brown,[colors.magenta]=colors.purple,[colors.lightBlue]=colors.cyan,[colors.yellow]=colors.orange,[colors.lime]=colors.green,[colors.pink]=colors.magenta,[colors.gray]=colors.black,[colors.lightGray]=colors.gray,[colors.cyan]=colors.blue,[colors.purple]=colors.gray,[colors.blue]=colors.gray,[colors.brown]=colors.black,[colors.green]=colors.gray,[colors.red]=colors.gray,[colors.black]=colors.black} for y = 1, #image do output[y] = {} for x = 1, #image[y] do output[y][x] = darkers[image[y][x]] or image[y][x] end end return output end paintutils.getSize = function(image) local xsize = 0 if type(image) ~= "table" then return 0,0 end for y = 1, #image do xsize = math.max(xsize,#image[y]) end return xsize, #image end paintutils.stretchImage = function(_image,sx,sy) local image,output = deepCopy(_image), {} if sx == 0 or sy == 0 then return {{}} end if sx < 0 then image = paintutils.flipX(image) end if sy < 0 then image = paintutils.flipY(image) end sx,sy = round(math.abs(sx)), round(math.abs(sy)) if sx == 0 or sy == 0 then return {{}} end local imX,imY = paintutils.getSize(image) local xcur,ycur for y = 1, sy do output[y] = {} for x = 1, sx do output[y][x] = image[math.max(1,round((y/sy)*imY))][math.max(1,round((x/sx)*imX))] or nil end end return output end paintutils.drawImageBlit = function(image,ix,iy,object) if (type(image) ~= "table") or (type(ix) ~= "number") or (type(iy) ~= "number") then error("Expected image, x, y", 2) else object = object or term ix, iy = round(ix), round(iy) local buff for y = 1, #image do buff = "" for x = 1, #image[y] do buff = buff..bcol[image[y][x]] end object.setCursorPos(ix,iy+(y-1)) object.blit(buff,buff,buff) end end end paintutils.drawImage = function(image,ix,iy,object) if (type(image) ~= "table") or (type(ix) ~= "number") or (type(iy) ~= "number") then error("Expected image, x, y", 2) else object = object or term for y = 1, #image do object.setCursorPos(ix,iy+(y-1)) for x = 1, #image[y] do if image[y][x] == 0 then object.setCursorPos(ix+x,iy+(y-1)) else object.blit(" ","0",bcol[image[y][x]]) if x == #image[y] and y == #image then --gotta have that backwards compatibility object.setBackgroundColor(image[y][x]) end end end end end end paintutils.centerWithBlankSpace = function(_image,ix,iy,object) local image,scX,scY = deepCopy(_image) if object then scX,scY = object.getSize() else scX,scY = term.getSize() end local imgXsize,imgYsize = paintutils.getSize(image) if imgXsize == 0 or imgYsize == 0 then return {{}} end local incX,incY = math.floor((ix or (scX/2)) - (imgXsize/2)), math.floor((iy or (scY/2)) - (imgYsize/2)) local output = {} for y = 1, imgYsize + incY do output[y] = {} for x = 1, imgXsize + incX do if (x > incX) and (y > incY) then output[y][x] = image[y-incY][x-incX] or 0 else output[y][x] = 0 end end end return output end paintutils.drawImageBlitCenter = function(image,ix,iy,object) local scX,scY object = object or term if object then scX,scY = object.getSize() else scX,scY = term.getSize() end local imgXsize,imgYsize = paintutils.getSize(image) return paintutils.drawImageBlit(image, (ix or (scX/2)) - (imgXsize/2), (iy or (scY/2)) - (imgYsize/2), object) end paintutils.drawImageCenter = function(image,ix,iy,object) local scX,scY object = object or term scX,scY = object.getSize() local imgXsize,imgYsize = paintutils.getSize(image) return paintutils.drawImage(image, (ix or (scX/2)) - (imgXsize/2), (iy or (scY/2)) - (imgYsize/2), object) end paintutils.merge = function(...) local output,arg,imgXsize,imgYsize,image,xdiff,ydiff = {}, table.pack(...), 0, 0 for a = 1, #arg do local x,y = paintutils.getSize(arg[a][1]) if not (x == 0 or y == 0) then x, y = x+arg[a][2], y+arg[a][3] imgXsize = math.max(imgXsize,x) imgYsize = math.max(imgYsize,y) end end for a = #arg, 1, -1 do image,xdiff,ydiff = table.unpack(arg[a]) xdiff, ydiff = xdiff - 1, ydiff - 1 for y = 1, imgYsize do output[y] = output[y] or {} for x = 1, imgXsize do output[y][x] = output[y][x] or 0 if image[y-ydiff] then if image[y-ydiff][x-xdiff] and (image[y-ydiff][x-xdiff] ~= 0) then output[y][x] = image[y-ydiff][x-xdiff] end end end end end return output end paintutils.fullScreen = function(bgcol,object) local scr_x,scr_y = (object or term).getSize() local output,l = {},{} bgcol = bgcol or colors.black for x = 1, scr_x do l[x] = bgcol end for y = 1, scr_y do output[y] = l end return output end paintutils.unloadImage = function(image) local output = "" for y = 1, #image do for x = 1, #image[y] do output = output..bcol[image[y][x]] end if y < #image then output = output.."\n" end end return output end paintutils.autocrop = function(image) local output,top,leftings = {},1,{} local isTopped = false for a = 1, #image do if (not isTopped) and (#image[a] > 0) then top = a isTopped = true end if isTopped then output[#output+1] = deepCopy(image[a]) end end for y = 1, #output do leftings[y] = 0 for x = 1, #output[y] do if (output[y][x] == 0) or (output[y][x] == nil) then leftings[y] = leftings[y] + 1 else break end end end local left = math.min(table.unpack(leftings)) for y = 1, #output do for l = 1, left do table.remove(output[y],1) end end return output end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Reads city's construction orders in thre...
19 min ago | 2.17 KB
Feels weather through floor
34 min ago | 0.28 KB
Untitled
1 hour ago | 16.33 KB
Zzz
1 hour ago | 0.62 KB
ffix_playthrough
2 hours ago | 1.26 KB
Untitled
3 hours ago | 20.93 KB
Untitled
5 hours ago | 22.26 KB
Untitled
7 hours ago | 13.50 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!