Permalink
Browse files

update snap

  • Loading branch information...
sdpython committed Jan 11, 2018
1 parent 0bf8fbf commit 49e1d350f15a1a683c51203865690eab3c62c7f8
Showing with 17,656 additions and 3,550 deletions.
  1. +2 −0 src/code_beatrix/jsscripts/README.txt
  2. 0 src/code_beatrix/jsscripts/Snapin8r2/__init__.py
  3. BIN src/code_beatrix/jsscripts/snap/Backgrounds/{brick_wall_and_stairs.jpg → brick-wall-and-stairs.jpg}
  4. +283 −0 src/code_beatrix/jsscripts/snap/CONTRIBUTING.md
  5. BIN src/code_beatrix/jsscripts/snap/Costumes/Alonzo3D.png
  6. +2 −1 src/code_beatrix/jsscripts/snap/Costumes/COSTUMES
  7. +55 −0 src/code_beatrix/jsscripts/snap/Costumes/alonzo.svg
  8. +1 −1 src/code_beatrix/jsscripts/snap/FileSaver.min.js
  9. +189 −189 src/code_beatrix/jsscripts/snap/{agpl.txt → LICENSE}
  10. +2 −2 src/code_beatrix/jsscripts/snap/README.md
  11. +1,076 −1,851 src/code_beatrix/jsscripts/snap/blocks.js
  12. +422 −75 src/code_beatrix/jsscripts/snap/byob.js
  13. +0 −173 src/code_beatrix/jsscripts/snap/contributing to BYOB4.txt
  14. +693 −148 src/code_beatrix/jsscripts/snap/gui.js
  15. +440 −1 src/code_beatrix/jsscripts/snap/history.txt
  16. +81 −7 src/code_beatrix/jsscripts/snap/lang-ca.js
  17. +96 −8 src/code_beatrix/jsscripts/snap/lang-de.js
  18. +470 −128 src/code_beatrix/jsscripts/snap/lang-eo.js
  19. +378 −52 src/code_beatrix/jsscripts/snap/lang-hr.js
  20. +215 −20 src/code_beatrix/jsscripts/snap/lang-nl.js
  21. +385 −54 src/code_beatrix/jsscripts/snap/lang-pl.js
  22. +126 −37 src/code_beatrix/jsscripts/snap/lang-pt.js
  23. +91 −11 src/code_beatrix/jsscripts/snap/lang-ru.js
  24. +10 −0 src/code_beatrix/jsscripts/snap/lang-zh_CN.js
  25. +3 −7 src/code_beatrix/jsscripts/snap/libraries/Eisenbergification.xml
  26. +4 −1 src/code_beatrix/jsscripts/snap/libraries/LIBRARIES
  27. +67 −0 src/code_beatrix/jsscripts/snap/libraries/animation_module.xml
  28. +18 −0 src/code_beatrix/jsscripts/snap/libraries/audioComp_module.xml
  29. +1,621 −0 src/code_beatrix/jsscripts/snap/libraries/biginteger.js
  30. +1 −1 src/code_beatrix/jsscripts/snap/libraries/bignumbers.xml
  31. +1 −1 src/code_beatrix/jsscripts/snap/libraries/list-utilities.xml
  32. +0 −1 src/code_beatrix/jsscripts/snap/libraries/penTrails.xml
  33. +3 −0 src/code_beatrix/jsscripts/snap/libraries/pixel_module.xml
  34. +6,558 −0 src/code_beatrix/jsscripts/snap/libraries/schemeNumber.js
  35. +1 −0 src/code_beatrix/jsscripts/snap/libraries/tools.xml
  36. +3 −2 src/code_beatrix/jsscripts/snap/lists.js
  37. +15 −15 src/code_beatrix/jsscripts/snap/locale.js
  38. +169 −52 src/code_beatrix/jsscripts/snap/morphic.js
  39. +29 −4 src/code_beatrix/jsscripts/snap/morphic.txt
  40. +1,332 −337 src/code_beatrix/jsscripts/snap/objects.js
  41. +1 −1 src/code_beatrix/jsscripts/snap/paint.js
  42. +4 −3 src/code_beatrix/jsscripts/snap/snap.html
  43. +40 −0 src/code_beatrix/jsscripts/snap/snap_fast.html
  44. +215 −100 src/code_beatrix/jsscripts/snap/store.js
  45. +1,735 −0 src/code_beatrix/jsscripts/snap/symbols.js
  46. +5 −3 src/code_beatrix/jsscripts/snap/tables.js
  47. +392 −113 src/code_beatrix/jsscripts/snap/threads.js
  48. +1 −1 src/code_beatrix/jsscripts/snap/tools.xml
  49. +0 −143 src/code_beatrix/jsscripts/snap/translating Snap.txt
  50. +416 −2 src/code_beatrix/jsscripts/snap/widgets.js
  51. +3 −3 src/code_beatrix/jsscripts/snap/xml.js
  52. +2 −2 src/code_beatrix/jsscripts/snap/ypr.js
