This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
oeed's profile picture

Sketch - Photoshop Inspired Image Editor for ComputerCraft

Started by oeed, 20 March 2014 - 12:04 AM
oeed #1
Posted 20 March 2014 - 01:04 AM
Some of you may have seen that Sketch is actually included in OneOS, but I thought it was probably best to release a standalone version too. So, here it is!

I actually started making Sketch in about August last year, obviously I wasn't working on it constantly, but it did take quite a while to make. I found that paint was too basic for what I was wanting to do, it didn't support text, fill bucket, etc. NPaintPro was designed to fill this void, but I found that painful to use and it had a dynamic canvas, meaning that I'd have remove tons of space after I finished the image. So I tried to make Sketch as easy to use and as advanced as I could, and I'm quite happy with the end result.

Features
  • Easy to use 'New Document' and 'Open Document' windows.
  • Supports NFT (NPaintPro format) and NFP (paint format) as well as a proprietary format, SKCH, that supports layers.
  • A large variety of tools (Hand [for panning], Pencil, Eraser, Fill Bucket, Selection, Move [selections], Text)
  • Custom tool sizes
  • Add, rename and remove layers
  • Cut, Copying and Pasting
  • Cropping and resizing
  • And more
Screenshots
Spoiler



Installation
Simply run this on your computer, then type in 'sketch' to run.

pastebin get Mm5hd97E sketch


Including in your OS

If you're wanting to use Sketch in your OS you're most welcome to, you don't need to ask. As long as you don't modify the code and keep the name I'm fine with it. If you do want to modify it for some reason (even for OS API integration) please PM me.
Edited on 24 March 2014 - 07:50 PM
theoriginalbit #2
Posted 20 March 2014 - 01:14 AM
Looks very nice! Shame we can't have some more colours just to get the UI looking even better, but you've done really well with what we've got :)/> I definitely do like the canvas size ability, that was a major annoyance I always had with NPP :)/>

I notice you went for a serialisation to save the data in the file, is there a particular reason for this?
oeed #3
Posted 20 March 2014 - 01:23 AM
Looks very nice! Shame we can't have some more colours just to get the UI looking even better, but you've done really well with what we've got :)/> I definitely do like the canvas size ability, that was a major annoyance I always had with NPP :)/>

I notice you went for a serialisation to save the data in the file, is there a particular reason for this?
Thank you!

To be perfectly honest, it's mainly because it was going to be a lot easier to store the layer values (name, visibility, etc) doing that than making my own special thing to do it. It also means that it will be easier for other people to use the format should they so wish to do so. While it does make the images bigger the files still aren't very big at all, the largest would only get to a few kilobytes.
theoriginalbit #4
Posted 20 March 2014 - 01:33 AM
To be perfectly honest, it's mainly because it was going to be a lot easier to store the layer values (name, visibility, etc) doing that than making my own special thing to do it. It also means that it will be easier for other people to use the format should they so wish to do so. While it does make the images bigger the files still aren't very big at all, the largest would only get to a few kilobytes.
Fair enough. I'm always interested in hearing why people make particular design choices. :)/>
Is there a way to 'flatten visible image' and export to say `.npp`?
Agoldfish #5
Posted 20 March 2014 - 01:59 AM
I love it! Is there any way to get rid of the select nodes when you done with them? Also, how did you get that thin line in your computer?
theoriginalbit #6
Posted 20 March 2014 - 02:11 AM
Also, how did you get that thin line in your computer?
its the minus symbol repeated across the entire width.
oeed #7
Posted 20 March 2014 - 02:22 AM
Also, how did you get that thin line in your computer?

Do you mean the underscore? Use the text tool.
awsmazinggenius #8
Posted 20 March 2014 - 06:39 AM
Don't you think that the advanced computer check should be the first thing that happens? That way, you don't spend the tiny bit of time that it takes to load all those variables and then find out it won't work on their system.
oeed #9
Posted 20 March 2014 - 06:58 AM
Don't you think that the advanced computer check should be the first thing that happens? That way, you don't spend the tiny bit of time that it takes to load all those variables and then find out it won't work on their system.

Good point, I hadn't thought about that. I'll change that soon.
H4X0RZ #10
Posted 20 March 2014 - 08:19 AM
+4k lines o_O
Well done… Well done…
Csstform #11
Posted 20 March 2014 - 11:23 AM
I just like how smooth the UI looks. I'm gonna try this out! Good job!
theoriginalbit #12
Posted 20 March 2014 - 01:11 PM
I really wanna know, so quote again :P/>

