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

Canvas - Multi-Window Image Editor with Text Support (Alpha 2)

Started by Kingdaro, 23 March 2013 - 10:35 PM
Kingdaro #1
Posted 23 March 2013 - 11:35 PM
Canvas

About
I wanted to make this as a program for someone's OS, but I thought it'd be neat if it had its own nice little window management system. Obvious inspiration from PearOS, the OS in question.

Canvas is mainly used for simply editing multiple images at once, and also being able to have text/ascii art in your images, saved in a neat, easy-to-use format. Obviously since not many programs today know of or use this format, the editor also allows you to save your images as "script objects," where you can load them from a script, and draw them accordingly, without the need for an external API.

myImage = dofile('path/to/image/file')
myImage:draw(5,5)

Canvas can also load images from the default paint program.

Usage
I can imagine the editor being a bit of a learning curve, but here's the run-down:
  • Right-click outside of a window:
    • New.. - Make a new image. Creates a new window for that image with the specified name.
    • Open.. - Open an image.
    • Exit - Leave the program.
  • Right-click the title bar of an image:
    • Load.. - replace the current image of that window with a new one from file
    • Save - Save your image. It will be saved with the name/path you've given on creation.
    • Save as Script Object - Save your image with the ability to be loaded with dofile() and drawn.
    • Rename - Give the image a new name.
    • Close - Close the window.
  • Editing controls:
    • Click and drag the titlebar to move windows around.
    • Click and drag the pixel to the bottom right of the window to resize your image. Not actually in the window, the corner right outside of it.
    • Double click the title bar of a window to maximize/minimize it.
    • Press tab to switch between windows.
    • Left-click/drag in the window to draw your image. A gray background with white dots is transparency.
    • Right-click/drag to erase.
    • Middle-click to pick a color.
    • Click the colored pixel in the top-right of the window to change the current painting color for that window.
    • Press left ctrl to change from painting to typing/ascii mode in the selected window. Type to input characters like you normally would, click and use arrow keys to change cursor position.
If you play around with it a bit you should find your way around pretty easily.

Additional Notes
This program is merely a preview, is missing some planned features, and is bound to have a couple of bugs or two, so don't expect it to be perfect.

When you resize an image, only what is visible in that window will be saved. The rest of the image is trimmed from the file. Keep that in mind.

A lot of comments in the code are either planned features, or just implemented features I forgot to take note of.

Screenshots
Spoiler








Download
pastebin get uekZ70QR canvas
kornichen #2
Posted 24 March 2013 - 02:12 AM
Very cool :D/>
theoriginalbit #3
Posted 24 March 2013 - 02:17 AM
very nice :)/>

Improvement to the code tho

local function tocolor(hex)
  return 2 ^ tonumber(hex, 16)
end
and why are you adding 1 in the tohex function? o.O it should just be math.floor( log2( colour ) ) where log2 is the log© / log(2)
svdragster #4
Posted 24 March 2013 - 02:42 AM
Wow, epic!

I found two bugs:
When changing the mode with ctrl and delete something written, there will be a gray background without dots,
and it's possible to write without being in typing-mode :P/>

This program is awesome anyways.
GravityScore #5
Posted 24 March 2013 - 03:16 AM
Very, very nice!!! :D/>

Love the GUI!

EDIT: suggestion: could the image go full screen when you double click the title bar, instead of having to resize it? So the image takes up all but the first line, which the title bar takes up?
Kingdaro #6
Posted 24 March 2013 - 09:25 AM
Wow, epic!

I found two bugs:
When changing the mode with ctrl and delete something written, there will be a gray background without dots,
That's not a bug. When you use text, it has to have a background. When drawing the image, I can't get the color behind text, therefore transparency is basically impossible. You'll notice that if you erase the background in paint mode, the text goes too.

and it's possible to write without being in typing-mode :P/>/>

This program is awesome anyways.
Oh sh-


Very, very nice!!! :D/>/>

Love the GUI!

EDIT: suggestion: could the image go full screen when you double click the title bar, instead of having to resize it? So the image takes up all but the first line, which the title bar takes up?
I didn't think full screen was necessary at first, but alright.

very nice :)/>

Improvement to the code tho

local function tocolor(hex)
  return 2 ^ tonumber(hex, 16)
end
and why are you adding 1 in the tohex function? o.O it should just be math.floor( log2( colour ) ) where log2 is the log© / log(2)
Thanks for the tips. I added 1 because the string I'm using is indexed by 1 instead of 0, and where log(1) / log(2) is 0, it doesn't find a correct index in the string.
theoriginalbit #7
Posted 24 March 2013 - 02:18 PM
Thanks for the tips. I added 1 because the string I'm using is indexed by 1 instead of 0, and where log(1) / log(2) is 0, it doesn't find a correct index in the string.
Oh yeh of course…. derp :P/>
Kingdaro #8
Posted 25 March 2013 - 09:19 AM
Updated.
  • Windows can be maximized through double-clicking. You can access the global menu (the one you get by clicking the background) through the dot in the top-left of the window.
  • Migrated the image windows to a new window object system thingamajig, and I plan to use this to create a nice open/save dialogue.
  • Text colors and painting colors are separate.
  • Various bug fixes and other stuff I forgot about
oeed #9
Posted 25 March 2013 - 10:09 AM
Nice
kornichen #10
Posted 25 March 2013 - 10:02 PM
Am I allowed to implementate it into the KREOS OrbitStore?
Kingdaro #11
Posted 26 March 2013 - 08:02 AM
Go ahead.
superaxander #12
Posted 28 March 2013 - 08:59 AM
This is cool looking…Mind blown…