@@ -0,0 +1,2 @@
https://github.com/djdolphin/Snapin8r2/
https://github.com/Jonathan50/desnapifier
@@ -0,0 +1,283 @@
# How to contribute

Attached is the current development code base for BYOB4 a.k.a. Snap. It consists of
several JavaScript, HTML and text files, and while some of it may be functional
most parts will be in flux and subject to frequent, even fundamental modifications.
This document lays out a few simple guidelines ensuring that collaborative code
contribution works out.


## Coding


### Working with changesets

You'll often want to change or add code in existing JS files. Please don't. Instead
use a changeset. The way I always do it myself is to copy the empty `changeset.js`
file and rename it to something like `JensChangesToMorphic.js`.

Into this file I write all the functions I want to add to Morphic. If I want to
change a function in Morphic.js I copy it to the changeset and edit it there. Then
I always validate the changeset with JSLint.com.

Please check your code frequently with JSLint!

For our Snap code set JSLint's settings to:

* assume a browser
* tolerate missing 'use strict' pragma
* `4` indentation
* `78` maximum line length

If you're working on the core Morphic library you can also

* tolerate eval
* tolerate unfiltered for in

although you'll probably not ever going to need either EVAL or FORIN in your
changesets anyway.

There are, of course, other tools - like JSHint and browser debug tools - that
help you debug your code. Feel free to use whichever suits you best, but let's
all agree on JSLint's (nitpicky!) formatting rules so we get code that's well
readable and easily shareable among ourselves.


### Coding style

Snap's codebase is both big and fast moving. We'll continue to churn out several
builds per day for a long time, hunting bugs and adding features throughout the
whole application. We'll also need to be able to get our heads around the whole
codebase. Being able to read and to quickly understand the code is most important,
much more so than mathematical elegance.

Let me really stress this point: In creating Snap we're neither playing "Code Golf"
(solving a problem using the least number of keystrokes) nor are we trying to
outsmart Knuth. Instead we're maintaining a large number of small interchangeable
code chunks, therefore:


### Avoid

* accessing the DOM
* frameworks (e.g. JQuery)
* modules and namespaces (e.g. IIFE)
- all of Snap is a single "World" with unique names for everything
- remember: Changesets contain "small interchangeable code chunks"...
* passing "thisArg" to functions like `map()`, `filter()` or `forEach()`
- except in `call()`
- always use `myself` to reference `this` in an outer scope instead
* meta-class systems
- use Morphic's way of creating class-like constructors instead
- initialize all attributes either in the constructor or in an `init()`
method, so you now the object's structure by casting a single look
upon it. Avoid adding adding attributes elsewhere, or if you do,
initialize them explicitly to "null" in the constructor or `init()`
code
* nested ternary operators
* RegEx
* overwriting existing definitions
- except in changesets, duh :-)
- create new constructors instead
* non-descriptive names for variables, functions, objects
* giant functions
- which often are "modules in disguise",
especially if they define local helper functions
- create a new constructor instead


### Testing your code

(don't worry, I'm not talking about formal UnitTest Suites or other BDSM software
fetishes, just about playing with what you're creating while you're doing it)

To test your changesets just add another line in the html stub file with your
changeset. Make sure to put your changeset **after** Morphic.js and Blocks.js and
whichever libraries are already included, so it'll actually get used.

In your changeset override the world's `customMorphs` function so it returns a
list of instances of your Morphs. For `Blocks.js` that code is:

