New Commands for Turing
Author |
Message |
MysticVegeta
|
Posted: Sat Jun 25, 2005 4:03 pm Post subject: (No subject) |
|
|
[Gandalf] wrote: Thanks Bacchus!
Token, I think you're missing the point. It's better to have it already in the module if there is a coresponding one, and if its some totally new idea (we don't have a lot of those) then we can make a new module. I am strongly inclined to keep the new commands in the already existing modules. Also, I didn't know somebody was working on Math, but that's alright.
Do you need a helpfile for Draw.ThickCircle and Draw.ThickBox too?
*EDIT* What's that MysticVegeta? It doesn't work good at all . The thing we are trying to eliminate is the white spots in the actual circle. We are also avoiding using drawfill* because of speed.
Oh, wait - I noticed the Draw.ThickFILLOval. Thanks for the contribution, but try to get rid of the white spaces.
oh lol. I am not really good at understanding trignometry yet, so i made it according to my simplycity lol.
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Sat Jun 25, 2005 4:19 pm Post subject: (No subject) |
|
|
wtd, I know, but well... I might some time soon. I have to make my decision betweem Java(school),C++, or Ruby.
Simplicity is best! (usually, someone please don't get into an argument with me about this )
Here you go Token, this is the Draw.ThickBox helpfile attached.
Also, I was looking around the other predefs/modules are here are some stuff I found/thought about:
--The limits.tu file, we could probably change that around. Not sure if changing the maximum supported integer would cause too many problems.
--Maybe we could export pi and e from Math.tu and make them global constants.
--Something interesting, for old commands like randseed it automatically changes them to things like Rand.Seed, so there really is no difference.
--Somebody could try 'unofficially' adding support for .gifs? It would be pretty useful.
--We could add some more general colours to the RGB module, like "gold" and stuff like that.
--There's an experimental View.Scroll command, maybe someone could figure it out and complete it?
Yeah, those are some ideas I came up with .
|
|
|
|
|
|
MysticVegeta
|
Posted: Sat Jun 25, 2005 4:49 pm Post subject: (No subject) |
|
|
Ah the fraction reducer, i found the CCC problem i coded and turned it into a module
code: | /*
Created by: Tan (aka Mystic)
Module fraction.Reduce takes a fraction in a*b/c format and reduces it to lowest terms
*/
module fraction %%% MODULE
export Reduce
proc Reduce (whole : int, numerator : int, denominator : int) %%% REDUCTION PROCEDURE
var num := (denominator * whole) + numerator %% NUMERATOR
var den := denominator %% DENOMINATOR
var numorden : int
var ans : string %% ANSWER
if num mod den = 0 then %% IF IT IS A LIKE FRACTION
ans := "Reduced Fraction: " + intstr (whole) + " " + intstr (numerator) + "/" + intstr (denominator) + " into: \n" + intstr (num div den) + "/" + "1"
%%put ans
else % IF IT IS AN UNLIKE FRACTION
if den < num then %% IF THE DENOMINATOR IS GREATOR THEN WE TAKE THE GCF FROM DECREASING DENOMINATOR
numorden := den
elsif den > num then %% VICE VERSA
numorden := num
end if
for decreasing s : numorden .. 1 %% GREATEST COMMON FACTOR
if (num mod s = 0) and (den mod s = 0) then
numorden := s %% NUM OR DEN NOW BECOMES THE GCF
exit
end if
end for
if den > num then %% ANSWERS
%% IF IT CANT BE REDUCED MORE THEN
ans := "Reduced Fraction: " + intstr (whole) + " " + intstr (numerator) + "/" + intstr (denominator) + " into: \n" + intstr (num div numorden) + "/" + intstr (den div numorden)
elsif den < num then
%% IF IT CAN BE REDUCED, EXPRESS IT AS A MIXED FRACTION
ans := "Reduced Fraction: " + intstr (whole) + " " + intstr (numerator) + "/" + intstr (denominator) + " into: \n" + intstr ((num div numorden) div (den div numorden)) + " " +
intstr ((num div numorden) - (((num div numorden) div (den div numorden)) * den div numorden)) + "/" + intstr (den div numorden)
end if
end if
put ans %% PUTTING THE MAIN ANSWER WE GOT
end Reduce %% ENDING THE REDUCE
end fraction %% ENDING THE MODULE
fraction.Reduce (5, 45, 3) %% HERE 0 IS THE WHOLE NUMBER, 3 IS THE NUMERATOR, 2 IS THE DENOMINATOR
|
|
|
|
|
|
|
Token
|
Posted: Sat Jun 25, 2005 5:06 pm Post subject: (No subject) |
|
|
amazing! its in, umm and as to gandolf, heres the list with ur sudgestions added, and thanks for the help file.
Quote:
Here is the list so far.
1 Rotated draw oval
2 3D box
3 GUI
4 Thick basic shapes
5 Pic.Opacity
6 Triangles
7 Array average
8 Better sprites
9 Music player
10 Array Shuffle (2d arrays)
11 Draw line that works off slope
12 String split
13 Button -switch for characters using Input.Keydown
14 Message Prompt
15 Limits? (if someone could look into this I'd appreciate it)
16 Gif Support
17 More Colors
18 View.Scroll
19 LCD (lowest common denominator)
20 Lowest terms - completed
21 Slope Func - Completed
22 Isint- Checks to see if a real number is whole (int) - completed
23 Shake Screen - completed
I'll add the help file and post the help file so that you can see how it turns out.
|
|
|
|
|
|
wtd
|
Posted: Sat Jun 25, 2005 5:10 pm Post subject: (No subject) |
|
|
What about having a Fraction type and then defining operations for it?
code: | type Fraction :
record
numerator, denominator : int
end record
function makeFraction (num, denom : int) : Fraction
var output : Fraction
output.numerator := num
output.denominator := denom
result output
end makeFraction
function reduce (f : Fraction) : Fraction
if f.numerator mod f.denominator == 0 then
result makeFraction (f.numerator div f.denominator, 1)
else
...
end if
end reduce |
|
|
|
|
|
|
[Gandalf]
|
Posted: Sat Jun 25, 2005 5:16 pm Post subject: (No subject) |
|
|
Nice, do you want to create a whole module for fractions or add it on to the Math one, for something like Math.FractionReduce. I'd probably just do that.
Here's a new Font module. I added Font.Centre. There's a help file too.
Here's an example program using it:
code: | setscreen ("graphics:max;max")
var exampleFont : int := Font.New ("Times:100:bold,italic")
Font.Centre ("Gandalf", maxx div 2, maxy div 2, exampleFont, green) |
Oh, and are you going to add all these help files to the current one, or are you going to have to have two seperate ones?
Description: |
|
Download |
Filename: |
Font.tu |
Filesize: |
1.51 KB |
Downloaded: |
94 Time(s) |
|
|
|
|
|
|
Cervantes
|
Posted: Sat Jun 25, 2005 5:22 pm Post subject: (No subject) |
|
|
[Gandalf] wrote:
Turing: | %
% Calculate the slope between two points.
% By: [Gandalf]
%
function Slope (x1, y1, x2, y2 : real) : real
var final : real
final := (y1 - y2) / (x1 - x2)
result final
end Slope
%
% Calculate the area of a circle.
% By: [Gandalf]
%
function CircleArea (radius : real) : real
var area : real
area := PI * (radius ** 2) %PI is already declared in the Math module
result area
end CircleArea |
Gandalf, those functions could be reduced to one line:
code: |
result (y2 - y1) / (x2 - x1)
|
Similarly for CircleArea.
Also note I used y2 - y1 and x2 - x1, not the reverse. It doesn't change the final result, but it's generally preferred to avoid working with negatives. Of course, it's not like the computer cares.
CircleArea is a bit restricted. Let's expand it to ellipses, specified by the bottom left corner at (x1, y1) and the top right corner at (x2, y2).
Turing: |
function EllipseArea (x1, y1, x2, y2 : real) : real
result Math.PI * abs ((x2 - x1 ) / 2) * abs ((y2 - y1 ) / 2)
end EllipseArea
|
I don't think there's any way to add things into the main Help file.
|
|
|
|
|
|
[Gandalf]
|
Posted: Sat Jun 25, 2005 5:25 pm Post subject: (No subject) |
|
|
Alright, thanks Cervantes, I'm not used to writing funtions. I was thinking something along the lines of decompiling the windows help file, editing the html, and then compiling it? Not sure if its possible though.
Ohhhh, and I didn't realize/forgot that that PI variable is already exported. That's what is called when you do Math.PI
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Sat Jun 25, 2005 5:33 pm Post subject: (No subject) |
|
|
Yep. Same with e, I believe.
Decompiling the windows help file, editing the html, and recompiling it? Well... How do you decompile it? And it's not the windows help file that we're looking to edit. How do you know it's in html? Seems kinda strange to me.
|
|
|
|
|
|
wtd
|
Posted: Sat Jun 25, 2005 5:35 pm Post subject: (No subject) |
|
|
[Gandalf] wrote: Nice, do you want to create a whole module for fractions or add it on to the Math one, for something like Math.FractionReduce. I'd probably just do that.
Oh, I have no desire to write it all myself. Just giving someone else a push in the right direction.
Oh, and if you're going to take a page from Ruby's book, learn this: synonyms can be very good. Feel free to have "Font.Centre", bt then also have "Font.Center" which does the same thing.
|
|
|
|
|
|
[Gandalf]
|
Posted: Sat Jun 25, 2005 5:54 pm Post subject: (No subject) |
|
|
Alright, where do I begin...
Cervantes wrote: Decompiling the windows help file, editing the html, and recompiling it? Well... How do you decompile it? And it's not the windows help file that we're looking to edit. How do you know it's in html? Seems kinda strange to me.
I'm not sure how you decompile it, which is why I'm not sure it's possible. I realize that its not the windows help file we're editing , I meant that its a windows-form help file. I know it's html because it that's what help files are written in, chm stands for compiled html (I think).
wtd wrote: Oh, I have no desire to write it all myself. Just giving someone else a push in the right direction.
Oh, and if you're going to take a page from Ruby's book, learn this: synonyms can be very good. Feel free to have "Font.Centre", bt then also have "Font.Center" which does the same thing.
Sorry, I was talking to MysticVegeta, because he made his procedure a whole module. I didn't even see your post when I made mine - it took a while .
Alright, I'll add the other spelling of centre/center, and I'll watch out for it in the future, thanks.
|
|
|
|
|
|
Token
|
Posted: Sat Jun 25, 2005 5:57 pm Post subject: (No subject) |
|
|
Gandalf: thats kinda what i'm doing, i'm making my own helpfile with the same software so i can just integrate it easily after
|
|
|
|
|
|
[Gandalf]
|
Posted: Sat Jun 25, 2005 6:01 pm Post subject: (No subject) |
|
|
Yes, but just how are you going to integrate it? It would be really cool if you could access the new help files from the F9 help menu.
|
|
|
|
|
|
Token
|
Posted: Sat Jun 25, 2005 6:02 pm Post subject: (No subject) |
|
|
its all in that software, it can be done.
|
|
|
|
|
|
[Gandalf]
|
Posted: Sat Jun 25, 2005 6:07 pm Post subject: (No subject) |
|
|
Ok, so you're going to decompile it somehow, and add the example to the "examples" folder, then add the loopup command to "Keyword Lookup.txt", right? Also, what is this magical software?
*This is in no way spam or off topic, I'm just tired from writing Turing *
|
|
|
|
|
|
|
|