Hardmath123 wrote:
Obsolete blocks?
In which format? The Flash editor can already convert 1.4 to 2.0, so I'll imitate that for that conversion.
Also, what about vector graphics?
Eh, there's no neat trick. I already do lazy loading/conversion of images to some extent. If the target format supports SVGs, I'll copy them across. I don't know about rasterising; I guess I could use Cairo or similar, but I'd rather avoid adding a dependency, so I might just throw an error or convert it with a blank image (and a warning). (Although I could have optional dependencies?)
How about (take a deep breath) writing Kurt 2.0 in JavaScript?
I've thought about it; but all the existing code uses Kurt from Python. And I can't find a good Construct-like library, so defining the binary format is a pain.
Offline
blob8108 wrote:
I've thought about it; but all the existing code uses Kurt from Python. And I can't find a good Construct-like library, so defining the binary format is a pain.
Aww… why not rip MathWizz' lib?
Offline
Hardmath123 wrote:
blob8108 wrote:
I've thought about it; but all the existing code uses Kurt from Python. And I can't find a good Construct-like library, so defining the binary format is a pain.
Aww… why not rip MathWizz' lib?
I dunno; the only uses I can think of for kurt.js would be
a) a little browser-based scratchblocks generator for Scratch 2.0 projects
b) for integrating with Snap!
But the scratchblocks generator is pretty trivial based off the raw project.json, and Snap! only really needs [everything else] -> Snap!, not universal two-way conversion.
And I'd end up maintaining two codebases, which is never fun.
So, yeah, it solves the vector images problem without requiring another Python library (although I would need another JS library; where's the logic? ); but I think it creates too many other problems.
Kurt's mainly used for analysing Scratch projects from Python code, so I guess that's my main use case.
Last edited by blob8108 (2013-03-20 09:48:01)
Offline
Oh, well. It was worth a try.
Offline
Neat! Can you put up the code somewhere?
Offline
I've had the sb.js code on github for a while. https://github.com/MathWizz/sb.js
Offline
Hardmath123 wrote:
Also, I can use the dot syntax for list querying too, right? Why is mylist.5 a bad idea? Which looks nicer:
Code:
print colors.(indices.5) print colors[indices[5]]
The reason most languages don't is because it's harder to parse—the tokenizer isn't sure if you mean <indices> <.> <5> or <indices> <.5>, and the picks the latter because it's greedy.
Offline
That's it? I was expecting something more reasonable.
I'm not planning on allowing .5, anyway, you have to use 0.5.
Offline
MathWizz wrote:
I've had the sb.js code on github for a while. https://github.com/MathWizz/sb.js
That's awesome! blob, you convinced yet?
Offline
nXIII wrote:
Hardmath123 wrote:
Also, I can use the dot syntax for list querying too, right? Why is mylist.5 a bad idea? Which looks nicer:
Code:
print colors.(indices.5) print colors[indices[5]]The reason most languages don't is because it's harder to parse—the tokenizer isn't sure if you mean <indices> <.> <5> or <indices> <.5>, and the picks the latter because it's greedy.
Oops, that was just about the inside one ("indices.5"). The outside one ("colors.(indices.5)") is a contradiction—the value after the dot is not evaluated in "colors.indices", but it is in "colors.(indices.5)"—unless you meant that ".(…)" is the equivalent of the "[…]" operator and ".<identifier|number>" is the equivalent of the "." operator….
Offline
bharvey wrote:
Hardmath123 wrote:
I'm not planning on allowing .5, anyway, you have to use 0.5.
Nope, you definitely can't call it Pravic!
My language, my rules.
It's really annoying to see people write CSS like
-webkit-animation-duation:.5s;
@nXIII: I see what you mean. There seem to be two cases:
object.expression_to_get_a_key_or_index
object.name_of_property_without_quotes_for_convenience
Maybe I should use the underscore operator for evaluated subscripting:
object.property
object_"property"
Offline
Hardmath123 wrote:
MathWizz wrote:
I've had the sb.js code on github for a while. https://github.com/MathWizz/sb.js
That's awesome! blob, you convinced yet?
"Kurt is written in Python ".replace(" ", ". ").upper() #
However, if you (and Math?) want to go rewrite it in JS — go ahead!
Offline
blob8108 wrote:
Hardmath123 wrote:
MathWizz wrote:
I've had the sb.js code on github for a while. https://github.com/MathWizz/sb.js
That's awesome! blob, you convinced yet?
"Kurt is written in Python ".replace(" ", ". ").upper() #
OK. OK. I. GET. IT.
However, if you (and Math?) want to go rewrite it in JS — go ahead!
Erm… I have no clue how to deal with a binary format.
Offline
Hardmath123 wrote:
blob8108 wrote:
Hardmath123 wrote:
That's awesome! blob, you convinced yet?"Kurt is written in Python ".replace(" ", ". ").upper() #
OK. OK. I. GET. IT.
"".join(map(dict(enumerate(map(chr, range(97, 123)), 1)).get, [23, 5, 1, 18, 5, 20, 15, 15, 3, 15, 15, 12]))
However, if you (and Math?) want to go rewrite it in JS — go ahead!
Erm… I have no clue how to deal with a binary format.
MathWizz wrote:
I've had the sb.js code on github for a while. https://github.com/MathWizz/sb.js
(Math and math. Eh heh heh. )
Offline
blob8108 wrote:
Hardmath123 wrote:
blob8108 wrote:
"Kurt is written in Python ".replace(" ", ". ").upper() #OK. OK. I. GET. IT.
"".join(map(dict(enumerate(map(chr, range(97, 123)), 1)).get, [23, 5, 1, 18, 5, 20, 15, 15, 3, 15, 15, 12]))
(lambda x:x[10]+x[9]+x[7])("just for kicks")
(Math and math. Eh heh heh. )
You can eh-heh-heh when we're on Wheel of Fortune's Before and After.
Offline
Hardmath123 wrote:
Erm… I have no clue how to deal with a binary format.
Are you talking about Typed Arrays? I think all modern web browsers support it, save IE.
EDIT: Works in IE 10
Last edited by shadow_7283 (2013-03-21 08:38:28)
Offline
Hardmath123 wrote:
bharvey wrote:
Hardmath123 wrote:
I'm not planning on allowing .5, anyway, you have to use 0.5.
Nope, you definitely can't call it Pravic!
My language, my rules.
It's really annoying to see people write CSS likeCode:
-webkit-animation-duation:.5s;
Stuff like rgba(0,0,0,.3) does look better without the leading zero, though.
shadow_7283 wrote:
Hardmath123 wrote:
Erm… I have no clue how to deal with a binary format.
Are you talking about Typed Arrays? I think all modern web browsers support it, save IE.
EDIT: Works in IE 10
Well, Opera mini doesn't.
IE8 and IE9 don't either, but nobody cares about them (or Opera mini).
Offline
Snapduino pre-pre-alpha is out now (you can turn on and off a digital pin )! http://www.github.com/technoboy10/snapduino
Offline
technoboy10 wrote:
Snapduino pre-pre-alpha is out now (you can turn on and off a digital pin )! http://www.github.com/technoboy10/snapduino
You're awesome. Let us know when it's ready to put on the Snap! page.
@Hm: Is there a single link for Snapin8r we should put there?
@blob: I'm not asking about Kurt b/c it sounds like we should wait for version 2, right?
Last edited by bharvey (2013-03-21 23:34:08)
Offline
I'll give you the gdocs zip link…
EDIT: Here's the closed-source mac-only version: https://docs.google.com/file/d/0B1UC0dD … sp=sharing. I'll make a new ZIP with annotated source and instructions later today, but for now this should suffice.
Last edited by Hardmath123 (2013-03-21 23:48:13)
Offline
Here's a patch to add support for device orientation/rotation natively. It does not check whether the features exist yet.
// changes.js // Hardware stuff, and declaring blocks DeviceSensor = { "acceleration": { "x": 0, "y": 0, "z": 0 }, "acceleration (with gravity)": { "x": 0, "y": 0, "z": 0 }, "rotation": { "x": 0, "y": 0, "z": 0 }, "rotation rate": { "x": 0, "y": 0, "z": 0 }, "compass": 0 } SpriteMorph.prototype.blocks.device = { "spec": "Device %mtype %mdir", "category": "sensing", "type": "reporter" } SpriteMorph.prototype.device = function (mtype, mdir) { return DeviceSensor[mtype][mdir]; } SpriteMorph.prototype.blocks.compass = { "spec": "Compass heading", "category": "sensing", "type": "reporter" } SpriteMorph.prototype.compass = function () { return DeviceSensor["compass"]; } window.addEventListener("devicemotion", function (event) { var a = event.acceleration; var ag = event.accelerationIncludingGravity; var rr = event.rotationRate; DeviceSensor.acceleration = { x: a.x, y: a.y, z: a.z }; DeviceSensor["acceleration (with gravity)"] = { x: ag.x, y: ag.y, z: ag.z }; DeviceSensor["rotation rate"] = { x: rr.alpha, y: rr.beta, z: rr.gamma }; }); window.addEventListener("deviceorientation", function (event) { DeviceSensor.rotation = { x: event.alpha, y: event.beta, z: event.gamma }; DeviceSensor.compass = event.webkitCompassHeading; }); // Declarations done // Adding blocks, declaring special input slots SpriteMorph.prototype.blockTemplates = function (category) { var blocks = [], myself = this, varNames, button, cat = category || 'motion', txt; function block(selector) { var newBlock = SpriteMorph.prototype.blockForSelector(selector, true); newBlock.isTemplate = true; return newBlock; } function variableBlock(varName) { var newBlock = SpriteMorph.prototype.variableBlock(varName); newBlock.isDraggable = false; newBlock.isTemplate = true; return newBlock; } function watcherToggle(selector) { var info = SpriteMorph.prototype.blocks[selector]; return new ToggleMorph('checkbox', this, function () { myself.toggleWatcher( selector, localize(info.spec), myself.blockColor[info.category]); }, null, function () { return myself.showingWatcher(selector); }, null); } function variableWatcherToggle(varName) { return new ToggleMorph('checkbox', this, function () { myself.toggleVariableWatcher(varName); }, null, function () { return myself.showingVariableWatcher(varName); }, null); } if (cat === 'motion') { blocks.push(block('forward')); blocks.push(block('turn')); blocks.push(block('turnLeft')); blocks.push('-'); blocks.push(block('setHeading')); blocks.push(block('doFaceTowards')); blocks.push('-'); blocks.push(block('gotoXY')); blocks.push(block('doGotoObject')); blocks.push(block('doGlide')); blocks.push('-'); blocks.push(block('changeXPosition')); blocks.push(block('setXPosition')); blocks.push(block('changeYPosition')); blocks.push(block('setYPosition')); blocks.push('-'); blocks.push(block('bounceOffEdge')); blocks.push('-'); blocks.push(watcherToggle('xPosition')); blocks.push(block('xPosition')); blocks.push(watcherToggle('yPosition')); blocks.push(block('yPosition')); blocks.push(watcherToggle('direction')); blocks.push(block('direction')); } else if (cat === 'looks') { blocks.push(block('doSwitchToCostume')); blocks.push(block('doWearNextCostume')); blocks.push(watcherToggle('getCostumeIdx')); blocks.push(block('getCostumeIdx')); blocks.push('-'); blocks.push(block('doSayFor')); blocks.push(block('bubble')); blocks.push(block('doThinkFor')); blocks.push(block('doThink')); blocks.push('-'); blocks.push(block('changeEffect')); blocks.push(block('setEffect')); blocks.push(block('clearEffects')); blocks.push('-'); blocks.push(block('changeScale')); blocks.push(block('setScale')); blocks.push(watcherToggle('getScale')); blocks.push(block('getScale')); blocks.push('-'); blocks.push(block('show')); blocks.push(block('hide')); blocks.push('-'); blocks.push(block('comeToFront')); blocks.push(block('goBack')); // for debugging: /////////////// if (this.world().isDevMode) { blocks.push('-'); txt = new TextMorph(localize('development mode \ndebugging primitives:')); txt.fontSize = 9; txt.setColor(new Color(230, 230, 230)); blocks.push(txt); blocks.push('-'); blocks.push(block('log')); blocks.push(block('alert')); } ///////////////////////////////// } else if (cat === 'sound') { blocks.push(block('playSound')); blocks.push(block('doPlaySoundUntilDone')); blocks.push(block('doStopAllSounds')); blocks.push('-'); blocks.push(block('doRest')); blocks.push('-'); blocks.push(block('doPlayNote')); blocks.push('-'); blocks.push(block('doChangeTempo')); blocks.push(block('doSetTempo')); blocks.push(watcherToggle('getTempo')); blocks.push(block('getTempo')); } else if (cat === 'pen') { blocks.push(block('clear')); blocks.push('-'); blocks.push(block('down')); blocks.push(block('up')); blocks.push('-'); blocks.push(block('setColor')); blocks.push(block('changeHue')); blocks.push(block('setHue')); blocks.push('-'); blocks.push(block('changeBrightness')); blocks.push(block('setBrightness')); blocks.push('-'); blocks.push(block('changeSize')); blocks.push(block('setSize')); blocks.push('-'); blocks.push(block('doStamp')); } else if (cat === 'control') { blocks.push(block('receiveGo')); blocks.push(block('receiveKey')); blocks.push(block('receiveClick')); blocks.push(block('receiveMessage')); blocks.push('-'); blocks.push(block('doBroadcast')); blocks.push(block('doBroadcastAndWait')); blocks.push('-'); blocks.push(block('doWarp')); blocks.push('-'); blocks.push(block('doWait')); blocks.push(block('doWaitUntil')); blocks.push('-'); blocks.push(block('doForever')); blocks.push(block('doRepeat')); blocks.push(block('doUntil')); blocks.push('-'); blocks.push(block('doIf')); blocks.push(block('doIfElse')); blocks.push('-'); blocks.push(block('doReport')); blocks.push('-'); blocks.push(block('doStopBlock')); blocks.push(block('doStop')); blocks.push(block('doStopAll')); blocks.push('-'); blocks.push(block('doRun')); blocks.push(block('fork')); blocks.push(block('evaluate')); blocks.push('-'); /* // list variants commented out for now (redundant) blocks.push(block('doRunWithInputList')); blocks.push(block('forkWithInputList')); blocks.push(block('evaluateWithInputList')); blocks.push('-'); */ blocks.push(block('doCallCC')); blocks.push(block('reportCallCC')); blocks.push('-'); blocks.push(block('receiveOnClone')); blocks.push(block('createClone')); blocks.push(block('removeClone')); } else if (cat === 'sensing') { blocks.push(block('reportTouchingObject')); blocks.push(block('reportTouchingColor')); blocks.push(block('reportColorIsTouchingColor')); blocks.push('-'); blocks.push(block('doAsk')); blocks.push(watcherToggle('getLastAnswer')); blocks.push(block('reportLastAnswer')); blocks.push('-'); blocks.push(block('reportMouseX')); blocks.push(block('reportMouseY')); blocks.push(block('reportMouseDown')); blocks.push('-'); blocks.push(block('reportKeyPressed')); blocks.push('-'); blocks.push(block('reportDistanceTo')); blocks.push('-'); blocks.push(block('doResetTimer')); blocks.push(watcherToggle('getTimer')); blocks.push(block('reportTimer')); blocks.push('-'); blocks.push(block('reportAttributeOf')); blocks.push('-'); blocks.push(block('reportURL')); blocks.push('-'); blocks.push(block('reportIsFastTracking')); blocks.push(block('doSetFastTracking')); blocks.push('-'); blocks.push(block('device')); blocks.push(block('compass')); // for debugging: /////////////// if (this.world().isDevMode) { blocks.push('-'); txt = new TextMorph(localize('development mode \ndebugging primitives:')); txt.fontSize = 9; txt.setColor(new Color(230, 230, 230)); blocks.push(txt); blocks.push('-'); blocks.push(block('colorFiltered')); blocks.push(block('reportStackSize')); blocks.push(block('reportFrameCount')); } } else if (cat === 'operators') { blocks.push(block('reifyScript')); blocks.push(block('reifyReporter')); blocks.push(block('reifyPredicate')); blocks.push('#'); blocks.push('-'); blocks.push(block('reportSum')); blocks.push(block('reportDifference')); blocks.push(block('reportProduct')); blocks.push(block('reportQuotient')); blocks.push('-'); blocks.push(block('reportModulus')); blocks.push(block('reportRound')); blocks.push(block('reportMonadic')); blocks.push(block('reportRandom')); blocks.push('-'); blocks.push(block('reportLessThan')); blocks.push(block('reportEquals')); blocks.push(block('reportGreaterThan')); blocks.push('-'); blocks.push(block('reportAnd')); blocks.push(block('reportOr')); blocks.push(block('reportNot')); blocks.push('-'); blocks.push(block('reportTrue')); blocks.push(block('reportFalse')); blocks.push('-'); blocks.push(block('reportJoinWords')); blocks.push(block('reportLetter')); blocks.push(block('reportStringSize')); blocks.push('-'); blocks.push(block('reportUnicode')); blocks.push(block('reportUnicodeAsLetter')); blocks.push('-'); blocks.push(block('reportIsA')); blocks.push(block('reportIsIdentical')); // for debugging: /////////////// if (this.world().isDevMode) { blocks.push('-'); txt = new TextMorph('development mode \ndebugging primitives:'); txt.fontSize = 9; txt.setColor(new Color(230, 230, 230)); blocks.push(txt); blocks.push('-'); blocks.push(block('reportTypeOf')); } ///////////////////////////////// } else if (cat === 'variables') { button = new PushButtonMorph( null, function () { new VariableDialogMorph( null, function (pair) { if (pair) { myself.addVariable(pair[0], pair[1]); myself.toggleVariableWatcher(pair[0], pair[1]); myself.blocksCache[cat] = null; myself.paletteCache[cat] = null; myself.parentThatIsA(IDE_Morph).refreshPalette(); } }, myself).prompt('Variable name', null, myself.world()); }, 'Make a variable'); blocks.push(button); if (this.variables.allNames().length > 0) { button = new PushButtonMorph( null, function () { var menu = new MenuMorph( myself.deleteVariable, null, myself); myself.variables.allNames().forEach(function (name) { menu.addItem(name, name); }); menu.popUpAtHand(myself.world()); }, 'Delete a variable'); blocks.push(button); } blocks.push('-'); varNames = this.variables.allNames(); if (varNames.length > 0) { varNames.forEach(function (name) { blocks.push(variableWatcherToggle(name)); blocks.push(variableBlock(name)); }); blocks.push('-'); } blocks.push(block('doSetVar')); blocks.push(block('doChangeVar')); blocks.push(block('doShowVar')); blocks.push(block('doHideVar')); blocks.push(block('doDeclareVariables')); blocks.push('='); blocks.push(block('reportNewList')); blocks.push('-'); blocks.push(block('reportCONS')); blocks.push(block('reportListItem')); blocks.push(block('reportCDR')); blocks.push('-'); blocks.push(block('reportListLength')); blocks.push(block('reportListContainsItem')); blocks.push('-'); blocks.push(block('doAddToList')); blocks.push(block('doDeleteFromList')); blocks.push(block('doInsertInList')); blocks.push(block('doReplaceInList')); blocks.push('='); button = new PushButtonMorph( null, function () { var ide = myself.parentThatIsA(IDE_Morph), stage = myself.parentThatIsA(StageMorph); new BlockDialogMorph( null, function (definition) { if (definition.spec !== '') { if (definition.isGlobal) { stage.globalBlocks.push(definition); } else { myself.customBlocks.push(definition); } ide.flushPaletteCache(); ide.refreshPalette(); new BlockEditorMorph(definition, myself).popUp(); } }, myself).prompt('Make a block', null, myself.world()); }, 'Make a block'); blocks.push(button); } return blocks; }; SyntaxElementMorph.prototype.labelPart = function (spec) { var part; if ((spec[0] === '%') && (spec.length > 1)) { // check for variable multi-arg-slot: if ((spec.length > 5) && (spec.slice(0, 5) === '%mult')) { part = new MultiArgMorph(spec.slice(5)); part.addInput(); return part; } // single-arg and specialized multi-arg slots: switch (spec) { case '%inputs': part = new MultiArgMorph('%s', 'with inputs'); part.isStatic = false; part.canBeEmpty = false; break; case '%scriptVars': part = new MultiArgMorph('%t', null, 1, spec); part.canBeEmpty = false; break; case '%parms': part = new MultiArgMorph('%t', 'Input Names:', 0, spec); part.canBeEmpty = false; break; case '%ringparms': part = new MultiArgMorph('%t', 'input names:', 0, spec); break; case '%cmdRing': part = new RingMorph(); part.color = SpriteMorph.prototype.blockColor.other; part.selector = 'reifyScript'; part.setSpec('%rc %ringparms'); part.isDraggable = true; break; case '%repRing': part = new RingMorph(); part.color = SpriteMorph.prototype.blockColor.other; part.selector = 'reifyReporter'; part.setSpec('%rr %ringparms'); part.isDraggable = true; part.isStatic = true; break; case '%predRing': part = new RingMorph(true); part.color = SpriteMorph.prototype.blockColor.other; part.selector = 'reifyPredicate'; part.setSpec('%rp %ringparms'); part.isDraggable = true; part.isStatic = true; break; case '%words': part = new MultiArgMorph('%s', null, 0); part.addInput(); // allow for default value setting part.addInput(); // allow for default value setting part.isStatic = false; break; case '%exp': part = new MultiArgMorph('%s', null, 0); part.addInput(); part.isStatic = true; part.canBeEmpty = false; break; case '%br': part = new Morph(); part.setExtent(new Point(0, 0)); part.isBlockLabelBreak = true; part.getSpec = function () { return '%br'; }; break; case '%inputName': part = new ReporterBlockMorph(); part.category = 'variables'; part.color = SpriteMorph.prototype.blockColor.variables; part.setSpec(localize('Input name')); break; case '%s': part = new InputSlotMorph(); break; case '%anyUE': part = new InputSlotMorph(); part.isUnevaluated = true; break; case '%txt': part = new InputSlotMorph(); part.minWidth = part.height() * 1.7; // "landscape" part.fixLayout(); break; case '%obj': part = new ArgMorph('object'); break; case '%n': part = new InputSlotMorph(null, true); break; case '%dir': part = new InputSlotMorph( null, true, { '(90) right': 90, '(-90) left': -90, '(0) up': '0', '(180) down': 180 }); part.setContents(90); break; case '%mdir': part = new InputSlotMorph( null, false, { 'x': 'x', 'y': 'y', 'z': 'z', }, true); part.setContents("x"); break; case '%mtype': part = new InputSlotMorph( null, false, { 'acceleration': 'acceleration', 'acceleration (with gravity)': 'acceleration (with gravity)', 'rotation': 'rotation', 'rotation rate': 'rotation rate' }, true); part.setContents("acceleration"); break; case '%inst': part = new InputSlotMorph( null, true, { '(1) Acoustic Grand': 1, '(2) Bright Acoustic': 2, '(3) Electric Grand': 3, '(4) Honky Tonk': 4, '(5) Electric Piano 1': 5, '(6) Electric Piano 2': 6, '(7) Harpsichord': 7 }); part.setContents(1); break; case '%month': part = new InputSlotMorph( null, // text false, // numeric? { 'January': ['January'], 'February': ['February'], 'March': ['March'], 'April': ['April'], 'May': ['May'], 'June': ['June'], 'July': ['July'], 'August': ['August'], 'September': ['September'], 'October': ['October'], 'November': ['November'], 'December': ['December'] }, true // read-only ); break; case '%ida': part = new InputSlotMorph( null, true, { '1': 1, last: ['last'], '~': null, all: ['all'] }); part.setContents(1); break; case '%idx': part = new InputSlotMorph( null, true, { '1': 1, last: ['last'], any: ['any'] }); part.setContents(1); break; case '%spr': part = new InputSlotMorph( null, false, 'objectsMenu', true); break; case '%col': // collision detection part = new InputSlotMorph( null, false, 'collidablesMenu', true); break; case '%dst': // distance measuring part = new InputSlotMorph( null, false, 'distancesMenu', true); break; case '%cln': // clones part = new InputSlotMorph( null, false, 'clonablesMenu', true); break; case '%cst': part = new InputSlotMorph( null, false, 'costumesMenu', true); break; case '%eff': part = new InputSlotMorph( null, false, { /* color : 'color', fisheye : 'fisheye', whirl : 'whirl', pixelate : 'pixelate', mosaic : 'mosaic', brightness : 'brightness', */ ghost: ['ghost'] }, true); part.setContents(['ghost']); break; case '%snd': part = new InputSlotMorph( null, false, 'soundsMenu', true); break; case '%key': part = new InputSlotMorph( null, false, { 'up arrow': ['up arrow'], 'down arrow': ['down arrow'], 'right arrow': ['right arrow'], 'left arrow': ['left arrow'], space: ['space'], a: ['a'], b: ['b'], c: ['c'], d: ['d'], e: ['e'], f: ['f'], g: ['g'], h: ['h'], i: ['i'], j: ['j'], k: ['k'], l: ['l'], m: ['m'], n: ['n'], o: ['o'], p: ['p'], q: ['q'], r: ['r'], s: ['s'], t: ['t'], u: ['u'], v: ['v'], w: ['w'], x: ['x'], y: ['y'], z: ['z'], '0': ['0'], '1': ['1'], '2': ['2'], '3': ['3'], '4': ['4'], '5': ['5'], '6': ['6'], '7': ['7'], '8': ['8'], '9': ['9'] }, true); part.setContents(['space']); break; case '%keyHat': part = this.labelPart('%key'); part.isStatic = true; break; case '%msg': part = new InputSlotMorph( null, false, 'messagesMenu', true); break; case '%msgHat': part = new InputSlotMorph( null, false, 'messagesMenu', true); part.isStatic = true; break; case '%att': part = new InputSlotMorph( null, false, 'attributesMenu', true); part.isStatic = true; break; case '%fun': part = new InputSlotMorph( null, false, { abs: ['abs'], sqrt: ['sqrt'], sin: ['sin'], cos: ['cos'], tan: ['tan'], asin: ['asin'], acos: ['acos'], atan: ['atan'], ln: ['ln'], // log : 'log', 'e^': ['e^'] // '10^' : '10^' }, true); part.setContents(['sqrt']); break; case '%typ': part = new InputSlotMorph( null, false, { number: ['number'], text: ['text'], Boolean: ['Boolean'], list: ['list'], command: ['command'], reporter: ['reporter'], predicate: ['predicate'] // ring : 'ring' // object : 'object' }, true); part.setContents(['number']); break; case '%var': part = new InputSlotMorph( null, false, 'getVarNamesDict', true); part.isStatic = true; break; case '%lst': part = new InputSlotMorph( null, false, { list1: 'list1', list2: 'list2', list3: 'list3' }, true); break; case '%l': part = new ArgMorph('list'); break; case '%b': case '%boolUE': part = new BooleanSlotMorph(null, true); break; case '%cmd': part = new CommandSlotMorph(); break; case '%rc': part = new RingCommandSlotMorph(); part.isStatic = true; break; case '%rr': part = new RingReporterSlotMorph(); part.isStatic = true; break; case '%rp': part = new RingReporterSlotMorph(true); part.isStatic = true; break; case '%c': part = new CSlotMorph(); part.isStatic = true; break; case '%cs': part = new CSlotMorph(); // non-static break; case '%clr': part = new ColorSlotMorph(); part.isStatic = true; break; case '%t': part = new TemplateSlotMorph('a'); break; case '%upvar': part = new TemplateSlotMorph('\u2191'); // up-arrow break; case '%f': part = new FunctionSlotMorph(); break; case '%r': part = new ReporterSlotMorph(); break; case '%p': part = new ReporterSlotMorph(true); break; // symbols: case '%turtle': part = new SymbolMorph('turtle'); part.size = this.fontSize * 1.2; part.color = new Color(255, 255, 255); part.shadowColor = this.color.darker(this.labelContrast); part.shadowOffset = this.embossing; part.drawNew(); break; case '%turtleOutline': part = new SymbolMorph('turtleOutline'); part.size = this.fontSize; part.color = new Color(255, 255, 255); part.isProtectedLabel = true; // doesn't participate in zebraing part.shadowColor = this.color.darker(this.labelContrast); part.shadowOffset = this.embossing; part.drawNew(); break; case '%clockwise': part = new SymbolMorph('turnRight'); part.size = this.fontSize * 1.5; part.color = new Color(255, 255, 255); part.isProtectedLabel = false; // zebra colors part.shadowColor = this.color.darker(this.labelContrast); part.shadowOffset = this.embossing; part.drawNew(); break; case '%counterclockwise': part = new SymbolMorph('turnLeft'); part.size = this.fontSize * 1.5; part.color = new Color(255, 255, 255); part.isProtectedLabel = false; // zebra colors part.shadowColor = this.color.darker(this.labelContrast); part.shadowOffset = this.embossing; part.drawNew(); break; case '%greenflag': part = new SymbolMorph('flag'); part.size = this.fontSize * 1.5; part.color = new Color(0, 200, 0); part.isProtectedLabel = true; // doesn't participate in zebraing part.shadowColor = this.color.darker(this.labelContrast); part.shadowOffset = this.embossing; part.drawNew(); break; case '%stop': part = new SymbolMorph('octagon'); part.size = this.fontSize * 1.5; part.color = new Color(200, 0, 0); part.isProtectedLabel = true; // doesn't participate in zebraing part.shadowColor = this.color.darker(this.labelContrast); part.shadowOffset = this.embossing; part.drawNew(); break; default: // nop(); } } else { part = new StringMorph(spec); part.fontName = this.labelFontName; part.fontStyle = this.labelFontStyle; part.fontSize = this.fontSize; part.color = new Color(255, 255, 255); part.isBold = true; part.shadowColor = this.color.darker(this.labelContrast); part.shadowOffset = this.embossing; part.drawNew(); } return part; };
To test it on an iPad, dump this file into a the snap source, add changes.js to the HTML file, and then run this server:
#!/usr/bin/python from twisted.web.server import Site from twisted.web.static import File from twisted.web.resource import Resource from twisted.internet import reactor import socket IP = socket.gethostbyname(socket.gethostname()) root = Resource() mstatic = File(raw_input("Input the directory where Snap! is located:\n>>> ")) root.putChild("snap",mstatic) factory = Site(root) reactor.listenTCP(8000, factory, interface=IP) print "Connection successful. Open Safari on an iPad and go to:" print IP+":8000/snap/snap.html" reactor.run()
Then follow the instructions on-screen.
(sorry for the laziness/lack of fancy hosting).
Offline
Hardmath123 wrote:
To test it on an iPad, dump this file into a the snap source, add changes.js to the HTML file, and then run this server:
Code:
#!/usr/bin/python from twisted.web.server import Site from twisted.web.static import File from twisted.web.resource import Resource from twisted.internet import reactor import socket IP = socket.gethostbyname(socket.gethostname()) root = Resource() mstatic = File(raw_input("Input the directory where Snap! is located:\n>>> ")) root.putChild("snap",mstatic) factory = Site(root) reactor.listenTCP(8000, factory, interface=IP) print "Connection successful. Open Safari on an iPad and go to:" print IP+":8000/snap/snap.html" reactor.run()
Is that just a static webserver to serve up a directory?
Offline
bharvey wrote:
I'm not asking about Kurt b/c it sounds like we should wait for version 2, right?
Yup!
Offline