NaaLaa
nPixel - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Code (https://www.naalaa.com/forum/forum-4.html)
+--- Thread: nPixel (/thread-191.html)



nPixel - johnno56 - 01-29-2025

Hi Marcus,

I have not implemented your code yet... by the way, it looks very similar to the old drawing program routine - I think you may have provided that one as well... how quickly I forget... lol

I will provide you with what I have at the moment....

Functionality: Selecting colours; Drawing and Erasing to and from the main screen; Selecting tile size (8, 16 and 32) all work. When changing resolutions the main canvas is erased. I am planning on an 'Are you sure?' to be displayed if the main canvas is 'occupied'.

As it only makes one tile, other functions like 'Line'; 'Fill', 'Circle' etc., seemed to be a lot more work. All I needed was to be able to Draw, Save and Load...

As always... open to suggestions.

It's really 'bare bones' but closer to what I had originally planned...


.zip   nPixel.zip (Size: 154.28 KB / Downloads: 7)

J


RE: nPixel - kevin - 01-29-2025

Excellent, the interface looks really professional and clean, and it works so well.


RE: nPixel - Marcus - 01-29-2025

Ah yes, very nice!

Other than saving as image files, maybe you could somehow make it export n7 arrays with image data that you can include in your programs?


RE: nPixel - kevin - 01-29-2025

(01-29-2025, 04:52 PM)Marcus Wrote: Ah yes, very nice!

Other than saving as image files, maybe you could somehow make it export n7 arrays with image data that you can include in your programs?

I had a similar thing working in a previous version of a tileset designer that I worked on (I abandoned it and am currently working on its sucessor - image below), and found it a really useful functionality to have. I was working on a series of programs that only used image files generated within the program, and it was really useful for those.
I'll see if I can dig it out, but it may be tomorrow now.
All the best - Kevin.

Current  project:
   


RE: nPixel - Marcus - 01-29-2025

You two are certainly working on interesting projects!


RE: nPixel - johnno56 - 01-29-2025

(01-29-2025, 04:52 PM)Marcus Wrote: Ah yes, very nice!

Other than saving as image files, maybe you could somehow make it export n7 arrays with image data that you can include in your programs?


I had given that idea some thought but figured  that a 32x32 image would probably use about 1000 odd array elements... but then again... with the speed of PC's now days... that may not be a concern... Ok. I will give that a try as well... Thank you...

(01-29-2025, 07:33 PM)kevin Wrote:
(01-29-2025, 04:52 PM)Marcus Wrote: Ah yes, very nice!

Other than saving as image files, maybe you could somehow make it export n7 arrays with image data that you can include in your programs?

I had a similar thing working in a previous version of a tileset designer that I worked on (I abandoned it and am currently working on its sucessor - image below), and found it a really useful functionality to have. I was working on a series of programs that only used image files generated within the program, and it was really useful for those.
I'll see if I can dig it out, but it may be tomorrow now.
All the best - Kevin.

Current  project:

Cool project!! Impressive. Most impressive! Obi Wan has taught you well.... lol


RE: nPixel - 1micha.elok - 01-30-2025

   

The nPixel editor’s quite a delight,
Turning my doodles from wrong to right!
Pixels obey as I click and I tap,
Till the alien stops looking like a potato mishap

Big Grin


RE: nPixel - kevin - 01-30-2025

(01-29-2025, 07:33 PM)kevin Wrote:
(01-29-2025, 04:52 PM)Marcus Wrote: Ah yes, very nice!

Other than saving as image files, maybe you could somehow make it export n7 arrays with image data that you can include in your programs?

I had a similar thing working in a previous version of a tileset designer that I worked on (I abandoned it and am currently working on its sucessor - image below), and found it a really useful functionality to have. I was working on a series of programs that only used image files generated within the program, and it was really useful for those.
I'll see if I can dig it out, but it may be tomorrow now.
All the best - Kevin.

Current  project:

Johnno,

The functions in the tileset designer that I was working on are a little complicated, so I thought it would be easier to amend your code with a simpler solution which may be easier for anyone reading it to follow.

Here is my amended version of npixel.n7 - I have annotated the additional code that I have added. The save routine saves the data as a text file, which can be used in the second attachment to create a png image file from the data within the program. The save routine will then proceed to create a png file that is saved under the same file name as the text file, but with a different suffix of course (.png instead of .txt).

The load routine allows you to open the .png file, that has been created above, into npixel, and edit it prior to re-saving. Before running the load routine, you need to ensure that the grid size is set correctly, otherwise the png file will not load correctly.

You should download this file to the same folder as the original npixel above,as it needs some of the assets included in the zip file in the first post.


.n7   nPixel_kc v5 all working.n7 (Size: 10.89 KB / Downloads: 5)

Here is small program to convert the data created in the text file above to a png image (it was originally published by Marcus I think - I have just amended it for the different data structure). You currently need to copy and paste the data from the text file into the CreateAssets() function, as well as copying the grid size into the function. This could be automated if required, but I wanted to keep it as simple as possible.


.n7   create_png_from_data 01 all ok.n7 (Size: 22.47 KB / Downloads: 5)

The code, particularly the amendments in npixel, are far from optimised. For example, the table that I use to keep the pixel data in (drawn_grid[]) will contain duplicated records - I have removed some, but not all, of these.

If anyone has any questions I will be happy to try to answer them. I have tested these a little, but please let me know if you run into any issues.

All the best - Kevin.

Edit - to run the save and load functions in npixel, just use the S and L keys.


RE: nPixel - 1micha.elok - 01-31-2025

   
click the image to zoom in

Thank you for sharing your code so fine,
It’s truly amazing—your skills shine
To save and load PNGs with such ease,
My pet alien now has a photo—what a tease


RE: nPixel - johnno56 - 01-31-2025

Kevin,

What can I say? Very nice job indeed... Big Grin