[papert] r138 committed - minor changes

14 views
Skip to first unread message

codesite...@google.com

unread,
Apr 27, 2010, 7:16:19 AM4/27/10
to paper...@googlegroups.com
Revision: 138
Author: keknehv
Date: Tue Apr 27 04:15:12 2010
Log: minor changes

http://code.google.com/p/papert/source/detail?r=138

Added:
/trunk/static/help.txt
/trunk/static/init.js
Modified:
/trunk/app.yaml
/trunk/index.html.tmpl
/trunk/index.yaml
/trunk/static/papert.css
/trunk/static/turtle.js

=======================================
--- /dev/null
+++ /trunk/static/help.txt Tue Apr 27 04:15:12 2010
@@ -0,0 +1,180 @@
+Quick reference logo guide:
+
+Stuff should work in lower or upper case.
+
+Types:
+
+WORDS: FW BW ....
+NUMBERS: 0, 0.1, 20
+LISTS: [1 2 3 5]
+SYMBOLS: "foo "bar
+VARIABLES: :foo :bar
+FUNCTION CALLS: COMMAND arg arg arg ...
+ (COMMAND arg arg arg ...)
+
+Supported Commands:
+
+RESET Clear the screen, move home.
+
+
+Turtle Movement:
+
+FORWARD n Move the turtle forward n pixels
+FW n
+
+BACKWARD n Move the turtle backward n pixels
+
+RIGHT n Move the turtle left or right n degrees
+RT n
+LEFT n
+LT n
+
+SETX x Set the co-ordinates of the turtle
+SETY y
+SETXY x y
+
+HOME Move the turtle to the home position
+
+
+Drawing:
+
+CLEARSCREEN Clear the screen
+CLEAR
+CS
+
+CIRCLE r Draw a Circle of radius r around the turtle
+
+ARC r d Draw an arc of radius r for d degrees
+
+PENUP Lift the pen up and down
+PU
+PENDOWN
+PD
+
+COLOR [r g b] Set the pen color
+
+PENWIDTH w Set the pen width
+
+
+Text:
+
+PRINT "foo Prints "foo"
+PR "foo
+PRINT ["foo "bar] Prints "foo bar"
+PR ["foo "bar]
+
+CLEARTEXT Clears previously printed text
+CT
+
+
+Arithmetic:
+
+1 + 2 1 * 2
+SUM 1 2 PRODUCT 1 2
+(SUM 1 2 3 ...) (PRODUCT 1 2 3 ...)
+
+1 - 2 1 / 2
+DIFFERENCE 1 2 DIVIDE 1 2
+
+1 % 2
+MOD 1 2
+
+RANDOM n Return a integer in [0,n)
+RAND n
+
+RERANDOM s Set the random seed value
+SRAND s
+
+
+INT n
+ROUND n
+POWER e m
+EXP n
+LN n
+LOG10 n
+
+
+
+SIN, COS
+RADSIN,RADCOS
+
+ARCTAN
+RADARCTAN
+
+
+
+List Operators (experimental):
+These functions may break silently at the moment.
+
+FIRST, HEAD Return the first item in a list
+BUTFIRST, TAIL Return the everything but the first item in a list
+LAST Return the last item in a list
+BUTLAST Return everything but the last item in a list
+
+FPUT item list Return a new list with item at the front
+LPUT item list Return a new list with item at the back
+
+ITEM index list Retrieve the indexed item
+SETITEM index list value Set the indexed item
+
+EMPTY? list Return true if list is empty
+EMPTYP list
+
+Logical and Comparison:
+
+1 = 1
+EQUAL? 1 1
+EQUALP 1 1
+
+1 < 2 1 <= 2
+LESS? 1 2 LESSEQUAL? 1 2
+LESSP 1 2 LESSEQUALP 1 2
+
+2 > 1 2 > 1
+GREATER? 2 1 GREATEREQUAL? 2 1
+GREATERP 2 1 GREATEREQUALP 2 1
+
+AND TRUE FALSE OR FALSE TRUE
+
+Conditionals:
+
+IF COND [IF_TRUE]
+IF 2 > 1 [FW 100]
+
+IFELSE COND [IF_TRUE] [IF_FALSE]
+IFELSE 2 > 1 [FW 100 RT 90] [BW 100 LT 90]
+
+
+Setting and getting:
+
+Set x to 1: make "x 1
+Adding :n to :x :n + :x
+Setting :x to :n + :x make "x :x + :n
+
+Looping:
+
+REPEAT n [COMMANDS ...]
+
+STOP - Stop the current Repeat or function.
+
+OUTPUT f - Return f.
+OP f
+
+
+Defining and Calling:
+
+TO FOO :ARG1 :ARG2 BODY END
+
+TO SQUARE :length
+REPEAT 4 [FW :length RT 90]
+END
+
+SQUARE :10
+
+TO POLYGON :length :sides
+REPEAT :sides [FW :length RT 360/:sides]
+END
+
+POLYGON 5 10
+
+Note: Simple Tail recursion is supported.
=======================================
--- /dev/null
+++ /trunk/static/init.js Tue Apr 27 04:15:12 2010
@@ -0,0 +1,70 @@
+var turtle = null;
+var logo = null;
+var canvas;
+var form;
+var sprite;
+var textOutput;
+var oldcode;
+var fast;
+var out;
+var DelayTurtle;
+
+function setup() {
+ logo = new Logo();
+
+ fast = 5;
+ turtle = new DelayTurtle(canvas, sprite, fast, false);
+ logo.setTurtle(turtle);
+ logo.setTextOutput(textOutput);
+}
+
+function init(canvas_id, turtle_id, form_id, oldcode_id, textoutput_id) {
+ canvas = document.getElementById(canvas_id);
+ form = document.getElementById(form_id);
+ textOutput = document.getElementById(textoutput_id);
+ sprite = document.getElementById(turtle_id);
+
+ // I hate opera, I hate firefox.
+ canvas.style.width = 500;
+ canvas.width = 500;
+
+ canvas.style.height = 500;
+ canvas.height = 500;
+
+ oldcode = document.getElementById(oldcode_id);
+ setup();
+}
+
+function run(speed, drawbits) {
+ turtle.stop();
+ if (speed !== fast) {
+ fast = speed;
+ var newturtle = null;
+ // newturtle = new Turtle(canvas);
+
+ newturtle = new DelayTurtle(canvas, sprite, fast, drawbits);
+ logo.setTurtle(newturtle);
+ turtle = newturtle;
+ }
+
+ oldcode.innerHTML += "\n" + form.code.value;
+ //form.code.value = ""
+
+ out = logo.run(form.code.value);
+
+ if (out && out.type === "error") {
+ alert(out.data);
+ setup();
+ }
+}
+
+function stop() {
+ turtle.stop();
+}
+
+function clearcanvas() {
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = "rgb(255,255,255)";
+ ctx.fillRect(0, 0, 500, 500);
+ textOutput.innerHTML = "";
+}
=======================================
--- /trunk/app.yaml Thu Sep 25 15:31:13 2008
+++ /trunk/app.yaml Tue Apr 27 04:15:12 2010
@@ -11,5 +11,9 @@
static_files: static/favicon.ico
upload: static/favicon.ico

