GRAPHER - not your ordinary drawing program. (for computer)
Grapher is written in BASIC256.
Main difference between normal drawing programs and Grapher: in a "standard" program, you'd click on Line and use the mouse to draw a line. In Grapher, you select Line, then enter in the coordinates for the line. It is menu based.

Here are some screenshots:
This is the main menu of Grapher:

-----
Here I am drawing a line:

-----
And here is the result:

-----
Here I am making a circle:

-----
And here is the result:


It doesn't automatically clear the drawing when you add a new shape, you have to press "6" (partial erase) or "7" (full erase) to erase.

Here's the code:

Code:
titlepg:
cls
color black
print "GRAPHER - By Spyro543"
print "Press the key the corresponds to what you want to do:"
print "1 - Draw Line"
print "2 - Draw Single Point"
print "3 - Draw Rectangle"
print "4 - Draw Circle"
print "5 - Draw Text"1
print "6 - Erase Partial"
print "7 - Erase All"
checkpg:
choice = key
if choice = asc("1") then
goto drawline
endif
if choice = asc("2") then
goto drawpoint
endif
if choice = asc("3") then
goto drawrect
endif
if choice = asc("4") then
goto drawcircle
endif
if choice = asc("5") then
goto drawtext
endif
if choice = asc("6") then
goto erasepart
endif
if choice = asc("7") then
goto eraseall
endif
goto checkpg

drawline:
cls
print "Draw a line:"
input "Start of line x-axis: ", x1
input "Start of line y-axis: ", y1
input "End of line x-axis: ", x2
input "End of line y-axis: ", y2
line(x1, y1, x2, y2)
goto titlepg

drawpoint:
cls
print "Draw a line:"
input "x-axis: ", x
input "y-axis: ", y
plot(x, y)
goto titlepg

drawrect:
cls
print "Draw a rectangle:"
input "x-axis: ", x1
input "y-axis: ", y1
input "Width: ", x2
input "Height: ", y2
rect(x1, y1, x2, y2)
goto titlepg

drawcircle:
cls
print "Draw a circle:"
input "x-axis: ", x
input "y-axis: ", y
input "Radius: ", r
circle(x, y, r)
goto titlepg

drawtext:
cls
print "Draw text:"
input "x-axis: ", x
input "y-axis: ", y
input "Text: ", t$
text(x, y, t$)
goto titlepg

erasepart:
cls
print "Partial erase:"
color clear
input "x-axis: ", x1
input "y-axis: ", y1
input "Width: ", x2
input "Height: ", y2
rect(x1, y1, x2, y2)
goto titlepg

eraseall:
cls
print "Erase all:"
input "Are you sure? [Y/N]", yn$
if yn$ = "Y" or yn$ = "y" then
clg
goto titlepg
else
if yn$ = "N" or yn$ = "n" then
goto titlepg
endif
endif


If you have any ideas, comments, or optimizations, please tell me! Smile

A Python version should be coming soon. Very Happy

Sorry I haven't uploaded the actual file yet. I will sometime. In the meantime, copy and paste the source code above. Thanks!
Looks good, but it's generally a bad idea to use labels and gotos like that in a program, especially TI Basic where it can cause memory leaks. You could move the code in the labels back into the If statement pretty easily, so that's not really a problem.
Yeah, but it just seemed easier to use gotos there. I guess removing gotos would be a good optimization, right?
Spyro543 wrote:
Yeah, but it just seemed easier to use gotos there. I guess removing gotos would be a good optimization, right?


Not necessarily an optimization, but a better coding practice Wink which usually takes high precedence.
Now that I think about it, I could have added subroutines there instead of GOTOing.
Spyro543 wrote:
Now that I think about it, I could have added subroutines there instead of GOTOing.


Now you're thinking like a Computer Scientist! Wink

(sorry, my comp. sci. teacher always says that to people, this was just too good an oppertunity to pass up)
Ashbad wrote:
Spyro543 wrote:
Now that I think about it, I could have added subroutines there instead of GOTOing.


Now you're thinking like a Computer Scientist! Wink
Maybe I am. Very Happy But yeah, in the situation of my program here, GOTOs and subroutines would be pretty much the same thing. But subroutines now seem easier to handle. Wink
Spyro543 wrote:
Ashbad wrote:
Spyro543 wrote:
Now that I think about it, I could have added subroutines there instead of GOTOing.


Now you're thinking like a Computer Scientist! Wink
Maybe I am. Very Happy But yeah, in the situation of my program here, GOTOs and subroutines would be pretty much the same thing. But subroutines now seem easier to handle. Wink


I'd actually tell you to forget about using GOTO statements if at all possible -- I'd say your two equally good choices are inserting them inline with an if-then-else chain, or using subroutines.
I'll try to do that. Smile
It seems like a CAD sort of program; very nice! If you'd like some reference on other things that you could make it do, might I throw this in your general direction?

http://www.cemetech.net/news.php?year=2005&month=all&id=199
KermMartian wrote:
It seems like a CAD sort of program; very nice! If you'd like some reference on other things that you could make it do, might I throw this in your general direction?

http://www.cemetech.net/news.php?year=2005&month=all&id=199

Looks pretty cool and fun!

I just got an idea: what if I would add a Mirror function that draws 3 other lines or whatever that have opposite coordinates of what you drew?
That's a great idea! Does it currently store the images in a vector format, by the way, or as images? IE, does it remember the coordinates, or store an image (or does it store at all)? Also, I'm curious what this BASIC256 thing is; it seems to be something you wrote?
No, BASIC256 is a programming language made for kids high school~middle school age. It's a very fun language to work with.
Link: http://www.basic256.org/index_en
Read this (From the Basic256 home page):

http://www.salon.com/technology/feature/2006/09/14/basic/index.html

It's a very good editorial that may apply to many of the world's aspiring coders.
I actually made a topic about that article on Omnimaga. Smile
Spyro543 wrote:
I actually made a topic about that article on Omnimaga. Smile


Considering it was a good discussion topic, and that most of the members here don't like frequenting Omnimaga (and in quite a few cases, can't even access it), why not make the same topic over here as well? I'm sure it would have an equally impressive reception here Smile
Thanks for that suggestions, Ashbad, and I'm glad to see that he did indeed do so. I had run across that article previously for some reason, and although I don't agree with all its points, I think it has quite a few good ones. Now that we have what BASIC256 is straightened out, why has no one made a program to port BASIC256 programs to TI-BASIC programs? Smile
That would be hard. The syntax, however similar, is also way different.
Spyro543 wrote:
That would be hard. The syntax, however similar, is also way different.
Can you clarify what you mean by that? Is program flow vastly different?
Well simple things like EndIf -> End, <> -> ≠, a = 1 into 1 -> a, etc.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement