Compare commits
1 Commits
greenkeepe
...
greenkeepe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32cf6c7d5f |
@@ -38,7 +38,7 @@
|
|||||||
"jsdoc": "^3.5.5",
|
"jsdoc": "^3.5.5",
|
||||||
"json": "^9.0.4",
|
"json": "^9.0.4",
|
||||||
"scratch-vm": "0.2.0-prerelease.20190213162739",
|
"scratch-vm": "0.2.0-prerelease.20190213162739",
|
||||||
"tap": "^14.9.2",
|
"tap": "^14.9.1",
|
||||||
"travis-after-all": "^1.4.4",
|
"travis-after-all": "^1.4.4",
|
||||||
"uglifyjs-webpack-plugin": "^1.2.5",
|
"uglifyjs-webpack-plugin": "^1.2.5",
|
||||||
"webpack": "^4.8.0",
|
"webpack": "^4.8.0",
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
"minilog": "3.1.0",
|
"minilog": "3.1.0",
|
||||||
"raw-loader": "^0.5.1",
|
"raw-loader": "^0.5.1",
|
||||||
"scratch-storage": "^1.0.0",
|
"scratch-storage": "^1.0.0",
|
||||||
"scratch-svg-renderer": "0.2.0-prerelease.20191104164753",
|
"scratch-svg-renderer": "0.2.0-prerelease.20190822202608",
|
||||||
"twgl.js": "4.4.0"
|
"twgl.js": "4.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -461,9 +461,7 @@ class Drawable {
|
|||||||
|
|
||||||
const localPosition = getLocalPosition(this, vec);
|
const localPosition = getLocalPosition(this, vec);
|
||||||
|
|
||||||
// We're not passing in a scale to useNearest, but that's okay because "touching" queries
|
if (this.useNearest) {
|
||||||
// happen at the "native" size anyway.
|
|
||||||
if (this.useNearest()) {
|
|
||||||
return this.skin.isTouchingNearest(localPosition);
|
return this.skin.isTouchingNearest(localPosition);
|
||||||
}
|
}
|
||||||
return this.skin.isTouchingLinear(localPosition);
|
return this.skin.isTouchingLinear(localPosition);
|
||||||
@@ -471,10 +469,8 @@ class Drawable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the drawable use NEAREST NEIGHBOR or LINEAR INTERPOLATION mode
|
* Should the drawable use NEAREST NEIGHBOR or LINEAR INTERPOLATION mode
|
||||||
* @param {?Array<Number>} scale Optionally, the screen-space scale of the drawable.
|
|
||||||
* @return {boolean} True if the drawable should use nearest-neighbor interpolation.
|
|
||||||
*/
|
*/
|
||||||
useNearest (scale = this.scale) {
|
get useNearest () {
|
||||||
// Raster skins (bitmaps) should always prefer nearest neighbor
|
// Raster skins (bitmaps) should always prefer nearest neighbor
|
||||||
if (this.skin.isRaster) {
|
if (this.skin.isRaster) {
|
||||||
return true;
|
return true;
|
||||||
@@ -496,8 +492,8 @@ class Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the scale of the skin is very close to 100 (0.99999 variance is okay I guess)
|
// If the scale of the skin is very close to 100 (0.99999 variance is okay I guess)
|
||||||
if (Math.abs(scale[0]) > 99 && Math.abs(scale[0]) < 101 &&
|
if (Math.abs(this.scale[0]) > 99 && Math.abs(this.scale[0]) < 101 &&
|
||||||
Math.abs(scale[1]) > 99 && Math.abs(scale[1]) < 101) {
|
Math.abs(this.scale[1]) > 99 && Math.abs(this.scale[1]) < 101) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -689,7 +685,7 @@ class Drawable {
|
|||||||
}
|
}
|
||||||
const textColor =
|
const textColor =
|
||||||
// commenting out to only use nearest for now
|
// commenting out to only use nearest for now
|
||||||
// drawable.useNearest() ?
|
// drawable.useNearest ?
|
||||||
drawable.skin._silhouette.colorAtNearest(localPosition, dst);
|
drawable.skin._silhouette.colorAtNearest(localPosition, dst);
|
||||||
// : drawable.skin._silhouette.colorAtLinear(localPosition, dst);
|
// : drawable.skin._silhouette.colorAtLinear(localPosition, dst);
|
||||||
return EffectTransform.transformColor(drawable, textColor, textColor);
|
return EffectTransform.transformColor(drawable, textColor, textColor);
|
||||||
|
|||||||
@@ -394,6 +394,8 @@ class RenderWebGL extends EventEmitter {
|
|||||||
for (const drawable of this._allDrawables) {
|
for (const drawable of this._allDrawables) {
|
||||||
if (drawable && drawable.skin === oldSkin) {
|
if (drawable && drawable.skin === oldSkin) {
|
||||||
drawable.skin = newSkin;
|
drawable.skin = newSkin;
|
||||||
|
drawable.setConvexHullDirty();
|
||||||
|
drawable.setTransformDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oldSkin.dispose();
|
oldSkin.dispose();
|
||||||
@@ -1733,7 +1735,7 @@ class RenderWebGL extends EventEmitter {
|
|||||||
|
|
||||||
if (uniforms.u_skin) {
|
if (uniforms.u_skin) {
|
||||||
twgl.setTextureParameters(
|
twgl.setTextureParameters(
|
||||||
gl, uniforms.u_skin, {minMag: drawable.useNearest(drawableScale) ? gl.NEAREST : gl.LINEAR}
|
gl, uniforms.u_skin, {minMag: drawable.useNearest ? gl.NEAREST : gl.LINEAR}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class TextBubbleSkin extends Skin {
|
|||||||
/** @type {Array<string>} */
|
/** @type {Array<string>} */
|
||||||
this._lines = [];
|
this._lines = [];
|
||||||
|
|
||||||
/** @type {object} */
|
this._textSize = {width: 0, height: 0};
|
||||||
this._textAreaSize = {width: 0, height: 0};
|
this._textAreaSize = {width: 0, height: 0};
|
||||||
|
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
@@ -127,14 +127,17 @@ class TextBubbleSkin extends Skin {
|
|||||||
this._lines = this.textWrapper.wrapText(BubbleStyle.MAX_LINE_WIDTH, this._text);
|
this._lines = this.textWrapper.wrapText(BubbleStyle.MAX_LINE_WIDTH, this._text);
|
||||||
|
|
||||||
// Measure width of longest line to avoid extra-wide bubbles
|
// Measure width of longest line to avoid extra-wide bubbles
|
||||||
let longestLineWidth = 0;
|
let longestLine = 0;
|
||||||
for (const line of this._lines) {
|
for (const line of this._lines) {
|
||||||
longestLineWidth = Math.max(longestLineWidth, this.measurementProvider.measureText(line));
|
longestLine = Math.max(longestLine, this.measurementProvider.measureText(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._textSize.width = longestLine;
|
||||||
|
this._textSize.height = BubbleStyle.LINE_HEIGHT * this._lines.length;
|
||||||
|
|
||||||
// Calculate the canvas-space sizes of the padded text area and full text bubble
|
// Calculate the canvas-space sizes of the padded text area and full text bubble
|
||||||
const paddedWidth = Math.max(longestLineWidth, BubbleStyle.MIN_WIDTH) + (BubbleStyle.PADDING * 2);
|
const paddedWidth = Math.max(this._textSize.width, BubbleStyle.MIN_WIDTH) + (BubbleStyle.PADDING * 2);
|
||||||
const paddedHeight = (BubbleStyle.LINE_HEIGHT * this._lines.length) + (BubbleStyle.PADDING * 2);
|
const paddedHeight = this._textSize.height + (BubbleStyle.PADDING * 2);
|
||||||
|
|
||||||
this._textAreaSize.width = paddedWidth;
|
this._textAreaSize.width = paddedWidth;
|
||||||
this._textAreaSize.height = paddedHeight;
|
this._textAreaSize.height = paddedHeight;
|
||||||
@@ -180,7 +183,6 @@ class TextBubbleSkin extends Skin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw the bubble's rounded borders
|
// Draw the bubble's rounded borders
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(BubbleStyle.CORNER_RADIUS, paddedHeight);
|
ctx.moveTo(BubbleStyle.CORNER_RADIUS, paddedHeight);
|
||||||
ctx.arcTo(0, paddedHeight, 0, paddedHeight - BubbleStyle.CORNER_RADIUS, BubbleStyle.CORNER_RADIUS);
|
ctx.arcTo(0, paddedHeight, 0, paddedHeight - BubbleStyle.CORNER_RADIUS, BubbleStyle.CORNER_RADIUS);
|
||||||
ctx.arcTo(0, 0, paddedWidth, 0, BubbleStyle.CORNER_RADIUS);
|
ctx.arcTo(0, 0, paddedWidth, 0, BubbleStyle.CORNER_RADIUS);
|
||||||
@@ -265,13 +267,14 @@ class TextBubbleSkin extends Skin {
|
|||||||
|
|
||||||
if (this._texture === null) {
|
if (this._texture === null) {
|
||||||
const textureOptions = {
|
const textureOptions = {
|
||||||
auto: false,
|
auto: true,
|
||||||
wrap: gl.CLAMP_TO_EDGE
|
wrap: gl.CLAMP_TO_EDGE,
|
||||||
|
src: textureData
|
||||||
};
|
};
|
||||||
|
|
||||||
this._texture = twgl.createTexture(gl, textureOptions);
|
this._texture = twgl.createTexture(gl, textureOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.bindTexture(gl.TEXTURE_2D, this._texture);
|
gl.bindTexture(gl.TEXTURE_2D, this._texture);
|
||||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, textureData);
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, textureData);
|
||||||
this._silhouette.update(textureData);
|
this._silhouette.update(textureData);
|
||||||
|
|||||||
10
tap-snapshots/test-integration-scratch-tests.js-TAP.test.js
Normal file
10
tap-snapshots/test-integration-scratch-tests.js-TAP.test.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* IMPORTANT
|
||||||
|
* This snapshot file is auto-generated, but designed for humans.
|
||||||
|
* It should be checked into source control and tracked carefully.
|
||||||
|
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||||
|
* Make sure to inspect the output below. Do not ignore changes!
|
||||||
|
*/
|
||||||
|
'use strict'
|
||||||
|
exports[`test/integration/scratch-tests.js TAP bubble snapshot > bubble-text-snapshot 1`] = `
|
||||||
|
<text xmlns="http://www.w3.org/2000/svg" alignment-baseline="text-before-edge" font-size="14" fill="#575E75" font-family="Helvetica"><tspan x="0" dy="1.2em"><e*&%$&^$></!abc'></tspan></text>
|
||||||
|
`
|
||||||
Reference in New Issue
Block a user