Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MANAGER_PRINT("FeynmanTechnologies Graphics Library is running!",255,125,0)
- --CHANGELOG: Added save-to-script conversion, fake deco. If you want something really good use Mniip's.
- --CHANGELOG: Added image plotting (Almost all by Mniip, just barely edited), line, property line, line with color
- --r,g,b, monochrome image plotting with threshold (Also based off of Mniip's script)
- ---FeynmanTechnologies Graphics Library---
- --------Plugins--------
- --Draws a shade using a property at x,y
- function ftgl_propshade(element,property,value,x,y)
- tpt.create(x,y,element)
- tpt.set_property('type',element,x,y)
- tpt.set_property(property,value,x,y)
- end
- --Anti-alias the deco layer from firstx,firsty to secondx,secondy
- function ftgl_antialias(firstx,firsty,secondx,secondy)
- for x=firstx,secondx do
- for y=firsty,secondy do
- decocolor = (((tpt.get_property('dcolor',x-1,y)+tpt.get_property('dcolor',x+1,y))/2)+tpt.get_property('dcolor',x,y))/2
- tpt.set_property('dcolor',decocolor,x,y)
- end
- end
- end
- --Draw a solid rectangle in an element
- function ftgl_rect(element,firstx,firsty,secondx,secondy)
- for x=firstx,secondx do
- for y=firsty,secondy do
- tpt.create(x,y,1)
- tpt.set_property('type',element,x,y)
- end
- end
- end
- --Draw a rectangle in an element
- function ftgl_hollowrect(element,xwidth,ywidth,firstx,firsty,secondx,secondy)
- for x=firstx,secondx do
- for y=firsty,secondy do
- tpt.create(x,y,1)
- tpt.set_property('type',element,x,y)
- end
- end
- for x=firstx+xwidth,secondx-xwidth do
- for y=firsty+ywidth,secondy-ywidth do
- tpt.set_property('type',0,x,y)
- end
- end
- end
- --Draw a solid rectangle in a property
- function ftgl_proprect(property,value,firstx,firsty,secondx,secondy)
- for x=firstx,secondx do
- for y=firsty,secondy do
- tpt.set_property(property,value,x,y)
- end
- end
- end
- --Draw a rectangle in a property
- function ftgl_hollowproprect(property,value,xwidth,ywidth,firstx,firsty,secondx,secondy)
- for x=firstx,secondx do
- for y=firsty,firsty+ywidth do
- tpt.set_property(property,value,x,y)
- end
- for y=secondy,secondy-ywidth do
- tpt.set_property(property,value,x,y)
- end
- for y=firsty,secondy do
- for x=firstx,firstx+xwidth do
- tpt.set_property(property,value,x,y)
- end
- for x=secondx,secondx-xwidth do
- tpt.set_property(property,value,x,y)
- end
- end
- end
- end
- --Draws a line from x1,y1 to x2,y2 in a certain element
- function ftgl_line(element,x1,y1,x2,y2)
- x=x1
- y=y1
- for x=x1,x2 do
- tpt.create(x,y,element)
- y=y+(y2-y1)/(x2-x1)
- end
- for y=y1,y2 do
- tpt.create(x,y,element)
- x=x+(x2-x1)/(y2-y1)
- end
- end
- --Draws a line from x1,y1 to x2,y2 in a certain property
- function ftgl_propline(property,value,x1,y1,x2,y2)
- x=x1
- y=y1
- for x=x1,x2 do
- tpt.set_property(property,value,x,y)
- y=y+(y2-y1)/(x2-x1)
- end
- for y=y1,y2 do
- tpt.set_property(property,value,x,y)
- x=x+(x2-x1)/(y2-y1)
- end
- end
- --Draws a line from x1,y1 to x2,y2 in color r,g,b
- function ftgl_colorline(element,x1,y1,x2,y2,r,g,b)
- x=x1
- y=y1
- for x=x1,x2 do
- tpt.create(x,y,element)
- tpt.set_property('dcolor',r*65536+g*256+b+16777216*255,value,x,y)
- y=y+(y2-y1)/(x2-x1)
- end
- for y=y1,y2 do
- tpt.create(x,y,element)
- tpt.set_property('dcolor',r*65536+g*256+b+16777216*255,value,x,y)
- x=x+(x2-x1)/(y2-y1)
- end
- end
- --------Stand-Alone Functions--------
- --Creates a script to recreate a save
- function savetoscript()
- scriptname=tpt.input("Script Name","This will be the name of the created script")
- local file = io.open(scriptname, "w")
- for x=5,607 do
- for y=5,375 do
- elemtype=tpt.get_property('type',x,y)
- if elemtype ~= 0 and elemtype ~= 'none' then
- decocolor=tpt.get_property('dcolor',x,y)
- lifeval=tpt.get_property('life',x,y)
- tempval=tpt.get_property('temp',x,y)
- tmpval=tpt.get_property('tmp',x,y)
- tmptwoval=tpt.get_property('tmp2',x,y)
- ctypeval=tpt.get_property('ctype',x,y)
- file:write("tpt.create(",x,",",y,",",elemtype,")\n")
- file:write("tpt.set_property('dcolor',",decocolor,",",x,",",y,")\n")
- file:write("tpt.set_property('life',",lifeval,",",x,",",y,")\n")
- file:write("tpt.set_property('temp',",tempval,",",x,",",y,")\n")
- file:write("tpt.set_property('tmp',",tmpval,",",x,",",y,")\n")
- file:write("tpt.set_property('tmp2',",tmptwoval,",",x,",",y,")\n")
- file:write("tpt.set_property('ctype',",ctypeval,",",x,",",y,")\n")
- end
- end
- end
- end
- --Fake Deco (uses EMBR's ctype instead of deco to make color). I don't know if it works yet, but when it does it will make a nice way to display deco in the save preview.
- function fakedeco()
- for x=5,607 do
- for y=5,375 do
- if tpt.get_property('type',x,y) > 0 then
- decocolor = 0
- decocolor = tpt.get_property('dcolor',x,y)
- elemtype = tpt.get_property('type',x,y)
- end
- if decocolor ~= 0 then
- tpt.set_property('type','embr',x,y)
- tpt.set_property('ctype',decocolor,x,y)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement