This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#6376 2012-12-12 03:40:52

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

xly wrote:

I don't know if that is worth of interest or not ? I've installed on a Windows XP PC a server , xampp, which allows to use Snap! locally. It works pretty well, better with Firefox than Chrome. Snap! projects can be loaded and saved as usual.

Yes, that's awesome!  Does that mean you keep a local copy of the Snap! source code, or does it automatically download the latest version when you have net access?

(It's especially awesome because it's platform-independent!)

Yes it works locally ( It is checked by deconnecting the Ethernet cable).
Snap! applications are saved "somewhere" (I can find out where ??)
Snap! is more instable with Chrome than with Firefox (opposedly to the "remote" Snap!)
To load existing applications I use Import or "drag-and-drop" .
Import feature does not work well with larger applis.
I have been inspired by the "instant.js" solution  a Javascript development tool to create javascriptHtml5 games.
Installation of xampp takes time, but is straightforward.
Very precious, installation is portable, ie all files are placed in one directory (no register parameters, hidden files split away in all the directory treeof the OS - that is Windows).
Snap! files are installed in the directory "htdocs" ie one launcher Snap!.htm file + one directory containing the Snap! *.js files (morphic, block,objects ..etc)
For Snap! only the Apache service is used, but it provides other services like Mysql and Ftp which for Snap! could be either removed from the package to have a lighter package, or exploited to achieve transfer/saving/sharing features.

Last edited by xly (2012-12-12 03:50:51)

Offline

 

#6377 2012-12-14 11:02:47

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

The only foolproof way I can think of for the HTTP block is to use a proxy, unless there's a JS procedure that reads a webpage without any security issues...


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6378 2012-12-14 11:48:15

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Can we have some kind of dictionary/object data type in Snap!? And a JSON parser and encoder built-in? I understand it's not too tough to make your own using lambda (I might do that as a project right now; I'm bored), but this way would be uniform across all projects. You could use the ([] of []) block to get properties of an object, and have a system similar to lists for constructors:

(new dictionary with key: [color] value: [green] >) => {"color":"green"}
(set [color] of (car) to [red]) => {"color":"red"}
(delete attrib [] of ())
...


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6379 2012-12-14 12:05:14

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Code:

