kopia lustrzana https://github.com/backface/turtlestitch
include background color when exporting (semi-) transparent script pics
rodzic
de9e210e70
commit
ac8220bdaf
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
### 2020-08-04
|
### 2020-08-04
|
||||||
* new dev version
|
* new dev version
|
||||||
|
* blocks: include background color when exporting (semi-) transparent script pics
|
||||||
|
|
||||||
## 6.1.2:
|
## 6.1.2:
|
||||||
* fixed variable scope for ASK/TELL
|
* fixed variable scope for ASK/TELL
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<script src="src/morphic.js?version=2020-07-23"></script>
|
<script src="src/morphic.js?version=2020-07-23"></script>
|
||||||
<script src="src/symbols.js?version=2020-07-21"></script>
|
<script src="src/symbols.js?version=2020-07-21"></script>
|
||||||
<script src="src/widgets.js?version=2020-07-27"></script>
|
<script src="src/widgets.js?version=2020-07-27"></script>
|
||||||
<script src="src/blocks.js?version=2020-07-29"></script>
|
<script src="src/blocks.js?version=2020-08-04"></script>
|
||||||
<script src="src/threads.js?version=2020-08-01"></script>
|
<script src="src/threads.js?version=2020-08-01"></script>
|
||||||
<script src="src/objects.js?version=2020-07-26"></script>
|
<script src="src/objects.js?version=2020-07-26"></script>
|
||||||
<script src="src/gui.js?version=2020-08-04"></script>
|
<script src="src/gui.js?version=2020-08-04"></script>
|
||||||
|
|
|
@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.blocks = '2020-July-29';
|
modules.blocks = '2020-August-04';
|
||||||
|
|
||||||
var SyntaxElementMorph;
|
var SyntaxElementMorph;
|
||||||
var BlockMorph;
|
var BlockMorph;
|
||||||
|
@ -4043,6 +4043,10 @@ BlockMorph.prototype.thumbnail = function (scale, clipWidth) {
|
||||||
|
|
||||||
BlockMorph.prototype.scriptPic = function () {
|
BlockMorph.prototype.scriptPic = function () {
|
||||||
// answer a canvas image that also includes comments
|
// answer a canvas image that also includes comments
|
||||||
|
if (this.alpha < 1) {
|
||||||
|
return this.scriptPicOnBackground();
|
||||||
|
}
|
||||||
|
|
||||||
var scr = this.fullImage(),
|
var scr = this.fullImage(),
|
||||||
fb = this.stackFullBounds(),
|
fb = this.stackFullBounds(),
|
||||||
pic = newCanvas(fb.extent()),
|
pic = newCanvas(fb.extent()),
|
||||||
|
@ -4058,6 +4062,36 @@ BlockMorph.prototype.scriptPic = function () {
|
||||||
return pic;
|
return pic;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BlockMorph.prototype.scriptPicOnBackground = function () {
|
||||||
|
// answer a canvas image that also includes comments
|
||||||
|
// note: this version is meant for (semi-) transparent blocks
|
||||||
|
// and lets the background shine through
|
||||||
|
var scr = this.fullImage(),
|
||||||
|
solid = this.doWithAlpha(1, () => this.fullImage()),
|
||||||
|
bg = newCanvas(this.fullBounds().extent()),
|
||||||
|
bgCtx = bg.getContext('2d'),
|
||||||
|
fb = this.stackFullBounds(),
|
||||||
|
pic = newCanvas(fb.extent()),
|
||||||
|
ctx = pic.getContext('2d');
|
||||||
|
|
||||||
|
bgCtx.fillColor = this.parent.getRenderColor().toString();
|
||||||
|
bgCtx.fillRect(0, 0, bg.width, bg.height);
|
||||||
|
bgCtx.globalCompositeOperation = 'destination-in';
|
||||||
|
bgCtx.drawImage(solid, 0, 0);
|
||||||
|
bgCtx.globalCompositeOperation = 'source-over';
|
||||||
|
bgCtx.drawImage(scr, 0, 0);
|
||||||
|
|
||||||
|
this.allComments().forEach(comment =>
|
||||||
|
ctx.drawImage(
|
||||||
|
comment.fullImage(),
|
||||||
|
comment.fullBounds().left() - fb.left(),
|
||||||
|
comment.top() - fb.top()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
ctx.drawImage(bg, 0, 0);
|
||||||
|
return pic;
|
||||||
|
};
|
||||||
|
|
||||||
BlockMorph.prototype.clearAlpha = function () {
|
BlockMorph.prototype.clearAlpha = function () {
|
||||||
this.forAllChildren(m => {
|
this.forAllChildren(m => {
|
||||||
if (m instanceof BlockMorph) {
|
if (m instanceof BlockMorph) {
|
||||||
|
|
Ładowanie…
Reference in New Issue