Is there a way to 'flatten visible image' and export to say `.npp`?
Csstform #13
Posted 20 March 2014 - 05:31 PM
Feature Request:
SpoilerSimilar to CS3+, can you add some kind of a way to run a script on it?then, I could have one program call Sketch, load a script, and print something out/edit a picture.

Request:
SpoilerDo I have permission to use the proprietory file of .skch for PokeCC? I want to check before I just up and use it.

Comments:
I really enjoy this, not sure how good it is compared to nf's paint program (never used it), but I really like it. WAY better than default. I especially like the specified sizes, and transparency. Also: I like that first screenie. ;)/>
TheOddByte #14
Posted 20 March 2014 - 07:31 PM
Really nice that you released this! Love the UI as always! :D/>
oeed #15
Posted 20 March 2014 - 08:35 PM
I really wanna know, so quote again :P/>

Is there a way to 'flatten visible image' and export to say `.npp`?
Ah, yea, sorry about not replying to that.

Yes, I'll try to add that ASAP.

Feature Request:
SpoilerSimilar to CS3+, can you add some kind of a way to run a script on it?then, I could have one program call Sketch, load a script, and print something out/edit a picture.

Request:
SpoilerDo I have permission to use the proprietory file of .skch for PokeCC? I want to check before I just up and use it.

Comments:
I really enjoy this, not sure how good it is compared to nf's paint program (never used it), but I really like it. WAY better than default. I especially like the specified sizes, and transparency. Also: I like that first screenie. ;)/>
I'm not too sure what the scripts would do to be honest, can you elaborate.

You're welcome to use .skch for anything, although, it's probably best to create it in .skch and convert it to .nfp (which I mentioned above) as there's no need to have layers for games.

Really nice that you released this! Love the UI as always! :D/>
Thanks!
Agoldfish #16
Posted 21 March 2014 - 03:43 PM
Bug: When you use .nfp, it gives you a message urging you to switch from .nst to .nfp when your using .nfp anyway.
JustPingo #17
Posted 21 March 2014 - 04:06 PM
Pretty awesome.
Really useful and easy to use.

A (pretty big) suggestion : add a way to create animations, and make them automated (a little like Flash, you say "hey layer 3, move one pixel up please").
Csstform #18
Posted 21 March 2014 - 07:04 PM
When I suggested scrips, I was half asleep or something, I can't think of a single use. An eyedropper might be nice though.
pasilein007 #19
Posted 21 March 2014 - 08:06 PM
Pastebin has a error reported

"pastebin:101: attempt index ? (a nil value)"
oeed #20
Posted 21 March 2014 - 09:20 PM
Bug: When you use .nfp, it gives you a message urging you to switch from .nst to .nfp when your using .nfp anyway.
Ah, thanks.

Pretty awesome.
Really useful and easy to use.

A (pretty big) suggestion : add a way to create animations, and make them automated (a little like Flash, you say "hey layer 3, move one pixel up please").
Well, it's not really designed for animation really. I never see anyone ever use NPaintPros animated images anyway really. I just don't think it's worth the effort.

When I suggested scrips, I was half asleep or something, I can't think of a single use. An eyedropper might be nice though.
I did originally have an eyedropper. But because screen space is so limited having tons of tools reduced the number of layers you could see. There's only 16 colours, it's not that hard to figure out which one it is.

Pastebin has a error reported

"pastebin:101: attempt index ? (a nil value)"
That's an error with Pastebin it self. Is it the vanilla version?

I've looked at the Pastebin code and that's when it's writing. I'd say the file name is already used or you're not using the normal version of Pastebin.
Edited on 21 March 2014 - 08:23 PM
TheOddByte #21
Posted 21 March 2014 - 09:30 PM
Pastebin has a error reported

"pastebin:101: attempt index ? (a nil value)"
Test doing

edit pastebin
to see if you have a modified version of pastebin, If it does then goto that line and post it.
Or you can just delete that version :P/>
awsmazinggenius #22
Posted 23 March 2014 - 06:42 PM
Nope, I occasionally get that error too, and I haven't done something stupid like modified Pastebin or the rom. Even on a free reboot on a newly placed computer I can get that.

Edit: Hellkid, only 10 more posts until you get your custom title, start thinking about it!
Edited on 23 March 2014 - 05:43 PM
oeed #23
Posted 23 March 2014 - 08:47 PM
Edit: Hellkid, only 10 more posts until you get your custom title, start thinking about it!

