bharvey wrote:
shadow_7283 wrote:
well, once its ready for a paint editor anyway.
Oh, we're ready. We just farmed it out to volunteer labor...
Need some? I'm just getting done with college apps and I'm suddenly finding myself with lots of time...
Offline
nXIII wrote:
Hardmath123 wrote:
Can't find it... hey Jens, do you know a good way to search a set of multiple files? I use Xcode to write my code, and normally I like to have all my code in the same file, all my styles in the same file, and all my HTML in the same file for web apps, for simplicity in editing.
1) Isn't Xcode's JavaScript formatting really messed up? I couldn't find a way to disable it…
EDIT: Oh, or you could just leave it on, I guess…
2) Click the third tab in the navigator area; it's a search utility.
Thanks.
Hardmath123 wrote:
One changeset for mosaic:
Code:
SpriteMorph.prototype.mosaicAmt = 1; SpriteMorph.prototype.setEffect = function (effect, value) { var eff = effect instanceof Array ? effect[0] : null; if (eff === 'ghost') { this.alpha = 1 - Math.min(Math.max(parseFloat(value), 0), 100) / 100; this.changed(); } if (eff === 'mosaic') { this.mosaicAmt = Number(value)>0 ? Number(value) : 1; this.changed(); this.drawNew(); } }; SpriteMorph.prototype.changeEffect = function (effect, value) { var eff = effect instanceof Array ? effect[0] : null; if (eff === 'ghost') { this.setEffect(effect, this.getGhostEffect() + parseFloat(value)); } if (eff === 'mosaic') { this.setEffect(effect, this.mosaicAmt + parseFloat(value)); } }; SpriteMorph.prototype.clearEffects = function () { this.setEffect(['ghost'], 0); this.setEffect(['mosaic'], 1); }; SpriteMorph.prototype.drawNew = function () { var myself = this, currentCenter = this.center(), facing, // actual costume heading based on my rotation style isFlipped, pic, // (flipped copy of) actual costume based on my rotation style stageScale = this.parent instanceof StageMorph ? this.parent.scale : 1, newX, corners = [], origin, shift, corner, costumeExtent, ctx; facing = this.rotationStyle ? this.heading : 90; if (this.rotationStyle === 2) { facing = 90; if ((this.heading > 180 && (this.heading < 360)) || (this.heading < 0 && (this.heading > -180))) { isFlipped = true; } } if (this.costume) { console.log(this.mosaicAmt); pic = isFlipped ? this.costume.flipped() : this.costume; // determine the rotated costume's bounding box corners = pic.bounds().corners().map(function (point) { return point.rotateBy( radians(facing - 90), myself.costume.center() ); }); origin = corners[0]; corner = corners[0]; corners.forEach(function (point) { origin = origin.min(point); corner = corner.max(point); }); costumeExtent = origin.corner(corner) .extent().multiplyBy(this.scale * stageScale); // determine the new relative origin of the rotated shape shift = new Point(0, 0).rotateBy( radians(-(facing - 90)), pic.center() ).subtract(origin); // create a new, adequately dimensioned canvas // and draw the costume on it this.image = newCanvas(costumeExtent); this.silentSetExtent(costumeExtent); ctx = this.image.getContext('2d'); ctx.scale(this.scale * stageScale, this.scale * stageScale); ctx.translate(shift.x, shift.y); ctx.rotate(radians(facing - 90)); for (var xpic = 0; xpic < this.mosaicAmt; xpic++) { for (var ypic = 0; ypic < this.mosaicAmt; ypic++) { ctx.drawImage(pic.contents, xpic*pic.contents.width/this.mosaicAmt, ypic*pic.contents.height/this.mosaicAmt, pic.contents.width/this.mosaicAmt, pic.contents.height/this.mosaicAmt); } } // adjust my position to the rotation this.setCenter(currentCenter); // determine my rotation offset this.rotationOffset = shift .translateBy(pic.rotationCenter) .rotateBy(radians(-(facing - 90)), shift) .scaleBy(this.scale * stageScale); } else { facing = isFlipped ? -90 : facing; newX = Math.min( Math.max( this.normalExtent.x * this.scale * stageScale, 5 ), 1000 ); this.silentSetExtent(new Point(newX, newX)); this.image = newCanvas(this.extent()); this.setCenter(currentCenter); SpriteMorph.uber.drawNew.call(this, facing); this.rotationOffset = this.extent().divideBy(2); } this.version = Date.now(); };I love your code, it's so organized.
Use (+value || 0) for casting a user value a number; it defaults to zero and avoids using the named Number function.
I need it to default to 1. Anything below 1 should become 1, too.
Offline
Hardmath123 wrote:
I need it to default to 1. Anything below 1 should become 1, too.
No, it should default to zero and be rounded up to one (which is essentially the same thing, but not what your current code does).
var value = +userValue || 0; if (value < 1) value = 1;
Last edited by nXIII (2012-12-15 23:55:38)
Offline
Fine. But I'd consider that nitpicking, since my code works perfectly fine anyway.
EDIT: Well, it depends. When you input a string in a number input, does the code get a string or parsed number?
Last edited by Hardmath123 (2012-12-16 07:20:28)
Offline
Hardmath123 wrote:
EDIT: Well, it depends. When you input a string in a number input, does the code get a string or parsed number?
We've been thinking that the silver lining of not having merged into Scratch is that we can rethink some elements of the Scratch design. (Rethink for Snap!, I mean; none of what follows is meant to apply that the design of Scratch is flawed for Scratch.)
In order to avoid scaring away beginners, the Scratch Team chose to minimize the use of error messages, trying instead to make some sense of whatever the user does. Hence, for example, all non-numbers where a number is expected are taken as zero. That's indeed comforting on your first day, but it makes debugging your code harder than an error message would be, because when you eventually get bitten by the result of propagating that incorrect value through a computation, you have no help in finding out where the error actually happened.
So, Jens and I have been thinking that we should more freely give red borders instead of second-guessing the user when an input doesn't make sense. I'd be inclined, if the user puts zero in a slot that demands a strictly positive number, to red-border it. And even more strongly if the user puts a non-number there.
Maybe we should make the halo mauve instead of red, to be friendlier to the user.
P.S. We need to work on better error messages, along the lines of "perhaps you meant..." when appropriate, or "this input has to be greater than zero, because..." Eventually.
Last edited by bharvey (2012-12-16 09:29:27)
Offline
A string in a number slot gets transformed to a number or to zero, same as in Scratch. You can't even type non-numerical characters there, so the string has to come from a reporter.
Sorry about being abrupt, but right now I'm in release mode and not open to any kind of design discussion. Especially not in the forums. The only things which count until SIGCSE are cloud storage, documentation and materials about Snap, and eliminating showstopper bugs.
Offline
What about the actual change set? Will you use it?
Offline
Hardmath123 wrote:
Fine. But I'd consider that nitpicking, since my code works perfectly fine anyway.
Your code accepts 0.1 and does not round it up to 1.
Also, don't abbreviate "amount" to "amt."
Offline
What is this mod?
Offline
Jens wrote:
A string in a number slot gets transformed to a number or to zero, same as in Scratch. You can't even type non-numerical characters there, so the string has to come from a reporter.
Actually in scratch, if you have a string that starts with a number such as "32MB" it will return the number at the start of the string (32 in this case) and ignore the text, when put into a numerical slot.
Offline
bharvey wrote:
but what you want is Emacs, God's text editor. No problem with multiple files. And you can split your window in half and play ASCII Space Invaders in the other half while watching your code compiling.
But viiiiimmm...
Offline
joefarebrother wrote:
Actually in scratch, if you have a string that starts with a number such as "32MB" it will return the number at the start of the string (32 in this case)
... whereas what the user clearly meant, if anything, is 32*10^6*8.
Not in 4.0, maybe not even in 4.1, but eventually we're going to get a good error handling system in place that will give good, useful error messages in a non-threatening way.
Offline
AriArk wrote:
I need help with a block. How can I make a If received block (a circle one that goes in a IF block)
It's not clear exactly what your desired block should do. Is it true if that message has ever been broadcast? Usually you want an asynchronous notification about broadcasts, which is why there's a hat block instead of a predicate.
Offline
Jens wrote:
Thanks for the changeset. I'll play with it tomorrow and let you know sometime next week
Great, thanks. Glad to help!
Offline
Hi Hardmath123,
I've checked out your mosaic changeset and it's really cool! But at the moment I'm just too caught up in working on the cloud backend to integrate it now. The actual code isn't all that much (basically a short detour in the drawNew() method), but there are other areas of the code that need to adjust, too. And usually when I do things like this other things are likely to break. At this stage of development I'd like to freeze most features except for the cloud thing, so, if you don't mind I'll keep the changeset around and integrate it later, once I'm ready for it.
Thanks!
P.S. I like how you handle what you call the mosaicAmt, because it makes sense to me. But Scratch somehow converts it to change only every 10 steps, I guess so it doesn't completely blow up when going up to (and above) 100. Do you think you could adjust that?
Offline
Great! That's alright, and I'll be thrilled if any of my code is in Snap!! I understand what you mean about freezing new features; I'm paranoid about messing up some of my code too.
I can try to adjust the mosaic level thing. I'll need to mess with Scratch to see how it works. Currently I basically make an n by n array of the costume, but I'm not sure that's what Scratch does. I'll look into it.
P.S. How's the backend going? In what language are you coding it? I thought you were using JS+Node.js, but I'd personally suggest Google App Engine + Python, if you are still thinking about that. When are you planning to release some code?
Offline
Hardmath123 wrote:
I understand what you mean about freezing new features; I'm paranoid about messing up some of my code too.
If we used real source control there would be no need for paranoia.
Last edited by nXIII (2012-12-20 12:14:28)
Offline
Jens wrote:
hey whaddaya mean, nxiii?!
When you have something like git, you can branch easily (and revert to previous commits if you don't like the result), so you don't have to worry about messing up your code.
Offline
*cough* SVN *cough*
By the way Jens, not sure if you're looking for a backend host for testing, but I've had extremely great results with AppFog. It uses real cloudracks, and you don't pay if you don't go above 2gb of RAM . Techwiq uses it to great (and free) effect.
Last edited by shadow_7283 (2012-12-20 19:44:08)
Offline
shadow_7283 wrote:
*cough* SVN *cough*
Branching and merging is not as easy in SVN.
EDIT: But please don't turn this into a git vs. SVN flamewar. I only mention that because that's why I brought it up originally.
Last edited by nXIII (2012-12-20 19:53:33)
Offline
Sorry, had no intentions of doing so. I just dislike GIT because its relatively difficult to use effectively on Windows. We had this discussion before, so just kidding around. Anyway,
[/offtopic]
Offline
Snap's Morphic kernel is on github... is that 'real' enough?
Offline