65 posts
Posted 24 August 2013 - 07:23 PM
Here's a new API I nmade:
The Fill API.
It adds a single function which is fillScreen(colour). It fills your screen with a color.
Features:
- Works with any screen size.
- Automatically alerts you when you have a normal computer.
Download:
http://pastebin.com/U3Lb4NQNOr type into your computer:
pastebin get U3Lb4NQN fillapi
Example code:
http://pastebin.com/5ujDCYNsOr type into the computer:
pastebin get 5ujDCYNs test
Ctrl+T to quit for bottom one.
Changelog:
v1.1:
To-do:
1604 posts
Posted 24 August 2013 - 07:49 PM
Easier way:
local function fillScreen(color)
term.setBackgroundColor(color)
term.clear()
end
1852 posts
Location
Sweden
Posted 24 August 2013 - 09:31 PM
So let's get this straight.. You made an API for just filling the screen with a color?
And you can just do as MysticT said above..
331 posts
Posted 24 August 2013 - 11:20 PM
also your code isnt even efficent for what it does mysticT's is the best way
but this is a more efficent your way
function fill(c) -- c = color
if term.isColor() then
w,h = term.getSize()
term.setBackgroundColor(c)
for y = 1, h do
for x = 1, w do
term.setCursorPos(x,y)
write(" ")
end
end
else
error("Not An Advanced Computer/Turtle/Monitor", 0)
end
end
65 posts
Posted 27 August 2013 - 04:20 PM
Easier way:
local function fillScreen(color)
term.setBackgroundColor(color)
term.clear()
end
Thanks! Will be in next release!
65 posts
Posted 27 August 2013 - 04:41 PM
Had to get a new code. Promise it won't happen again!
v1.1 is out now:
- Shrunk code. Thanks to MysticT for the code!
1688 posts
Location
'MURICA
Posted 27 August 2013 - 04:52 PM
Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
331 posts
Posted 27 August 2013 - 05:42 PM
Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already
1604 posts
Posted 28 August 2013 - 02:03 PM
Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already
Not really. There isn't a function in the paintutils api for that (at least there wasn't the last time I checked).
Here's a function for that:
function fillArea(x, y, w, h, color)
if color then
term.setBackgroundColor(color)
end
local line = string.rep(" ", w)
for i = 0, h-1 do
term.setCursorPos(x, y + i)
term.write(line)
end
end
That's the most efficient way to do it in CC. You could also add some checks to avoid drawing outside of the screen and save a few loops.
65 posts
Posted 30 August 2013 - 05:14 AM
Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
Will add fillRow(row, color) and fillColumn(column, color) soon!
331 posts
Posted 30 August 2013 - 07:00 AM
Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already
Not really. There isn't a function in the paintutils api for that (at least there wasn't the last time I checked).
Here's a function for that:
function fillArea(x, y, w, h, color)
if color then
term.setBackgroundColor(color)
end
local line = string.rep(" ", w)
for i = 0, h-1 do
term.setCursorPos(x, y + i)
term.write(line)
end
end
That's the most efficient way to do it in CC. You could also add some checks to avoid drawing outside of the screen and save a few loops.
I believe its
paintutils.drawLine(startX,startY,endX,endY, color)
7508 posts
Location
Australia
Posted 30 August 2013 - 07:05 AM
Would be at least somewhat useful if you could fill in a specific area of the screen, rather then being limited to just the entire screen.
yeh but that's practically in paintutils already
Not really. There isn't a function in the paintutils api for that (at least there wasn't the last time I checked).
Here's a function for that:
function fillArea(x, y, w, h, color)
if color then
term.setBackgroundColor(color)
end
local line = string.rep(" ", w)
for i = 0, h-1 do
term.setCursorPos(x, y + i)
term.write(line)
end
end
That's the most efficient way to do it in CC. You could also add some checks to avoid drawing outside of the screen and save a few loops.
I believe its
paintutils.drawLine(startX,startY,endX,endY, color)
No paintutils.drawLine draws
a line, where as MysticT's solution draws
boxes on the screen with the given width and height, at the given x and y position.
28 posts
Location
pcapi.location
Posted 18 September 2013 - 01:32 PM
I was working on an API, which has fill screen and draw line lol, but it's just fillScreen(String color) or drawLine(String color, int line) (ik it's not java, but just clearing out that for you). I also have checkerboard, but sometimes it's behaving quite weird. I got it worked out now =)
28 posts
Location
pcapi.location
Posted 22 September 2013 - 10:30 AM
Soo… I can see your code doesn't have drawLine and drawColumn yet… I would actually give you negative reputation. In one post, you said that for catching right clicks just check for "right" parameter. It's not "right", it's 2. I'm not trying to advertise myself here, but I have better screen filling - just like the suggestion in comments, it can fill a specific area. If you want to fill the entire screen, just do pcapi.backCl(color, true). Do you even put effort to your code? Your status is "Script Kiddie", how do you then fail to do such simple tasks? If you want help, please watch Direwolf20's videos or if you already watched them, ask me for help or read everything in Ask A Pro. If you know how to code, don't post sxxx. Thanks.
1852 posts
Location
Sweden
Posted 21 October 2013 - 01:40 PM
Sorry for kinda digging up the dead but… I just want to point out that this doesn't even work anymore :P/>
I looked at it in pastebin and well.. Look in the spoiler below
Error
function fillScreen(colourans) -- Here it's colourans
if term.isColor() then
term.setBackgroundColor(colorans) -- Here it's colorans
term.clear()
else
error("Advanced Monitor/Turtle Needed")
end
end
And you should maybe extend your "API" a little if you want it to actually be considered an API rather than just a function.
Here's a small list of stuff you could add
* Box drawing
* Line drawing
* Circle drawing
- Hellkid98
51 posts
Posted 29 December 2013 - 06:26 AM
The code doesn't even work (Parameter doesn't match):
function fillScreen(colourans)
if term.isColor() then
term.setBackgroundColor(colorans)
term.clear()
else
error("Advanced Monitor/Turtle Needed")
end
end
128 posts
Location
Poland
Posted 29 December 2013 - 09:55 AM
It's useless.