Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/#1551 #1562

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
3 changes: 2 additions & 1 deletion activities/Fototoon.activity/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ define(["sugar-web/activity/activity","sugar-web/datastore","sugar-web/env","tex
element.src = text;
}
element.onload = function () {
toonModel.addImage(element.src);
toonModel.addGlobe(element.src);
// toonModel.addImage(element.src);
};
});
}, { mimetype: 'image/png' }, { mimetype: 'image/jpeg' }, { activity: 'org.olpcfrance.PaintActivity'});
Expand Down
40 changes: 27 additions & 13 deletions activities/Fototoon.activity/js/toon.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
});
};

this.addGlobe = function (globeType) {
this.addGlobe = function (globeType, imageSrc) {
var width = 100;
var height = 50;
globeData = {'globe_type': globeType, 'x': 100, 'y': 100,
Expand All @@ -640,9 +640,9 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
globeData['mode'] = MODE_WHISPER;
};

var globe = new Globe(this, globeData);
var globe = new Globe(this, globeData, imageSrc);
this.globes.push(globe);
this.stage.update();
this.stage.update(imageSrc);
};

this.getJson = function() {
Expand Down Expand Up @@ -936,7 +936,7 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
};


function Globe(box, globeData) {
function Globe(box, globeData, imageSrc) {
this._box = box;
this._stage = box.stage;
this._shapeControls = null;
Expand Down Expand Up @@ -1001,7 +1001,7 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
this._shape = null;
};

this.createShape = function() {
this.createShape = function(imageSrc) {
if (this._shape != null) {
this._stage.removeChild(this._shape);
if (this._type == TYPE_CLOUD) {
Expand All @@ -1019,10 +1019,10 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
this.createShapeCloud(scaled_x, scaled_y, scale_x, scale_y);
} else if (this._type == TYPE_EXCLAMATION) {
this.createShapeExclamation(scaled_x, scaled_y, scale_x, scale_y);
} else if (this._type == TYPE_RECTANGLE) {
this.createShapeRectangle();
} else {
} else if (this._type == TYPE_GLOBE) {
this.createShapeGlobe(scaled_x, scaled_y, scale_x, scale_y);
} else {
this.createShapeRectangle(imageSrc);
};

this._shape.on('click', function(event) {
Expand Down Expand Up @@ -1115,19 +1115,33 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
this._shape.setTransform(0, 0, scale_x, scale_y);
};

this.createShapeRectangle = function() {
this.createShapeRectangle = function(imageSrc) {
var x = this._x;
var y = this._y;
var w = this._width;
var h = this._height;


this._shape = new createjs.Shape();
this._shape.name = 'rect';
this._stage.addChild(this._shape);
this._shape.graphics.setStrokeStyle(LINE_WIDTH, "round",
null, null, true);
this._shape.graphics.beginStroke(BLACK);
this._shape.graphics.beginFill(WHITE);

var image = document.createElement("img");
image.crossOrigin = "Anonymous"; // Should work fine
image.src = imageSrc;
var bitmap = new createjs.Bitmap(image);

// var bitmap = new createjs.Bitmap(image);
bitmap.x = x - w;
bitmap.y = y - h;
bitmap.scaleX = image.width;
bitmap.scaleY = image.height;

this._shape.graphics.beginBitmapFill(bitmap.image, "no-repeat");
if(!imageSrc) this._shape.graphics.beginFill(WHITE);

this._shape.graphics.rect(x - w , y - h, w * 2, h * 2);
this._shape.graphics.endStroke();
Expand Down Expand Up @@ -1504,8 +1518,8 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
};
};

this.update = function() {
this.createShape();
this.update = function(imageSrc) {
this.createShape(imageSrc);
this._textViewer.update();
this.createControls();
this._stage.update();
Expand Down Expand Up @@ -1577,7 +1591,7 @@ define(["easel","sugar-web/datastore","sugar-web/env","webL10n","humane"], funct
};

this.init();
this.update();
this.update(imageSrc);
};


Expand Down
3 changes: 1 addition & 2 deletions v2/js/screens/loginscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,4 @@ const LoginScreen = {
}
}
},
};

};
4 changes: 2 additions & 2 deletions v2/js/screens/mainscreen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @ MainScreen
@desc This is the main screen component */
const MainScreen = {
const MainScreen = {
name: 'MainScreen',
template: ` <div class="toolbar ">
<div class="tool_leftitems">
Expand Down Expand Up @@ -168,4 +168,4 @@ const MainScreen = {
},
};

if (typeof module !== 'undefined') module.exports = { MainScreen }
if (typeof module !== 'undefined') module.exports = { MainScreen }