Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Best wishes for a happy, peaceful Christmas and holiday season from the Cemetech staff to all of you and your family and friends! No matter what you celebrate (or don't), we hope you're able to take the end of the year to share some time with those who matter, reflect on the past year, and look forward to what's ahead. We particularly hope that even if you haven't had a chance to pick up your calculator or computer for a while to do some programming, that you take the opportunity to code up a project this winter.

If you need a little inspiration and Christmas cheer, here's a simple TI-BASIC program for the TI-84 Plus CE and TI-84 Plus C Silver Edition that will draw some Christmas greetings on your graphscreen. Just press [ENTER] after it pauses to end the program (and restore your graphscreen settings). If you're curious how it works, just look below, where we've challenged our members to provide the most accurate and concise explanation (yes, guys, that means you. Go to it!). If you want to load this onto your own calculator, you can copy this code into our SourceCoder 3 TI-BASIC editor. Happy holidays!



SourceCoder 3 (TREE) wrote:
:StoreGDB 0
:FnOff
:AxesOff
:0->Xmin:~164->Ymin
:1->DeltaX:1->DeltaY:ClrDraw
:For(X,32,140
: .7(X-32)-8int((X-32)/27)
: Line(132-Ans,~X,132+Ans,~X,Green
:End
:For(X,141,164
: Line(120,~X,144,~X,Brown
:End
:For(X,0,100
: {Red,Blue,Yellow,Magenta,Orange
: Ans(randInt(1,dim(Ans->C
: randInt(32,140->A
: int(.7(Ans-32)-8int((Ans-32)/27)
: 132+randInt(~Ans,Ans
: Pt-On(Ans,~A,C
:End
:"MERRY CHRISTMAS
:For(X,1,length(Ans
: TextColor(Red+(Green-Red)(remainder(X,2
: Text(2,122-5*length(Ans)+10X,sub(Ans,X,1
:End
:Pause
:RecallGDB 0
:Ans
KermMartian wrote:
we've challenged our members to provide the most accurate and concise explanation



Code:
:StoreGDB 0
:FnOff
:AxesOff
:0->Xmin:~164->Ymin


This stores the graph screen to the graph database 0. Then turns the Fn's and axis off. Lastly, the lower bound for the x-axis is set to 0 and the lower y-axis bound is set to around 164.


Code:
:1->DeltaX:1->DeltaY:ClrDraw

Preps the delta printer then clears the drawing board.


Code:
:For(X,32,140
:   .7(X-32)-8int((X-32)/27)
:   Line(132-Ans,~X,132+Ans,~X,Green
:End

This prints the tree with pixels.


Code:
:For(X,141,164
:   Line(120,~X,144,~X,Brown
:End

This prints the tree trunk with more pixels.


Code:
:For(X,0,100
:   {Red,Blue,Yellow,Magenta,Orange
:   Ans(randInt(1,dim(Ans->C
:   randInt(32,140->A
:   int(.7(Ans-32)-8int((Ans-32)/27)
:   132+randInt(~Ans,Ans
:   Pt-On(Ans,~A,C
:End

This prints random little pixel lights onto the tree.


Code:
:"MERRY CHRISTMAS
:For(X,1,length(Ans
:   TextColor(Red+(Green-Red)(remainder(X,2
:   Text(2,122-5*length(Ans)+10X,sub(Ans,X,1
:End

Here we have a comment that tells us this will print "MERRY CHRISTMAS" but it also does a thing where this string is saved in the variable "Ans." Pretty schwifty if you ask me. In the For( loop it prints the the string saved in Ans as alternating colors of green and red.


Code:
:Pause
:RecallGDB 0
:Ans

Pauses the program until you press enter, When you do that, recalls the graph database 0. Then it needs to get the last word in before it quits.
Oh god... I don't think I could give that program justice, it is quite complicated and amazingly clever. (I started making this post before Alex posted, ok?!)
(I did notice that there are some small optimizations in the above code, most notably parenthesis at the ends of lines.)
Instead, I'm going to shamelessly post a simpler project of mine from about exactly one year ago. I think I can explain this one easier.


SourceCoder 3 (XMASDRAW) wrote:
://Change this to change the color of the ornaments and present.
:Red
:Ans->theta
:
://Store the current graphscreen settings, it's "rude" to just delete them.
:StoreGDB 0
://Set up graphscreen by removing the axes and grid and turning off the functions and plots.
:BackgroundOn Black
:FnOff
:GridOff
:AxesOff
:PlotsOff
:
://Zoom to the "standard screen", then make everything square (Think graph paper)
:ZStandard
:ZSquare
://Draw the tree. Note that a filled triangle (We'll call it triangle ABC) can be created by drawing the lines connecting point A to each point on line BC.
:For(A,2,~2,~0.05
: Line(0,5,A,~1,1,Green
:End
://Draw the ornaments. At the time, I couldn't think of ways to keep random points inside the triangle, and I never thought I'd post this, so...
:Pt-On(0,4,1,theta
:Pt-On(~0.5,2.75,1,theta
:Pt-On(~1,0,1,theta
:Pt-On(0.5,0.5,1,theta
:Pt-On(1,1,1,theta
:Pt-On(~1,1.5,1,theta
:Pt-On(0.25,2,1,theta
://Begin drawing the trunk.
:Line(~0.5,~1,0.5,~1,1,Brown
://Draw the trunk.
:For(A,~0.5,0.5,0.05
: Line(A,~1,A,~2.5,1,Brown
:End
://Draw the star at the top, by using the Pt-On command, and the 3rd point style, which somewhat resembles a star (technically, it's a plus shape)
:Pt-On(0,5,3,Yellow
://Draw the snowman. If you draw a bunch of concentric circles close enough, then the circle will appear filled. I edited the screenshot a little, there were minor errors where the circles weren't close enough, but it's barely noticable on-calc.
:For(A,2,0.1,~0.025
: If A<=1.5
: Circle(~5,~2,A,1,White
: If A<=1
: Circle(~5,0.5,A,1,White
: Circle(~5,~5.5,A,1,White
:End
://Draw the nose.
:Pt-On(~5,0.4,1,Orange
://Draw the buttons.
:For(A,1,3
: Pt-On(~5,~A,1,Black
:End
://Draw the arms.
:Line(~3.5,~1.5,~2.25,0.5,1,Brown
:Line(~6.5,~1.5,~7.75,~2.5,1,Brown
://Draw the eyes.
:Pt-On(~5.5,1,Black
:Pt-On(~4.5,1,Black
://Draw the present. I edited the screenshot a little, there were minor errors where the present didn't come out correctly, but at least the math is correct.
:For(A,0,1,0.05
: theta->Z
: //If we are in the center of the present, change the color to add a vertical stripe
: If A=.5
: Orange->Z
: Line(1,~1.5-A,2,~1.5-A,1,Z
:End
://Draw the horizontal stripe.
:Line(1.5,~2.55,1.5,~1.55,Orange
://Wait for the user to press enter, then restore the current settings.
:Pause
:RecallGDB 0

This program is much simpler, in my humble opinion, and I added in-line comments to help explain the code.

This is even a bit customizable, you can change the color on the second line to change the color of the presents.

(This is all in the interest of inspiration, right?)

Also, Alex:
Alex wrote:
and the lower y-axis bound is set to around 164.

Nope!

The tilde (~) in SC3 syntax does not mean around, instead, it means the little negative sign thingie.

Alex wrote:
Preps the delta printer then clears the drawing board.

What's a delta printer? Wink

It sets Xmax to 264 and Ymax to 164, so that the visual distance between, say 4 and 5 on the X axis is the same as the visual distance between, say, 10 and 11 on the Y axis.

Specifically:
The TIBD wrote:
In addition to those four window variables, there are two other window variables that you can use to set the window dimensions. ΔX is the difference between Xmin and Xmax divided by the graphscreen width and ΔY is the difference between Ymin and Ymax divided by the graphscreen height. When you set Xmin and Ymin to 0, you just need to set ΔX and ΔY to 1 to make Xmax 94 264 on the color calculators and Ymin 62 164 on the color calculators.
_iPhoenix_ wrote:
Also, Alex:
Alex wrote:
and the lower y-axis bound is set to around 164.

Nope!


That was all mostly tongue in cheek since I don't really know TI-BASIC anymore, but I appreciate the insightful lesson. Mostly about in regards to the Delta stuff. Much appreciated!
DeltaX is how much the X coord changes over 1 pixel, so

Code:

:0->Xmin:~164->Ymin
:1->DeltaX:1->DeltaY:

is the same as doing:

Code:

0->XMin:~164->Ymin
Xmin + 264 -> Xmax : Ymin + 164 -> Ymax

Basically in the end, the top left pixel is coord (0,0), and adding 1 to a coord will move you 1 pixel.

This equation surely doesn't result in a "MERRY CHRISTMAS" message. Razz
PT_ wrote:

This equation surely doesn't result in a "MERRY CHRISTMAS" message. Razz


Code:
r^2y = rry = log_e(x/m - sa)
e^(rry) = x/m - sa
e^(rry) + sa = x/m
me^(rry) + mas = x
0 = me^(rry) - x+mas


Not bad, not bad at all. Although I might try to make it work out as me^rry + x-mas. Wink
Merry Christmas! If you're looking for a bit of Christmas fun, you can temporarily change Cemetech's boring gray/yellow background color by typing this in the console:

Code:

document.body.style.backgroundColor = "#3C8D0D";

There is also a way to make the snow in the header fall much faster or change the actual snow pictures, but that requires more work in the Inspector and should be fairly easy to figure out yourself Wink
Michael2_3B wrote:
Merry Christmas! If you're looking for a bit of Christmas fun, you can temporarily change Cemetech's boring gray/yellow background color by typing this in the console:

Code:

document.body.style.backgroundColor = "#3C8D0D";

There is also a way to make the snow in the header fall much faster or change the actual snow pictures, but that requires more work in the Inspector and should be fairly easy to figure out yourself Wink

I prefer this:

Code:

var counter = 0
function changeC(){document.body.style.backgroundColor = '#' + ('00000' + counter.toString(16)).slice(-6);; counter++;}
setInterval(changeC, 1);

(Enter the last line dozens of times for best effect)
What does it mean to type it into the console?
21tmccauley wrote:
What does it mean to type it into the console?


When you inspect a web pages source code (via right clicking, "Inspect Element") there's a little window that appears in that web pages window/tab. It shows you the source code as well as various tabs for any resources the page calls on, a timeline of events so you can see how long each file takes to load, etc etc. Some browsers may have different names for tabs. But I've always seen the "console" tab named "console." It's an incredibly useful tool.
  
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 1
» All times are GMT - 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