Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

newbie question about canvas

A topic by 7acques created Jul 15, 2024 Views: 260 Replies: 5
Viewing posts 1 to 3
(+1)

I have just started using Decker, and I am amazed by its expressiveness.

however, I cannot figure out the right way to use Canvas.

I read from the document, that I can use [edit]->[paste as a new canvas] to create a canvas with images from clipboard. but when I copy a png image file from my Windows PC desktop, and then try to do exactly the same, I find that the bottom [paste as new canvas] is grayed out.

after a few hours, I found out that I could drag the PNG image file into decker, with the same effect as [file]->[import image], then I ctrl-c, switch to widget mode, then the [paste as new canvas] button is clickable and work like a charm.

I wonder, is this the expected way to put a PNG image file into a Decker canvas widget? if not, what’s the more convenient way? if it is so, I’m perfectly fine with it, but after several times of fiddling, I always feel there’s more things going on underneath, and I want to work with Decker the intended way.

(+1)

I think this is as expected. Copying and pasting images in Decker (including pasting as a canvas) seems to only work with images in Decker's internal image format (you'll note if you try to copy an image out of Decker into something else it comes out as a bunch of text).

I think dragging an image into Decker and then copying and pasting it from there into a canvas is certainly not an unintended way of using Decker, like there is nothing wrong with doing it that way. But another method is using the read[] function. With a canvas named canvas1, try this in the Listener

canvas1.paste[read["image"]]

(you'll need to press shift+enter after typing it to make it run)

It works a bit differently, since it doesn't resize the image to fit, and it doesn't apply dithering. By default it converts to Decker's 16-color palette, but there's some options listed in the manual for having it work differently. If you want to bring in images using Decker's characteristic dithered 1-bit style, then the way you're doing it is probably the easiest.

(+1)

thanks! you totally anwsered my question! i haven’t really getting used to use the repl, your reply really helped a lot! now I’m thinking of using listener more frequently.

Developer

Millie is correct; Decker doesn't attempt to manipulate native image data in the system clipboard; it's very difficult to do that sort of thing in a cross-platform fashion, especially once web browsers are added to the mix.

Decker uses a custom text encoding for information stored in the clipboard. If you're interested, it's described in The Decker Document Format. This is also the same format for images you can obtain with the ".encoded" attribute of image interfaces.

Keep in mind that anything you find yourself doing repeatedly in the Listener can be moved to a button script, and parameterized with other widgets. Use Decker to build tools to remove tedium from working on your projects!

(+1)

understand! i haven’t thought about the technical difficulty of manipulating native files. your advice on using decker to build tools to help building deck is mind-blowing, yet makes a lot of sense! great thx for developing this amazing tool!

Developer

Whenever I design new contraptions, I end up making little scaffolds and one-off tools:

The best part is that highly specialized tools that only do exactly the thing you need tend to be much simpler than writing general, reusable tools. 

Blurring the lines between "writing an application" and "using an application" produces a very unique and pleasant way of working. :)