I thought of the one I'm using at about 500 :P/>
Chickenbreadlp #24
Posted 24 March 2014 - 02:34 PM
Could i use this for my OS. It is called ApfelOS and i will give credit.
oeed #25
Posted 24 March 2014 - 08:49 PM
Could i use this for my OS. It is called ApfelOS and i will give credit.

Sure!

To anyone else wanting to use Sketch in your OS you're most welcome to. As long as you don't modify and keep the name I'm fine with it. If you do want to modify it for some reason (even for OS API integration) please PM me.
awsmazinggenius #26
Posted 24 March 2014 - 11:59 PM
I've been working on Creative Craft Image Shack for a little bit now (my image editor for CC and OC in one file) and one thing that I'm adding is Undo. I think it might be something worth adding into Sketch and Ink, too.
Edited on 24 March 2014 - 10:59 PM
oeed #27
Posted 25 March 2014 - 12:18 AM
I've been working on Creative Craft Image Shack for a little bit now (my image editor for CC and OC in one file) and one thing that I'm adding is Undo. I think it might be something worth adding into Sketch and Ink, too.

If you look in the menu options is actually there, I just never got around to adding it. One of the issues is knowing how far back to revert to.
awsmazinggenius #28
Posted 30 March 2014 - 05:28 AM
EDIT:
Since I only edited my post instead of creating a new one, I'm not sure oeed has actually seen the report. Hence, I'm going to have to double post, and ask to have my old one deleted.
oeed #29
Posted 30 March 2014 - 05:47 AM
EDIT:
Since I only edited my post instead of creating a new one, I'm not sure oeed has actually seen the report. Hence, I'm going to have to double post, and ask to have my old one deleted.

Fixed.
TableCraft0R #30
Posted 12 June 2014 - 01:08 PM
How do I render skch images? [ like paintutills.loadImage? ]
oeed #31
Posted 12 June 2014 - 11:38 PM
How do I render skch images? [ like paintutills.loadImage? ]