```javascript
var BlockMorph;
var ScriptsMorph;
WorldMorph.prototype.customMorphs = function () {
var sm = new ScriptsMorph();
sm.setExtent(new Point(800, 600));
return [
new BlockMorph(),
sm
];
};
```

Just modify this code so it returns your list of sample Morphs instead of
`BlockMorph` and `ScriptsMorph` instances.

Once you've added this code to your changeset you can open your sample html file
in your browser, and you'll find your sample Morphs in the World's DEMO menu.


### Inspectors

To actually test play with your Morphs you can right-click on them and open an
inspector on them. You can open more than one inspector on each object. The
inspector pretty much works the same as in Smalltalk. It even has an evaluation
pane at the bottom, in which you can type in any JS code, mark it with your mouse
(or select all with ctrl-a), righ-click on the selection and either "do it", "show
it" or "inspect it" (again, like in Squeak).

Needless to say, in the evaluation pane `this` always refers to the inspected
object.


### Source Code Mgmt

The good thing about changesets is that you can continue working on them regardless
of new dev releases that happen in the meantime. When you feel you've got something
that's finished just send me your changeset, and I'll work all the changesets into
the Snap codebase and release another dev version. That way there will always (and
frequently) be a harmonized common code base.

---


## Translating Snap!

At this stage of development, Snap! can be translated to any LTR language
maintaining the current order of inputs (formal parameters in blocks).

Translating Snap! is easy:


### 1. Download

Download the sources and extract them into a local folder on your
computer: https://snap.berkeley.edu/snapsource/snap.zip.

Use the German translation file (named 'lang-de.js') as template for your
own translations. Start with editing the original file, because that way
you will be able to immediately check the results in your browsers while
you're working on your translation (keep the local copy of snap.html open
in your web browser, and refresh it as you progress with your
translation).


### 2. Edit

Edit the translation file with a regular text editor, or with your
favorite JavaScript editor.

In the first non-commented line (the one right below this
note) replace "de" with the two-letter ISO 639-1 code for your language,
e.g.