+- url: /help.txt
+ static_files: static/help.txt
+ upload: static/help.txt
+
- url: /.*
script: index.py
=======================================
--- /trunk/index.html.tmpl Sat May 23 14:34:21 2009
+++ /trunk/index.html.tmpl Tue Apr 27 04:15:12 2010
@@ -9,79 +9,7 @@
<script type="text/javascript" src="/static/turtle.js"></script>
<script type="text/javascript" src="/static/parser.js"></script>
<script type="text/javascript" src="/static/logo.js"></script>
-<script type="text/javascript">
-var turtle = null;
-var logo = null;
-var canvas;
-var form;
-var sprite;
-var textOutput;
-var oldcode;
-var fast;
-var out;
-var DelayTurtle;
-
-function setup() {
- logo = new Logo();
-
- fast = 5;
- turtle = new DelayTurtle(canvas, sprite, fast, false);
- logo.setTurtle(turtle);
- logo.setTextOutput(textOutput);
-}
-
-function init(canvas_id, turtle_id, form_id, oldcode_id, textoutput_id) {
- canvas = document.getElementById(canvas_id);
- form = document.getElementById(form_id);
- textOutput = document.getElementById(textoutput_id);
- sprite = document.getElementById(turtle_id);
-
- // I hate opera, I hate firefox.
- canvas.style.width = 500;
- canvas.width = 500;
-
- canvas.style.height = 500;
- canvas.height = 500;
-
- oldcode = document.getElementById(oldcode_id);
- setup();
-}
-
-function run(speed, drawbits) {
- turtle.stop();
- if (speed !== fast) {
- fast = speed;
- var newturtle = null;
- // newturtle = new Turtle(canvas);
-
- newturtle = new DelayTurtle(canvas, sprite, fast, drawbits);
- logo.setTurtle(newturtle);
- turtle = newturtle;
- }
-
- oldcode.innerHTML += "\n" + form.code.value;
- //form.code.value = ""
-
-
- out = logo.run(form.code.value);
-
- if (out && out.type === "error") {
- alert(out.data);
- setup();
- }
-}
-
-function stop() {
- turtle.stop();
-}
-
-function clearcanvas() {
- var ctx = canvas.getContext('2d');
- ctx.fillStyle = "rgb(255,255,255)";
- ctx.fillRect(0, 0, 500, 500);
- textOutput.innerHTML = "";
-}
-</script>
+<script type="text/javascript" src="/static/init.js"></script>

