|
Post by n00b on Feb 18, 2020 0:35:19 GMT -6
I just tried it out. It looks pretty good.
|
|
|
Post by johnno56 on Feb 18, 2020 1:40:38 GMT -6
Many thanks. There are still a lot of 'flaky' button clicks that need looking into. Example: Select, let's say, either "8" or "16" then "lightly" tap LMB on "load" and watch the image load... Now do the same with a "firmer" click... The "8" or "16" image will load and immediately be displayed on the "32" grid... I may have to research a better button system... I am curious as to how you managed to code the "circle" and "line" buttons... Did you code them from scratch, or like me, "borrow" from other listings? From scratch or borrow that's one talent that I wish I had... You make this look SO easy... I know that it's not... But you know what I mean, right? lol I'm going to finish my coffee then look into some better buttons. Side note: I made a set of buttons for a CD player that I was coding in SDLBasic. Way back then, those buttons looked really cool, maybe not so much now. Ah. Gimp and a tutorial...
|
|
|
Post by n00b on Feb 19, 2020 0:07:17 GMT -6
The buttons look pretty good. I don't think this particular style is suited for a sprite editor but I think you definitely have the talent to make something appealing.
On the circle and line routines, I did not use any existing code for them. I did use some formulas for points on a circle I found by google. The circle itself is not perfect and there is definitely room for improvement. The line function is something I came up with on my own.
|
|
|
Post by johnno56 on Feb 19, 2020 5:15:56 GMT -6
Yeah. I figured the "buttons" wouldn't "fit" this application, but it's good to know that with the right tools, anything can be made...
I've googled a lot of stuff in the past; gleaned ideas from sdlbasic, qbasic and basic256... I can count on one hand the number of 'original' games that I've made... but most of the ideas usually come from one game or another... Well, more like a patchwork quilt, than a game... lol
Line function by yourself you say... Well, I'm impressed... That's the kind of coding that I can only dream of...
I saw a youtube video of someone trying to clear out a shopping centre car-park by shovelling snow into a shopping cart... Good for a chuckle at first... but eventually futile... Most of 'my' ideas are like that... Hopefully one day an idea will stick or maybe it might be time to stop shovelling... *sigh* Time will tell...
|
|
|
Post by johnno56 on Aug 1, 2022 15:24:54 GMT -6
After the loss of a hard drive (which contained the backup of the Editor) I have had to start over. Fortunately, I had converted that version to another language, and have begun the recreation of the editor... This is going to take some time... *sigh*
|
|
|
Post by n00b on Aug 1, 2022 21:10:22 GMT -6
I'm looking forward to seeing where this goes.
|
|
|
Post by johnno56 on Aug 1, 2022 23:40:34 GMT -6
I still have a lot to do... So far the editor is reasonably bug free. Colours can be selected. Drawing (Pencil and Mirror) on the main grid seems to be behaving itself. Transferring to the preview boxes is causing nasty lagging... I think you addressed that some time ago. I will search for the post. There were several mods that you had dome back then... Time for some homework. The one thing that works perfectly is the stupid Message Box. Does what it is supposed to do. No fuss. No bother. The one part of the editor that was not written by myself... lol
All the Zones are working as the mouse can interact with the colour patch and the buttons...
As soon as I check out your mods and the lag issue I will then attempt to handle loading and saving... That should bring the editor 'up to scratch'. From there I can try to implement line drawing etc... gulp...
|
|
|
Post by johnno56 on Aug 2, 2022 1:04:40 GMT -6
Lag discovered. Main loop was updating the preview boxes each cycle. The main grid was being scanned with, you guessed it, getpixel(). Instead of continuously scanning the main grid when drawing to the grid, draw to the two preview boxes at the same time. Lag is gone. Scanning will probably only be needed to load an image? The Editor is functioning fairly well... All it can do, at the moment, is draw (pencil and mirror), Clear, New and Quit. Save, Load and Line will display a message until ready. This should look familiar... rcdraw.zip (232.17 KB) Of course, any constructive criticism or suggestions for improvements, are always welcome. Perhaps a "To Do" list? J
|
|
|
Post by johnno56 on Aug 2, 2022 13:32:11 GMT -6
Quick question: "Creating an image 64x64 and painstakingly placing the pixels just so. Almost finished then realizing a mistake had been made". You know where this is going, right? An 'undo' function. Using 8x8 or 16x16 sprites, correcting a mistake, does not take very long... But 32+... Not so much. I have no idea as to where to start to code such a function. It is logical to assume that, if one wants to 'undo' a step, then all the steps (or at least a sizeable number of steps) need to be recorded... Again, another function I do not know how to code.. Am I over thinking this again? Hmm... Maybe just wishful thinking? lol Open to suggestions...
|
|
|
Post by n00b on Aug 2, 2022 15:49:25 GMT -6
johnno56 First of all, I just want to say that this app looks really nice and its very responsive. Good work. To answer your question about undo/redo, typically an application has an undo buffer which is a fancy way of saying an array of previous states. So if you have a 4x4 image you would have an array setup that stores the 4x4 image as it was at each level of undo up to a certain amount. For larger images this can be memory intensive which is why most applications have a limit on the amount of undos you can actually do. Here is an example with a 4x4 image which stores the 10 previous actions: MAX_UNDO = 10 image_width = 4 image_height = 4
Dim undo_buffer[MAX_UNDO, image_width, image_height] 'This holds the buffer (ie. the image) for each undo Dim undo_buffer_order$ 'This holds the order of the items in the undo buffer. 'This is an optimization trick we can use to prevent us from having to move data around in the undo_buffer.
undo_buffer_order_digits = 1 'We are going to store each index in this string as 1 digit. 'We are using 1 digit since the max number we will store will be 9 (0 to 9 is the 10 indexes in our array)
current_undo = 0 'The current index in the undo buffer to write to
'This will add the current state of the image to the undo buffer Sub Add_Undo_Action() For y = 0 to image_height-1 For x = 0 to image_width-1 'undo_buffer[current_undo, x, y] = image[x, y] 'image[x,y] is representing the color at (x,y) position in the image Next Next
undo_buffer_order$ = Right$(undo_buffer_order$, (MAX_UNDO-1) * undo_buffer_order_digits) 'If there is 10 items in the undo buffer, this will only keep the last 9 undo_buffer_order$ = undo_buffer_order$ + Str$(current_undo) 'This adds our current undo action to the end of our buffer order
current_undo = current_undo + 1 'Move the current_undo index to the next position in the buffer for the next undo action
'If current_undo has reached the size of our undo_buffer then we set it back to 0 If current_undo = MAX_UNDO Then current_undo = 0 End If End Sub
'This will remove the last undo action from our buffer order and return the index in the undo buffer Function Pop_Undo() last_undo = Val(Right$(undo_buffer_order$, undo_buffer_order_digits)) 'Here we are getting the last undo buffer index of the last action stored undo_buffer_order$ = Left$(undo_buffer_order$, Min((MAX_UNDO-1) * undo_buffer_order_digits, Length(undo_buffer_order$)-1)) 'Here we are removing the last index from the buffer order current_undo = current_undo - 1 'We want to go back one on the index we are writing to so we don't overwrite and index still in our undo order 'If the current_undo is less than 0 then we set it to the end of the undo_buffer If current_undo < 0 Then current_undo = MAX_UNDO-1 End If 'And finally we need to return the action that we have removed from the buffer Return last_undo End Function
'After an action has been performed you would store the image state after that action Add_Undo_Action()
'When undoing an action you will need to call Pop_Undo to get the index in the buffer of the image you want to restore Undo_Index = Pop_Undo()
'Then you can draw the image stored at that index in the undo buffer ' put code here to draw the image in undo_buffer[Undo_Index]
|
|
|
Post by johnno56 on Aug 2, 2022 16:13:17 GMT -6
I remember seeing an old basic256 program (paint) that stored actual images of the drawing surface. Undo would simply load the image back onto the surface.
Just looking at your code, basically does the same, but stores the image in memory and uses an index to recall a specific image. I hope I got that right... lol
You mentioned several times, the phrase "after an action". Gimp (and similar) can undo just one pixel, if a pixel is all that was done, but there would be a limit to how far "back" the image data was stored. Would you be referring to an "action" like just placing a pixel or a broader sense of say after drawing a filled box? I hope I am making sense... Because it does not sound like it to me... lol
I have no idea how to do lines 57 & 58...
I really should do more 'homework' before jumping into projects like this... lol
|
|
|
Post by n00b on Aug 2, 2022 20:09:55 GMT -6
If you can give me the link to the repo on github I can submit this feature to you as a pull request.
A pull request is how other people can submit code to your project for approval. Github is built for collaboration so if you write an issue for a feature you want to add or a bug that needs to be fixed, others can work on those issues and submit it to you. You can then accept or reject the code they submit.
|
|
|
Post by johnno56 on Aug 2, 2022 21:52:11 GMT -6
|
|
|
Post by n00b on Aug 3, 2022 2:45:33 GMT -6
I just submitted a pull request with Undo implemented. I also, extracted all the code out of the repo so that the source code can be viewed on Github.
|
|
|
Post by aurel on Aug 3, 2022 3:04:38 GMT -6
Hello I am not sure how to comment this program. ON Windows code compiled...then when run ..stop responding i changed window size to 1024x768 then program work but i cannot see buttons on right side i get it why ...heh then i increase X size for xmax = 1248 ymax = 768
and i saw button Pencil... strange thing is that button not respond right-now ( what program do internally is a mistery) than i need to wait 5-6 seconds then i can click on -change color to yellow also then picker work and i pick color and start to draw - really work well
that part is fine
then i try to click button Line and again program not responding ? and i must force to close it .
Program looking good ,yeah somehow is to-large and that is because large buttons I don't know ...maybe work better on Linux I don't have version of RCB for linux installed ..so maybe i should try from Linux
all in all very good!!!
PS. Johnno don't get me wrong and i don't have very much experience in such a programs BUT as i can see ..you use only one Canvas Maybe ...just maybe is there a way to use more canvases to split operations in between of them ? just asking ..
|
|