fr - French => SnapTranslator.dict.fr = {
it - Italian => SnapTranslator.dict.it = {
pl - Polish => SnapTranslator.dict.pl = {
pt - Portuguese => SnapTranslator.dict.pt = {
es - Spanish => SnapTranslator.dict.es = {
el - Greek => => SnapTranslator.dict.el = {

etc. (see <http://en.wikipedia.org/wiki/ISO_639-1>)


### 3. Translate

Then work through the dictionary, replacing the German strings against
your translations. The dictionary is a straight-forward JavaScript ad-hoc
object, for review purposes it should be formatted as follows:

```
{
'English string':
'Translation string',
'last key':
} 'last value'
```

and you only edit the indented value strings. Note that each key-value
pair needs to be delimited by a comma, but that there shouldn't be a comma
after the last pair (again, just overwrite the template file and you'll be
fine).

If something doesn't work, or if you're unsure about the formalities you
should check your file with [JSLint](https://JSLint.com)

This will inform you about any missed commas etc.


### 4. Accented characters

Depending on which text editor and which file encoding you use you can
directly enter special characters (e.g. Umlaut, accented characters) on
your keyboard. However, I've noticed that some browsers may not display
special characters correctly, even if other browsers do. So it's best to
check your results in several browsers. If you want to be on the safe
side, it's even better to escape these characters using Unicode.

See this collection of JavaScript utilities: http://0xcc.net/jsescape/


### 5. Block specs

At this time your translation of block specs will only work
correctly, if the order of formal parameters and their types
are unchanged. Placeholders for inputs (formal parameters) are
indicated by a preceding % prefix and followed by a type
abbreviation.

For example:

'say %s for %n secs'

can currently not be changed into

'say %n secs long %s'

and still work as intended.

Similarly

'point towards %dst'

cannot be changed into

'point towards %cst'

without breaking its functionality.


### 6. Submit

When you're done, rename the edited file by replacing the "de" part of the
filename with the two-letter ISO 639-1 code for your language, e.g.

fr - French => lang-fr.js
it - Italian => lang-it.js
pl - Polish => lang-pl.js
pt - Portuguese => lang-pt.js
es - Spanish => lang-es.js
el - Greek => => lang-el.js

and send it to me for inclusion in the official Snap! distribution.
Once your translation has been included, Your name will the shown in the
"Translators" tab in the "About Snap!" dialog box, and you will be able to
directly launch a translated version of Snap! in your browser by appending

lang:xx

to the URL, `xx` representing your translations two-letter code.


### 7. Known issues

In some browsers accents or ornaments located in typographic ascenders
above the cap height are currently (partially) cut-off.

---

Enjoy!

-Jens
Binary file not shown.
@@ -4,7 +4,8 @@ abby-c.svg abby c
abby-d.svg abby d
airplane2.png airplane2
alonzo.png alonzo
Alonzo3D.png alonzo3D
Alonzo3D.png alonzo (3D)
alonzo.svg alonzo (vector)
amon.gif amon
anina_pop_down.png anina pop down
anina_pop_front.png anina pop front
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="95px" height="123px" viewBox="0 0 95 123" enable-background="new 0 0 95 123" xml:space="preserve">
<g id="ID0.8323829737491906" transform="matrix(1, 0, 0, 1, 0, 3)">
<path id="R_Leg" fill="#FFC93E" stroke="#603813" stroke-width="3" d="M47.316,104.251c0-1.276,0.358-3.109,2.338-3.523
c2.857-0.599,6.126,2.293,7.014,3.146c-0.065,0.338,1.047,7.173,1.047,7.765c0,2.004-0.535,2.083-0.743,2.116
c-1.956,0.284-7.169-5.197-9.562-8.387C47.376,105.193,47.316,104.809,47.316,104.251L47.316,104.251L47.316,104.251z"/>
<path id="Center_Leg" fill="#FFC93E" stroke="#603813" stroke-width="4" d="M39.394,113.827c-1.418-1.538-1.621-5.707-1.621-7.482
c0-0.752,0.039-1.253,0.041-1.268l0.002-0.039c0,0-0.004-0.16-0.004-0.219c0-3.341,3.075-4.501,3.597-4.675
c1.781,0.021,4.858,0.864,5.593,2.136c0.075,0.128,0.144,0.289,0.144,0.495c0,0.181-0.054,0.4-0.208,0.666
c-0.071,0.121-1.335,3.109-2.405,5.4l-0.765,2.119c-0.572,1.851-1.473,3.703-2.452,3.703
C40.542,114.666,39.914,114.392,39.394,113.827L39.394,113.827L39.394,113.827z"/>
<path id="R_Arm" fill="#FFC93E" stroke="#603813" stroke-width="3" d="M79.505,89.611l-1.383-2.44
c-1.516-2.637-3.265-5.052-4.807-7.177c-1.983-2.738-3.71-5.571-4.281-7.572c-0.207-0.721-0.107-1.41,0.189-1.79
c0.028-0.102,0.327-0.265,0.539-0.309c2.541-0.55,13.06,5.491,15.685,8.719c3.845,4.727,5.382,11.358,4.524,14.699
c-0.352,1.364-1.139,2.332-2.278,2.793C84.782,97.71,82.867,95.586,79.505,89.611L79.505,89.611L79.505,89.611z"/>
<path id="Body" fill="#FFC93E" stroke="#603813" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" d="
M38.097,43.007c0,0-3.11-9.629-6.011-13.598c-1.72-2.79-4.2-6.267-7.477-6.049c-4.067,0.106-6.283,4.984-10.299,6.545
c-2.602,1.003-9.461,2.314-8.406,0c2.813-5.814,14.04-9.079,16.844-16.379c1.263-3.305-4.272-7.252-7.941-7.942
c-2.745-0.501-4.039,4.217-6.545,5.615c-1.151,0.643-4.339,1.305-3.753,0C6.629,6.836,9.052,1.172,13.845-0.495
c3.617-1.254,7.562,2.473,10.299,5.119c8.464,8.185,15.617,17.938,23.24,26.65l4.511,5.139c0,0,3.225,3.956,5.692,6.566
c0.044,0.045,2.378-0.317,3.989-1.657c1.314-1.096,1.141-2.323,1.559-4.902c0.384-2.371,0.802-6.659,2.072-6.681
c1.916-0.029,3.176,7.868,3.666,10.793l0.272,1.565c0.643,3.479,3.999,13.94,4.144,14.384c0.046,0.108,0.121,0.249,0.121,0.249
l0.027,0.056l0.038,0.047c5.185,6.429,9.038,14.223,9.038,21.524c0,15.464-13.555,26.349-31.697,26.349
c-3.365,0-6.657-0.473-9.783-1.398l-0.168-0.049c0,0-4.908-0.412-11.186,7.84c-1.26,1.657-1.147,3.201-2.922,2.726
c-0.592-0.158-1.026-0.593-1.382-1.383c-0.848-1.884-0.222-6.347,0.816-9.197l0.163-0.448l-0.375-0.297
c-0.092-0.073-10.274-7.493-11.303-18.125c-0.896-9.268,3.785-14.545,5.728-17.444l1.117-1.858
c1.409-3.428-1.243-8.195-3.583-12.401c-1.397-2.511-3.652-6.176-3.143-7.038c0.565-0.954,2.585,0.062,4.625,1.034
c1.654,0.791,3.245,1.908,4.35,1.171c1.149-0.765,0.396-2.686-0.649-5.346c-0.982-2.498-2.841-6.443-2.127-8.072
c0.197-0.447,0.542-0.762,1.055-0.961c1.897-0.734,4.609,2.461,6.805,4.961C31.532,41.469,34.57,44.927,38.097,43.007
L38.097,43.007L38.097,43.007z"/>
<g id="L_Eye">
<path id="White_1_" fill="#FFFFFF" d="M41.228,79.489c0,2.789,2.263,5.05,5.054,5.05c2.791,0,5.051-2.261,5.051-5.05
c0-2.791-2.261-5.056-5.051-5.056C43.49,74.436,41.228,76.698,41.228,79.489L41.228,79.489L41.228,79.489z"/>
<path id="Pupil_1_" fill="#603813" d="M46.961,75.796c0.981,0,1.87,0.398,2.513,1.043c0.645,0.643,1.042,1.532,1.042,2.513
c0,0.981-0.397,1.87-1.042,2.514c-0.644,0.644-1.532,1.042-2.513,1.042s-1.87-0.398-2.513-1.042
c-0.645-0.644-1.042-1.532-1.042-2.514c0-0.98,0.398-1.87,1.042-2.513C45.092,76.194,45.98,75.796,46.961,75.796L46.961,75.796z"
/>
</g>
<g id="R_Eye">
<path id="White" fill="#FFFFFF" d="M65.568,79.489c0,2.789,2.262,5.05,5.054,5.05c2.788,0,5.052-2.261,5.052-5.05
c0-2.791-2.262-5.056-5.052-5.056C67.83,74.436,65.568,76.698,65.568,79.489L65.568,79.489L65.568,79.489z"/>
<path id="Pupil" fill="#603813" d="M67.745,79.352c0,1.964,1.59,3.555,3.556,3.555c1.963,0,3.556-1.59,3.556-3.555
c0-1.962-1.593-3.556-3.556-3.556C69.335,75.796,67.745,77.389,67.745,79.352L67.745,79.352L67.745,79.352z"/>
</g>
<path id="L_Arm" fill="#FFC93E" stroke="#603813" stroke-width="3" d="M6.341,98.994c-1.036-0.661-1.633-1.753-1.729-3.161
c-0.234-3.445,2.492-9.682,7.134-13.626c3.17-2.694,14.617-6.707,17.014-5.703c0.198,0.083,0.463,0.297,0.472,0.404
c0.224,0.427,0.194,1.119-0.14,1.791c-0.927,1.864-3.142,4.335-5.594,6.66c-1.906,1.814-4.065,3.863-6.035,6.181l-1.807,2.141
C11.259,98.943,8.986,100.685,6.341,98.994L6.341,98.994L6.341,98.994z"/>
<path id="Mouth" fill="none" stroke="#603813" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M63.148,95.391
c0,0-4.599,0.004-7.819-2.756"/>
</g>
</svg>
Oops, something went wrong.

0 comments on commit 49e1d35

Please sign in to comment.