</head>
<body onload="init('canvas','turtle','input','oldcode', 'textOutput');
clearcanvas(); run(5,false);">
@@ -126,7 +54,7 @@
<div id="turtle">
<embed width="20" height="20" id='sprite'
src="/static/turtle.svg"/>
</div>
- <canvas id="canvas">
+ <canvas id="canvas" width="500" height="500">
Your browser doesn't support canvas tags. Please upgrade to a recent
version of Firefox or Opera.
</canvas>
<span style="float: left; margin-right: auto;">
@@ -165,190 +93,8 @@
{% endif %}
</ul>
</div>
-<div id="notes">
-<pre>
-Quick reference logo guide:
-
-Stuff should work in lower or upper case.
-
-Types:
-
-WORDS: FW BW ....
-NUMBERS: 0, 0.1, 20
-LISTS: [1 2 3 5]
-SYMBOLS: "foo "bar
-VARIABLES: :foo :bar
-FUNCTION CALLS: COMMAND arg arg arg ...
- (COMMAND arg arg arg ...)
-
-Supported Commands:
-
-RESET Clear the screen, move home.
-
-
-Turtle Movement:
-
-FORWARD n Move the turtle forward n pixels
-FW n
-
-BACKWARD n Move the turtle backward n pixels
-
-RIGHT n Move the turtle left or right n degrees
-RT n
-LEFT n
-LT n
-
-SETX x Set the co-ordinates of the turtle
-SETY y
-SETXY x y
-
-HOME Move the turtle to the home position
-
-
-Drawing:
-
-CLEARSCREEN Clear the screen
-CLEAR
-CS
-
-CIRCLE r Draw a Circle of radius r around the turtle
-
-ARC r d Draw an arc of radius r for d degrees
-
-PENUP Lift the pen up and down
-PU
-PENDOWN
-PD
-
-COLOR [r g b] Set the pen color
-
-PENWIDTH w Set the pen width
-
-
-Text:
-
-PRINT "foo Prints "foo"
-PR "foo
-PRINT ["foo "bar] Prints "foo bar"
-PR ["foo "bar]
-
-CLEARTEXT Clears previously printed text
-CT
-
-
-Arithmetic:
-
-1 + 2 1 * 2
-SUM 1 2 PRODUCT 1 2
-(SUM 1 2 3 ...) (PRODUCT 1 2 3 ...)
-
-1 - 2 1 / 2
-DIFFERENCE 1 2 DIVIDE 1 2
-
-1 % 2
-MOD 1 2
-
-RANDOM n Return a integer in [0,n)
-RAND n
-
-RERANDOM s Set the random seed value
-SRAND s
-
-
-INT n
-ROUND n
-POWER e m
-EXP n
-LN n
-LOG10 n
-
-
-
-SIN, COS
-RADSIN,RADCOS
-
-ARCTAN
-RADARCTAN
-
-
-
-List Operators (experimental):
-These functions may break silently at the moment.
-
-FIRST, HEAD Return the first item in a list
-BUTFIRST, TAIL Return the everything but the first item in a list
-LAST Return the last item in a list
-BUTLAST Return everything but the last item in a list
-
-FPUT item list Return a new list with item at the front
-LPUT item list Return a new list with item at the back
-
-ITEM index list Retrieve the indexed item
-SETITEM index list value Set the indexed item
-
-EMPTY? list Return true if list is empty
-EMPTYP list
-
-Logical and Comparison:
-
-1 = 1
-EQUAL? 1 1
-EQUALP 1 1
-
-1 &lt; 2 1 &lt;= 2
-LESS? 1 2 LESSEQUAL? 1 2
-LESSP 1 2 LESSEQUALP 1 2
-
-2 &gt; 1 2 &gt; 1
-GREATER? 2 1 GREATEREQUAL? 2 1
-GREATERP 2 1 GREATEREQUALP 2 1
-
-AND TRUE FALSE OR FALSE TRUE
-
-Conditionals:
-
-IF COND [IF_TRUE]
-IF 2 &gt; 1 [FW 100]
-
-IFELSE COND [IF_TRUE] [IF_FALSE]
-IFELSE 2 &gt; 1 [FW 100 RT 90] [BW 100 LT 90]
-
-
-Setting and getting:
-
-Set x to 1: make "x 1
-Adding :n to :x :n + :x
-Setting :x to :n + :x make "x :x + :n
-
-Looping:
-
-REPEAT n [COMMANDS ...]
-
-STOP - Stop the current Repeat or function.
-
-OUTPUT f - Return f.
-OP f
-
-
-Defining and Calling:
-
-TO FOO :ARG1 :ARG2 BODY END
-
-TO SQUARE :length
-REPEAT 4 [FW :length RT 90]
-END
-
-SQUARE :10
-
-TO POLYGON :length :sides
-REPEAT :sides [FW :length RT 360/:sides]
-END
-
-POLYGON 5 10
-
-Note: Simple Tail recursion is supported.
-</pre>
-</div>
+
+<iframe id="notes" src="static/help.txt"/>