<project name="Dictionary" app="Snap! 4.0, http://snap.berkeley.edu" version="1"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAADIUlEQVR4Ae3WwUlkARRE0d/DxKFoRrozIyMxARfmonm4dVQQBodmoCgokPM32q3vPTxcaE9v78/hITAS+DW66yyBTwEBCmEqIMApv+MC1MBUQIBTfscFqIGpgACn/I4LUANTAQFO+R0XoAamAgKc8jsuQA1MBQQ45XdcgBqYCghwyu+4ADUwFRDglN9xAWpgKiDAKb/jAtTAVECAU37HBaiBqYAAp/yOC1ADUwEBTvkdF6AGpgICnPI7LkANTAUEOOV3XIAamAoIcMrvuAA1MBUQ4JTfcQFqYCogwCm/4wLUwFRAgFN+xwWogamAAKf8jgtQA1MBAU75HRegBqYCApzyOy5ADUwFBDjld1yAGpgKCHDK77gANTAVEOCU33EBamAqIMApv+MC1MBUQIBTfscFqIGpgACn/I4LUANTAQGe4b+4uDgeHh7O/NTbLYHT2/vTWvbT9tze3h5fPM/Pz8fj4+NxfX390/7M6d8jwP/w39zc/PMbp9PpeH19PZ6eno6P7z25gI/g0E54Idy3sd/fXnv5l8DHR/DX8/Ly8vkRfHV19fWWrwUBAZ5BvLy8PO7v74+7u7szv+HthoD/ARuKdsQC/geM6Qw2BATYULQjFhBgTGewISDAhqIdsYAAYzqDDQEBNhTtiAUEGNMZbAgIsKFoRywgwJjOYENAgA1FO2IBAcZ0BhsCAmwo2hELCDCmM9gQEGBD0Y5YQIAxncGGgAAbinbEAgKM6Qw2BATYULQjFhBgTGewISDAhqIdsYAAYzqDDQEBNhTtiAUEGNMZbAgIsKFoRywgwJjOYENAgA1FO2IBAcZ0BhsCAmwo2hELCDCmM9gQEGBD0Y5YQIAxncGGgAAbinbEAgKM6Qw2BATYULQjFhBgTGewISDAhqIdsYAAYzqDDQEBNhTtiAUEGNMZbAgIsKFoRywgwJjOYENAgA1FO2IBAcZ0BhsCAmwo2hELCDCmM9gQEGBD0Y5YQIAxncGGgAAbinbEAgKM6Qw2BATYULQjFhBgTGewISDAhqIdsYAAYzqDDQEBNhTtiAUEGNMZbAgIsKFoRyzwB9UYKzMr6RmVAAAAAElFTkSuQmCC</thumbnail><stage name="Stage" costume="0" tempo="60" threadsafe="false" id="1"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAOiklEQVR4Ae3VwQkAIAwEQbX/niM24X4mDRwMgd0zsxwBAgQIECDwV+D8nbNGgAABAgQIPAEB9gcECBAgQCAQEOAA3SQBAgQIEBBgP0CAAAECBAIBAQ7QTRIgQIAAAQH2AwQIECBAIBAQ4ADdJAECBAgQEGA/QIAAAQIEAgEBDtBNEiBAgAABAfYDBAgQIEAgEBDgAN0kAQIECBAQYD9AgAABAgQCAQEO0E0SIECAAAEB9gMECBAgQCAQEOAA3SQBAgQIEBBgP0CAAAECBAIBAQ7QTRIgQIAAAQH2AwQIECBAIBAQ4ADdJAECBAgQEGA/QIAAAQIEAgEBDtBNEiBAgAABAfYDBAgQIEAgEBDgAN0kAQIECBAQYD9AgAABAgQCAQEO0E0SIECAAAEB9gMECBAgQCAQEOAA3SQBAgQIEBBgP0CAAAECBAIBAQ7QTRIgQIAAAQH2AwQIECBAIBAQ4ADdJAECBAgQEGA/QIAAAQIEAgEBDtBNEiBAgAABAfYDBAgQIEAgEBDgAN0kAQIECBAQYD9AgAABAgQCAQEO0E0SIECAAAEB9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0E0SIECAAAEB9gMECBAgQCAQEOAA3SQBAgQIEBBgP0CAAAECBAIBAQ7QTRIgQIAAAQH2AwQIECBAIBAQ4ADdJAECBAgQEGA/QIAAAQIEAgEBDtBNEiBAgAABAfYDBAgQIEAgEBDgAN0kAQIECBC4qcoFzaZQGfQAAAAASUVORK5CYII=</pentrails><costumes><list id="2"></list></costumes><sounds><list id="3"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites><sprite name="Sprite" idx="1" x="0" y="0" heading="90" scale="1" rotation="1" draggable="true" costume="0" color="80,80,80" id="8"><costumes><list id="9"></list></costumes><sounds><list id="10"></list></sounds><variables></variables><blocks></blocks><scripts><script x="80" y="192"><custom-block s="get keys %s"><custom-block s="add pair key: %txt value: %s to %s"><l>color</l><l>red</l><custom-block s="Object"></custom-block></custom-block></custom-block></script></scripts></sprite></sprites></stage><blocks><block-definition s="Object" type="reporter" category="other"><inputs></inputs><script><block s="doReport"><block s="reifyScript"><script><block s="doIfElse"><block var="keys?"/><script><block s="doReport"><block s="reportNewList"><list></list></block></block></script><script><block s="doReport"><block s="reportNewList"><list></list></block></block></script></block></script><list><l>keys?</l></list></block></block></script></block-definition><block-definition s="get keys %&apos;obj&apos;" type="reporter" category="other"><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="evaluate"><custom-block s="Object"></custom-block><list><block s="reportTrue"></block></list></block></block></script></block-definition><block-definition s="get values %&apos;obj&apos;" type="reporter" category="other"><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="evaluate"><custom-block s="Object"></custom-block><list><block s="reportFalse"></block></list></block></block></script></block-definition><block-definition s="add pair key: %&apos;k&apos; value: %&apos;v&apos; to %&apos;obj&apos;" type="reporter" category="other"><inputs><input type="%txt"></input><input type="%s"></input><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>keys</l><l>values</l></list></block><block s="doSetVar"><l>keys</l><custom-block s="get keys %s"><block var="obj"/></custom-block></block><block s="doAddToList"><block var="k"/><block var="keys"/></block><block s="doSetVar"><l>values</l><custom-block s="get values %s"><block var="obj"/></custom-block></block><block s="doAddToList"><block var="v"/><block var="values"/></block><block s="doReport"><block s="reifyScript"><script><block s="doIfElse"><block var="keys?"/><script><block s="doReport"><block var="keys"/></block></script><script><block s="doReport"><block var="values"/></block></script></block></script><list><l>keys?</l></list></block></block></script></block-definition></blocks><variables></variables></project>

