Author Topic: Fastest way to render random points and lines?  (Read 1978 times)

0 Members and 1 Guest are viewing this topic.

CalcMax

• LV2 Member (Next: 40)
• Posts: 34
• Rating: +0/-0
• TI-84+SE for play, NSpire CX CAS for hard work
Fastest way to render random points and lines?
« on: January 15, 2017, 07:38:13 am »
Could someone tell me what the best way to randomly generate lines,points,pixels,etc... on a TI-84+ in TI-BASIC? I have gone through many different attempts and it usually involved taking and modding a portion of Hex2Sprite and then adding quite a bit of my own code to randomize coordinates (randInt operations) and draw what I need (I think my code is the slow part, but the programs are too long to post here.). Is there an alternative method to mine or is this the fastest I can get without attempting to OC my calc to 25-30MHz?
http://www.ticalc.org/archives/files/authors/115/11518.html

Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4667
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
Re: Fastest way to render random points and lines?
« Reply #1 on: January 15, 2017, 09:27:27 am »
Of course assembly would be way faster, but have you tried the standard built in Pxl-On(, Pxl-Off(, Pxl-Change(, Pt-On(, Pt-Off(, Pt-Change(, Line(, and Circle( commands? Also, if you include an extra argument for Circle( of {i it will perform faster (i being the imaginary i).

If you haven't tried Axe yet, I urge you to try that if you want much faster graphics. Just be warned that Axe works a lot closer to assembly, so you can't just press [ON] to break out of infinite loops. For example, if you do While 1:End, you will need to pull a battery and get a RAM clear.

Edit: Also, if you want a pixel based circle (instead of TIs point-based), I think KermM wrote an entirely TI-BASIC routine that performs faster than TIs.
« Last Edit: January 15, 2017, 09:41:04 am by Xeda112358 »

CalcMax

• LV2 Member (Next: 40)
• Posts: 34
• Rating: +0/-0
• TI-84+SE for play, NSpire CX CAS for hard work
Re: Fastest way to render random points and lines?
« Reply #2 on: January 15, 2017, 10:18:33 am »
Well,here is the code of a program that should appear in soon on ticalc.org along with another one (all in one package):
Code: [Select]
NAME:CALCIMGAxesOffClrDrawClrHomeGoto 1Lbl 1ClrHomeClrDraw"0"->Str4I+28->C:J->Ulength(Str4Ans/(3+2(Ans>29)+4(Ans>29->ZIf min(Ans!={8,16,32Then ClrHome "ACBCEFEFBCBCCECBCACACACACACCACA989898964317979BCCECECECECECECCACACACACACCECACEC9797979797979779797979797979797979779797979797979797979797979797CCACAFFFDFCACCDCCACACCBCBCCBCBFECBCBCCBCECBCCBCBCBCBFFEFBCECBCBC97797977979797979797964646799497676313461616161616464997989898989898989898897997646466464631331313131313466466464979977979979797979797979CBCEFBCCECCCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBC9797ABDEACDCCACACACBCCBC56565656565565656565"->Str4 ClrHome 32->ZEndFor(B,1,length(Str4 inString("123456789ABCDEF",sub(Str4,B,1 If 4<Ans Pt-On(U-5-randInt(1,5),C-5-randInt(3,10 Line(U-randInt(0,9),C-randInt(0,8),3,2 If 4<8fPart(Ans/8 C+4->C U+(C=I+Z->UIf C=I+Z:I->C:EndClrDrawClrHomeMenu("More?","Yes",1,"No",2)Lbl 2ClrDrawClrHomeDelVar Str4DelVar BDelVar CDelVar IDelVar JDelVar UDelVar YDelVar ZStopIf I were to make a fast version of this program, what should I do? I am currently using KermMartian's book to learn TI-BASIC, but I am still stuck. Also, I assume running this on a TI84+CSE would surely be a horrendously crappy experience (try it yourself if you have a CSE).

« Last Edit: January 15, 2017, 03:06:27 pm by Eeems »
http://www.ticalc.org/archives/files/authors/115/11518.html

E37

• LV6 Super Member (Next: 500)
• Posts: 306
• Rating: +21/-0
• Trial and error is the best teacher
Re: Fastest way to render random points and lines?
« Reply #3 on: January 15, 2017, 05:06:41 pm »
You look good for the most part!
The clrHome's aren't necessary. The GoTo 1 isn't needed either, since the program just passes over them.
The delVar's aren't really needed anyway. It would be a good idea to delete the strings, but the letter vars don't matter.
You could probably do something to compress str4... it is pretty huge.
I'm not exactly sure what you are trying to accomplish, but would this work?
Code: [Select]
For(X,0,500)If randInt(0,1):ThenLine(randInt(Xmin,Xmax),randInt(Ymin,Ymax),randInt(Xmin,Xmax),randInt(Ymin,Ymax))ElsePt-On(randInt(Xmin,Xmax),randInt(Ymin,Ymax))EndEndThat should generate random lines and points on the screen.
I'm still around... kind of.

CalcMax

• LV2 Member (Next: 40)
• Posts: 34
• Rating: +0/-0
• TI-84+SE for play, NSpire CX CAS for hard work
Re: Fastest way to render random points and lines?
« Reply #4 on: January 16, 2017, 06:04:00 am »
Thanks alot. Already started building a new program from this. This is so much better and faster than my bloatcode.