</div>
</body>
=======================================
--- /trunk/index.yaml Wed Mar 25 18:18:08 2009
+++ /trunk/index.yaml Tue Apr 27 04:15:12 2010
@@ -10,7 +10,6 @@
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

-# Unused in query history -- copied from input.
- kind: LogoProgram
properties:
- name: date
=======================================
--- /trunk/static/papert.css Sat Feb 14 14:47:20 2009
+++ /trunk/static/papert.css Tue Apr 27 04:15:12 2010
@@ -77,8 +77,7 @@
#notes {
clear: left;
width: 100%;
- padding: 4px 0;
- margin-left: 100px;
+ height: 100%;
}

#footer{
=======================================
--- /trunk/static/turtle.js Wed May 20 10:22:39 2009
+++ /trunk/static/turtle.js Tue Apr 27 04:15:12 2010
@@ -17,8 +17,7 @@

this.c.lineCap = "round";
this.turtle = turtle;
- this.sprite = document.getElementById('sprite').getSVGDocument();
- this.sprite = this.sprite.getElementById('sprite');
+ this.sprite = document.getElementById('sprite');
this.visible = true;
this.undobuffer = [];
this.redobuffer = [];

--
You received this message because you are subscribed to the Google Groups "papertlogo" group.
To post to this group, send email to paper...@googlegroups.com.
To unsubscribe from this group, send email to papertlogo+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/papertlogo?hl=en.

Reply all
Reply to author
Forward
0 new messages