What's wrong here?  hmm


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6380 2012-12-14 13:08:18

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

What's wrong here?  hmm

Should "add pair key" be returning a block thing?

screenshot


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6381 2012-12-14 13:24:07

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Isn't it already?

EDIT: Nice job with letting us drop XML files in on Snap, Jens! I wish I had that for other apps.

Last edited by Hardmath123 (2012-12-14 13:24:41)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6382 2012-12-14 15:48:01

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

Isn't it already?

It is. Clearly I don't understand how it's supposed to work  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6383 2012-12-14 21:22:04

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Well, Object returns a lambda with an input, and the input dictates whether it returns the list of keys or list of values.

Add pair basically gets the keys and values, tacks on your pair, and then spits out a new lambda with the new lists.

Except, it doesn't.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6384 2012-12-14 21:57:03

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I understand it's not too tough to make your own using lambda

Why not just a list of length-2 lists?

ADD (LIST (color) (red)) TO (mydict)

(I might do that as a project right now; I'm bored)

Implement one of the missing graphic sprite effects for Snap!!  smile

PS I think your project doesn't work b/c of a Snap! bug, but I'm not sure yet.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6385 2012-12-14 22:36:55

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Implement one of the missing graphic sprite effects for Snap!!   smile

Alrighty! I just finished two USAMTS problems, so I'm going to try to do something actually fun for the rest of the day.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6386 2012-12-14 23:00:44

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Where do you define the list of options in the %eff dropdown?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6387 2012-12-15 05:38:46

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

check out one way to make dictionaries in Snap!.


Jens Mönig

Offline

 

#6388 2012-12-15 05:40:19

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

And here's another way


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6389 2012-12-15 06:00:47

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123, check your GET KEYS definition, I'm sure you'll discover the glitch  smile


Jens Mönig

Offline

 

#6390 2012-12-15 06:08:48

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

*facepalm* it's moments like these that I realize how insanely stupid I am past 11:30PM.

So it works.  big_smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6391 2012-12-15 06:10:31

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

Where do you define the list of options in the %eff dropdown?

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.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6392 2012-12-15 06:12:59

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

yup, it works! And it's a great idea, inspiring both me and Joefarebrother. Thanks!


Jens Mönig

Offline

 

#6393 2012-12-15 06:13:58

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Sorry about the triple-post, but I wanted to point out that you already have  some sort of function to add color filters. Are you using that for the graphic effect? If so, that just leaves the mosaic, whirl and fisheye effects. I'll try to implement mosaic.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6394 2012-12-15 06:18:07

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

line 777 in blocks.js. Sorry for being cryptic, I'm on a train with lousy bandwith, in fact I'm about to sign off. Good luck!

Last edited by Jens (2012-12-15 06:20:39)


Jens Mönig

Offline

 

#6395 2012-12-15 06:30:39

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Thanks! And no problem, you're crystal clear compared to say my history teacher, who sounds more like the train you're on.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6396 2012-12-15 07:24:09

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

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();
};

smile  I love your code, it's so organized.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6397 2012-12-15 10:31:36

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

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.

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();
};

smile  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.

Last edited by nXIII (2012-12-15 10:32:24)


nXIII

Offline

 

#6398 2012-12-15 11:16:36

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Just got accepted into the Scratch 2.0 Alpha and I've got to say- the vector-based paint editing is pretty fantastic. It'd be a good model for Snap- well, once its ready for a paint editor anyway.

Offline

 

#6399 2012-12-15 12:41:20

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

hey Jens, do you know a good way to search a set of multiple files?

IANJ, 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.  smile

(If you're using a Mac, get Aquamacs.)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#6400 2012-12-15 12:43:24

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

well, once its ready for a paint editor anyway.

Oh, we're ready.  We just farmed it out to volunteer labor...  hmm


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

Board footer