--> Undo --> -->

Author Topic: Undo  (Read 23515 times)

0 Members and 1 Guest are viewing this topic.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Undo
« on: February 25, 2011, 03:47:30 pm »
My BASIC program Macro is a drawing tool. There are 8 drawing commands available, and the coordinates for each are recorded and stored, along with the command number, in a single element of LM. It's almost done, but it's missing a desperately needed feature: An undo button. I can't just do the opposite of the command that was just performed, because that could change pixels that weren't changed by the instruction being undone. The only way I can see to circumvent this situation would be to remove the last element of the list and call Read to redraw the whole thing, which would be an absolute pain. Can anyone think up a more efficient way to implement an undo feature?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Undo
« Reply #1 on: February 25, 2011, 03:49:52 pm »
My BASIC program Macro is a drawing tool. There are 8 drawing commands available, and the coordinates for each are recorded and stored, along with the command number, in a single element of LM. It's almost done, but it's missing a desperately needed feature: An undo button. I can't just do the opposite of the command that was just performed, because that could change pixels that weren't changed by the instruction being undone. The only way I can see to circumvent this situation would be to remove the last element of the list and call Read to redraw the whole thing, which would be an absolute pain. Can anyone think up a more efficient way to implement an undo feature?

In computer programs, what is usually done is to save all the things that are done and then undo them, but this is theory, I have no idea about the practical way of 'Undo' in Basic.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Undo
« Reply #2 on: February 25, 2011, 03:50:34 pm »
Before every action, you could store the screen to an OS Pic variable, and then using Undo would recall the pic var onto the screen, effectively "undoing" the last action :)

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #3 on: February 25, 2011, 03:52:05 pm »
Before every action, you could store the screen to an OS Pic variable, and then using Undo would recall the pic var onto the screen, effectively "undoing" the last action :)
But that would only allow one undo. That's not enough. I want the ability to undo ad infinitum.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Undo
« Reply #4 on: February 25, 2011, 03:52:51 pm »
Before every action, you could store the screen to an OS Pic variable, and then using Undo would recall the pic var onto the screen, effectively "undoing" the last action :)
But that would only allow one undo. That's not enough. I want the ability to undo ad infinitum.

Then it'd requite saving infinite Pic Variables, but they are finite.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #5 on: February 25, 2011, 03:54:18 pm »

Then it'd requite saving infinite Pic Variables, but they are finite.
Hence the necessity of another method.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Undo
« Reply #6 on: February 25, 2011, 03:56:35 pm »
I basic that would be really, really hard.  I'd say cap it to 5 undos or so and use Pic Variables. ;)

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #7 on: February 25, 2011, 03:57:59 pm »
I think you could use the algorithm of a snake.
And what algorithm would that be?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Undo
« Reply #8 on: February 25, 2011, 04:00:24 pm »
the ability to undo ad infinitum.

Even photoshop doesn't have this :P

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Undo
« Reply #9 on: February 25, 2011, 04:00:31 pm »
I'd be curious about where the RAM to store all of that information is. TI-BASIC doesn't give you access to a whole lot of memory with which to store data.

However, I made a CAD tool awhile back in BASIC and here's what I did:

Every time the user drew a point, the 3D spatial coordinates of that point would be stored in an array in sequential order. When the user needed to erase something, the program searched searched the list for a point close to the cursor and erased it. All elements after the deleted element were then placed in a temporary list and the lists then augmented together again to remove that element. The location on the screen that corresponded to the coordinates was simultaneously erased pixel by pixel. That way, the point would be erased until the next time the screen needed to be redrawn, at which the point would not show up because it was no longer present in the array.
« Last Edit: February 25, 2011, 04:02:16 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Undo
« Reply #10 on: February 25, 2011, 04:01:11 pm »
It is only to store the last coordonates. To redraw everything, you must use picvars. Maybe an Axe subprogram could help you ?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Undo
« Reply #11 on: February 25, 2011, 04:02:37 pm »
Yeah one issue with multiple undos is that it would take loads of memory. Even some computer programs lets the user set a limit on undos, because otherwise they run out of RAM quick.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Undo
« Reply #12 on: February 25, 2011, 04:04:09 pm »
DJ, yeah. The only program I've ever seen advertise "unlimited undos" was HxD, which has a much easier task of it than most programs because of how densely you can store hex.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Undo
« Reply #13 on: February 25, 2011, 04:08:49 pm »
I'm with ztrumpet with this one, store a max of 3 or 4 picture variables and recall them when you want to undo.  Quick, simple, and it works.  Any other way is going to be really complicated, and probably not the fastest

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #14 on: February 25, 2011, 04:12:49 pm »
the ability to undo ad infinitum.

Even photoshop doesn't have this :P
And this should stop me...why?
DJ, yeah. The only program I've ever seen advertise "unlimited undos" was HxD, which has a much easier task of it than most programs because of how densely you can store hex.
What does this program do and how does it undo?
And, technically, I only need 999 undoes. If the list has any more elements than that, something's seriously wrong with the calculator. Currently, I have a save and load feature that takes a pic and notes how many list elements there are when it saves, and then truncates the list and puts the pic back on the screen when it loads.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

 

\n\t\t\t\t\t\t\t\t\t
<' + '/div>\n\t\t\t\t\t\t\t\t\t