If you take a look at the bottom of the code (https://github.com/oeed/OneOS/blob/master/Programs/Sketch.program/startup) you'll find the functions I use.


function ReadSKCH(path)
local _fs = fs
if OneOS then
  _fs = OneOS.FS
end
local file = _fs.open(path, 'r')
local _layers = textutils.unserialize(file.readAll())
file.close()
local layers = {}
for i, l in ipairs(_layers) do
  local layer = {
   Name = l.Name,
   Pixels = ParseNFT(l.Pixels),
   BackgroundColour = l.BackgroundColour,
   Visible = l.Visible,
   Index = l.Index,
  }
  table.insert(layers, layer)
end
return layers
end

function ParseNFT(lines)
local pixels = {}
for y, line in ipairs(lines) do
  local bgNext, fgNext = false, false
  local currBG, currFG = nil,nil
  local writePosition = 1
  for x = 1, #line do
   if not pixels[writePosition] then
    pixels[writePosition] = {}
   end
   local nextChar = string.sub(line, x, x)
		    if nextChar:byte() == 30 then
				    bgNext = true
		    elseif nextChar:byte() == 31 then
				    fgNext = true
		    elseif bgNext then
				    currBG = getColourOf(nextChar)
				    if currBG == nil then
					 currBG = colours.transparent
				    end
				    bgNext = false
		    elseif fgNext then
				    currFG = getColourOf(nextChar)
				    fgNext = false
		    else
				    if nextChar ~= " " and currFG == nil then
						    currFG = colours.white
				    end
				    pixels[writePosition][y] = {BackgroundColour = currBG, TextColour = currFG, Character = nextChar}
				    writePosition = writePosition + 1
		    end
  end
end
return pixels
end

It's essentially just a table of NFT files.
awsmazinggenius #32
Posted 14 June 2014 - 11:18 PM
Now that this is bumped, it seems that you use the serialization from textutils to serialize data. Have you considered copy-pasting the old CC1.58 textutils.serialize() function into your code to make file sizes smaller, as CC1.6 now serializes in a pretty fashion rather than a compact fashion? You can still unserialize data serialized with the old function with the current textutils.unserialize(), so it would give a smaller file.
Lego Stax #33
Posted 02 August 2014 - 06:29 PM
I don't think I was ever using .NFT….

[attachment=1834:oneos bug.png]
Not-A-Spammer #34
Posted 02 August 2014 - 09:30 PM
Look's Awesome. Great Job!!
ade125 #35
Posted 28 October 2014 - 09:46 AM
Can I export to png?
oeed #36
Posted 28 October 2014 - 10:12 AM
Can I export to png?
There are a few other programs that will let you do that, but no, Sketch can't.
ade125 #37
Posted 28 October 2014 - 01:10 PM
Can I export to png?
There are a few other programs that will let you do that, but no, Sketch can't.
Can you list a few? would be perfect for concept art.
Endergreen117 #38
Posted 27 November 2014 - 08:17 AM
So far it's been great! It's a lot better than NPaintPro, and FAR better than the default Paint that's included with cc. Keep up the good work!

REQUEST: After using this program for a little bit, I've realized the inconvenience of the lack of a "Save As…" option. This would make the program complete, in my opinion. However, other than that small, annoying bit, this program is great.
ByteMe #39
Posted 13 December 2014 - 11:28 AM
Just a note, the ability to right click to erase and have two colours on the go would be very handy.
oeed #40
Posted 15 December 2014 - 07:34 AM
So I've been working on a brand new version of Sketch. It uses Bedrock, my GUI API, to make everything easier and awesomer. It's pretty much a complete recode, the only original code is the loading and saving code, which I've still modified.

It's not quite ready, but it's pretty close. There's bound to be a few bugs here and there, so if you'd like to beta test it you can do so as such:

pastebin get QHE2JDPp sketch

I'll go in to more details about the new features once it's released, but here's a few:
  • 'Flatten' images
  • No more sidebar - everything is done with windows, you can move them and redock them
  • Resize images (not as in crop, as in double the size of pixels or whatever)
  • Zooming (kinda like above)
  • Undo and redo
  • Save as (and in whatever format you want)
  • Filters (think Photoshop adjustment layers, such as black and white, invert, etc)
  • Filter masks, again, think Photoshop adjustment layer masks
  • Two current colours, left click for the first colour right for the second
  • Spray can (like the one in MS Paint, kinda useless, but meh)
  • More stuff I've forgotten about
Edited on 15 December 2014 - 06:52 AM
AlkamlBan #41
Posted 16 December 2014 - 05:59 PM
You really should add the ability to add colored characters (slashes, comas etc.) because many people use them to create shapes that the pixels just can't produce.
Exerro #42
Posted 16 December 2014 - 06:04 PM
You really should add the ability to add colored characters (slashes, comas etc.) because many people use them to create shapes that the pixels just can't produce.
As far as I'm aware, you can using the text tool. Unless he has removed this in a newer version, you definitely can as I've done it before.

If you're talking about the beta, it's a beta, and he probably hasn't had time to implement it yet.
AlkamlBan #43
Posted 16 December 2014 - 06:10 PM
You really should add the ability to add colored characters (slashes, comas etc.) because many people use them to create shapes that the pixels just can't produce.
As far as I'm aware, you can using the text tool. Unless he has removed this in a newer version, you definitely can as I've done it before.

If you're talking about the beta, it's a beta, and he probably hasn't had time to implement it yet.

Don't know I haven't really seen what it does but I just mentioned it cause I would really like such a feature
Exerro #44
Posted 16 December 2014 - 06:13 PM
Just checked…
Spoiler
It has text support, with colours too.
oeed #45
Posted 16 December 2014 - 10:43 PM
Yea, it certainly has text support. I've done a few small updates and I've uploaded them, it's mainly bug fixes though. The earlier beta may not have had text support though, but this version definitely does.
Admiraltallcactus #46
Posted 08 July 2015 - 04:05 AM
Can I print .skch with pantutils.drawImage()?
Exerro #47
Posted 08 July 2015 - 09:54 AM
No, it saves in its own format, but you can save to paintutils format I believe (although this strips out the text).
oeed #48
Posted 08 July 2015 - 10:27 AM
Can I print .skch with pantutils.drawImage()?
Yeah Ben hit the nail on the head really. Sketch just uses NFT for the most part, the rest is just a serialised table you can easily decode with textutils. Reading NFT isn't incredibly straight forward, but not impossible. You'd probably be best to either look and see if there's an Ask a Pro topic/tutorial or look through the code of Sketch (there's something in the Objects folder that does it) or the NPaintPro code.
Admiraltallcactus #49
Posted 09 July 2015 - 05:18 AM
Can I print .skch with pantutils.drawImage()?
Yeah Ben hit the nail on the head really. Sketch just uses NFT for the most part, the rest is just a serialised table you can easily decode with textutils. Reading NFT isn't incredibly straight forward, but not impossible. You'd probably be best to either look and see if there's an Ask a Pro topic/tutorial or look through the code of Sketch (there's something in the Objects folder that does it) or the NPaintPro code.
Thank you for the help oeed
Thefdjurt #50
Posted 10 July 2015 - 06:18 PM
This is awesome, I have planned to download this a never had a need to edit images in CC until now and this made it a lot easier.
With that said I have found a bug :(/>.
I was attempting to resize a 19x51 image to 51x19 and I got


sketch:439: attempt to index ? (a nil value)

Recreating the bug:
  1. Make an image (the format and background colour does not matter) of any proportions (as long as the height is larger than that of the width (e.g. 5x10))
  2. Resize the image making the width any amount larger (e.g. 5->6) and the height any amount smaller (e.g. 10->9).
The error occurs in the layer draw function on the x=[new width] y=[new height]. I sorry if I am not too much of a help in this, I have yet to look a the code in an editor that isn't the CC editor.
oeed #51
Posted 12 July 2015 - 10:26 AM
This is awesome, I have planned to download this a never had a need to edit images in CC until now and this made it a lot easier.
With that said I have found a bug :(/>.
I was attempting to resize a 19x51 image to 51x19 and I got


sketch:439: attempt to index ? (a nil value)

Recreating the bug:
  1. Make an image (the format and background colour does not matter) of any proportions (as long as the height is larger than that of the width (e.g. 5x10))
  2. Resize the image making the width any amount larger (e.g. 5->6) and the height any amount smaller (e.g. 10->9).
The error occurs in the layer draw function on the x=[new width] y=[new height]. I sorry if I am not too much of a help in this, I have yet to look a the code in an editor that isn't the CC editor.

Hmm yeah sorry about that. You could try using Sketch 2 (I think you might need to download the files from the OneOS GitHub (just use download ZIP on the main page and copy it out) https://github.com/oeed/OneOS/tree/master/Programs/Sketch.program.

I'm working on Silica at the moment which will certainly have an image editor. Until then there's not a ton I can do sorry.
LDDestroier #52
Posted 13 July 2015 - 04:37 PM
Small bug, when you hide the interface and try using the brush on part of the canvas that would be behind a button, that button is pressed.

Damn this thing is amazing! Why isn't this in computercraft by default?
Waitdev_ #53
Posted 19 July 2015 - 12:36 PM
how does this only have 2 +1's? this is epic :D/>

btw i just beat someone in the top 20 posters today o.O
ReBraLaCC #54
Posted 10 October 2015 - 01:16 PM
Is there a way to print the image on screen?
oeed #55
Posted 11 October 2015 - 07:32 AM
Is there a way to print the image on screen?

What do you mean by print? So, not printing on paper I presume.

If you save it as NFP you can can open it in paint. Alternatively, install nPainPro and save it as an NFT file.
jacob7ism #56
Posted 31 October 2015 - 03:52 PM
another amazing 11/10 program by oeed :D/>

This paint program looks AMAZING! Will be using this a lot. And by a lot, I mean A LOT. :D/>
jakejakey #57
Posted 20 October 2016 - 01:09 PM
Love the program so much! All of your programs inspire me to try and cross my comfort zone (in coding)

Anyway I really love the program, and want to use it to make a background for my new OS.

Is there an API made by you or nitrofingers that I can use for this?
Bomb Bloke #58
Posted 20 October 2016 - 01:45 PM
More or less.
oeed #59
Posted 20 October 2016 - 09:16 PM
You can also take a look at the formats' specifications here.
WattDev #60
Posted 08 April 2017 - 06:07 AM
Here are some of my questions:
How to load the image in .skch format?
Are there some api that can load the image crated using Sketch?
oeed #61
Posted 08 April 2017 - 10:29 PM
Here are some of my questions:
How to load the image in .skch format?
Are there some api that can load the image crated using Sketch?

No unfortunately there is not an API. It is a fairly simple format though, it's just a textutils serialised table with NFTs in it. I'd take a look at the code and reverse engineer it.
WattDev #62
Posted 15 April 2017 - 12:13 PM
Here are some of my questions:
How to load the image in .skch format?
Are there some api that can load the image crated using Sketch?

No unfortunately there is not an API. It is a fairly simple format though, it's just a textutils serialised table with NFTs in it. I'd take a look at the code and reverse engineer it.
Well I don't know how to load the skch format