pxt-common-packages 9.4.3 → 9.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/common-sim.d.ts +10 -2
- package/built/common-sim.js +86 -1
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color/colors.ts +11 -0
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +9043 -7832
- package/libs/controller---none/built/debug/binary.js +9022 -7811
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/_locales/game-strings.json +21 -0
- package/libs/game/built/debug/binary.js +8935 -7724
- package/libs/game/docs/reference/scene/set-tile-at.md +2 -2
- package/libs/game/docs/reference/scene/tile-at-location-equals.md +1 -1
- package/libs/game/docs/reference/sprites/sprite/ax.md +34 -3
- package/libs/game/docs/reference/sprites/sprite/ay.md +34 -3
- package/libs/game/docs/reference/sprites/sprite/fx.md +123 -0
- package/libs/game/docs/reference/sprites/sprite/fy.md +123 -0
- package/libs/game/docs/reference/sprites.md +2 -0
- package/libs/game/hitbox.ts +40 -22
- package/libs/game/renderText.ts +74 -11
- package/libs/game/sprite.ts +244 -16
- package/libs/game/spritesay.ts +206 -53
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +10832 -9617
- package/libs/palette/built/debug/binary.js +8934 -7723
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +9 -9
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/screen/image.cpp +14 -4
- package/libs/screen/image.ts +5 -4
- package/libs/screen/sim/image.ts +15 -3
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/README.md +3 -0
- package/libs/sprite-scaling/_locales/sprite-scaling-jsdoc-strings.json +1 -0
- package/libs/sprite-scaling/_locales/sprite-scaling-strings.json +9 -0
- package/libs/sprite-scaling/built/debug/binary.js +40047 -0
- package/libs/sprite-scaling/pxt.json +16 -0
- package/libs/sprite-scaling/scaling.ts +111 -0
- package/libs/sprite-scaling/targetoverrides.ts +1 -0
- package/libs/sprite-scaling/test.ts +0 -0
- package/libs/storyboard/built/debug/binary.js +8934 -7723
- package/libs/text-to-speech/pxt.json +14 -0
- package/libs/text-to-speech/shims.d.ts +47 -0
- package/libs/text-to-speech/sim/tts.ts +72 -0
- package/libs/text-to-speech/tts.ts +70 -0
- package/package.json +1 -1
package/built/common-sim.d.ts
CHANGED
|
@@ -1007,8 +1007,8 @@ declare namespace pxsim.ImageMethods {
|
|
|
1007
1007
|
function _fillCircle(img: RefImage, cxy: number, r: number, c: number): void;
|
|
1008
1008
|
function _blitRow(img: RefImage, xy: number, from: RefImage, xh: number): void;
|
|
1009
1009
|
function blitRow(img: RefImage, x: number, y: number, from: RefImage, fromX: number, fromH: number): void;
|
|
1010
|
-
function _blit(img: RefImage, src: RefImage, args: RefCollection):
|
|
1011
|
-
function blit(dst: RefImage, src: RefImage, args: RefCollection):
|
|
1010
|
+
function _blit(img: RefImage, src: RefImage, args: RefCollection): boolean;
|
|
1011
|
+
function blit(dst: RefImage, src: RefImage, args: RefCollection): boolean;
|
|
1012
1012
|
}
|
|
1013
1013
|
declare namespace pxsim.image {
|
|
1014
1014
|
function byteHeight(h: number, bpp: number): number;
|
|
@@ -1119,6 +1119,14 @@ declare namespace pxsim.input {
|
|
|
1119
1119
|
function onSwitchMoved(direction: number, body: RefAction): void;
|
|
1120
1120
|
function switchRight(): boolean;
|
|
1121
1121
|
}
|
|
1122
|
+
declare namespace pxsim.tts {
|
|
1123
|
+
function _getLanguageCode(): string;
|
|
1124
|
+
function _speakAsync(text: string, pitch?: number, rate?: number, volume?: number, language?: string, onStart?: RefAction, onBoundary?: RefAction): Promise<void>;
|
|
1125
|
+
function _pause(): void;
|
|
1126
|
+
function _isPaused(): boolean;
|
|
1127
|
+
function _resume(): void;
|
|
1128
|
+
function _cancel(): void;
|
|
1129
|
+
}
|
|
1122
1130
|
declare namespace pxsim {
|
|
1123
1131
|
interface TemperatureBoard extends CommonBoard {
|
|
1124
1132
|
thermometerState: AnalogSensorState;
|
package/built/common-sim.js
CHANGED
|
@@ -3905,7 +3905,7 @@ var pxsim;
|
|
|
3905
3905
|
}
|
|
3906
3906
|
ImageMethods.blitRow = blitRow;
|
|
3907
3907
|
function _blit(img, src, args) {
|
|
3908
|
-
blit(img, src, args);
|
|
3908
|
+
return blit(img, src, args);
|
|
3909
3909
|
}
|
|
3910
3910
|
ImageMethods._blit = _blit;
|
|
3911
3911
|
function blit(dst, src, args) {
|
|
@@ -3918,6 +3918,7 @@ var pxsim;
|
|
|
3918
3918
|
const wSrc = args.getAt(6);
|
|
3919
3919
|
const hSrc = args.getAt(7);
|
|
3920
3920
|
const transparent = args.getAt(8);
|
|
3921
|
+
const check = args.getAt(9);
|
|
3921
3922
|
const xSrcStep = ((wSrc << 16) / wDst) | 0;
|
|
3922
3923
|
const ySrcStep = ((hSrc << 16) / hDst) | 0;
|
|
3923
3924
|
const xDstClip = Math.abs(Math.min(0, xDst));
|
|
@@ -3930,16 +3931,26 @@ var pxsim;
|
|
|
3930
3931
|
const ySrcStart = Math.max(0, (ySrc << 16) + yDstClip * ySrcStep);
|
|
3931
3932
|
const xSrcEnd = Math.min(src._width, xSrc + wSrc) << 16;
|
|
3932
3933
|
const ySrcEnd = Math.min(src._height, ySrc + hSrc) << 16;
|
|
3934
|
+
if (!check)
|
|
3935
|
+
dst.makeWritable();
|
|
3933
3936
|
for (let yDstCur = yDstStart, ySrcCur = ySrcStart; yDstCur < yDstEnd && ySrcCur < ySrcEnd; ++yDstCur, ySrcCur += ySrcStep) {
|
|
3934
3937
|
const ySrcCurI = ySrcCur >> 16;
|
|
3935
3938
|
for (let xDstCur = xDstStart, xSrcCur = xSrcStart; xDstCur < xDstEnd && xSrcCur < xSrcEnd; ++xDstCur, xSrcCur += xSrcStep) {
|
|
3936
3939
|
const xSrcCurI = xSrcCur >> 16;
|
|
3937
3940
|
const cSrc = getPixel(src, xSrcCurI, ySrcCurI);
|
|
3941
|
+
if (check && cSrc) {
|
|
3942
|
+
const cDst = getPixel(dst, xDstCur, yDstCur);
|
|
3943
|
+
if (cDst) {
|
|
3944
|
+
return true;
|
|
3945
|
+
}
|
|
3946
|
+
continue;
|
|
3947
|
+
}
|
|
3938
3948
|
if (!transparent || cSrc) {
|
|
3939
3949
|
setPixel(dst, xDstCur, yDstCur, cSrc);
|
|
3940
3950
|
}
|
|
3941
3951
|
}
|
|
3942
3952
|
}
|
|
3953
|
+
return false;
|
|
3943
3954
|
}
|
|
3944
3955
|
ImageMethods.blit = blit;
|
|
3945
3956
|
})(ImageMethods = pxsim.ImageMethods || (pxsim.ImageMethods = {}));
|
|
@@ -4568,6 +4579,80 @@ var pxsim;
|
|
|
4568
4579
|
})(input = pxsim.input || (pxsim.input = {}));
|
|
4569
4580
|
})(pxsim || (pxsim = {}));
|
|
4570
4581
|
var pxsim;
|
|
4582
|
+
(function (pxsim) {
|
|
4583
|
+
var tts;
|
|
4584
|
+
(function (tts) {
|
|
4585
|
+
function _getLanguageCode() {
|
|
4586
|
+
return window.navigator.language;
|
|
4587
|
+
}
|
|
4588
|
+
tts._getLanguageCode = _getLanguageCode;
|
|
4589
|
+
function _speakAsync(text, pitch, rate, volume, language, onStart, onBoundary) {
|
|
4590
|
+
return new Promise((resolve, reject) => {
|
|
4591
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
4592
|
+
utterance.voice = getVoiceForLanguage(language || _getLanguageCode());
|
|
4593
|
+
if (pitch != undefined)
|
|
4594
|
+
utterance.pitch = pitch;
|
|
4595
|
+
if (rate != undefined)
|
|
4596
|
+
utterance.rate = rate;
|
|
4597
|
+
if (volume != undefined)
|
|
4598
|
+
utterance.volume = volume;
|
|
4599
|
+
utterance.onend = () => resolve();
|
|
4600
|
+
utterance.onerror = reject;
|
|
4601
|
+
if (onStart) {
|
|
4602
|
+
utterance.onstart = () => pxsim.runtime.runFiberAsync(onStart);
|
|
4603
|
+
}
|
|
4604
|
+
if (onBoundary) {
|
|
4605
|
+
utterance.onboundary = event => {
|
|
4606
|
+
const offset = event.charIndex;
|
|
4607
|
+
const nextWord = text.substring(offset).split(/\s/).shift();
|
|
4608
|
+
pxsim.runtime.runFiberAsync(onBoundary, offset, nextWord, text);
|
|
4609
|
+
};
|
|
4610
|
+
}
|
|
4611
|
+
speechSynthesis.speak(utterance);
|
|
4612
|
+
});
|
|
4613
|
+
}
|
|
4614
|
+
tts._speakAsync = _speakAsync;
|
|
4615
|
+
function _pause() {
|
|
4616
|
+
speechSynthesis.pause();
|
|
4617
|
+
}
|
|
4618
|
+
tts._pause = _pause;
|
|
4619
|
+
function _isPaused() {
|
|
4620
|
+
return speechSynthesis.paused;
|
|
4621
|
+
}
|
|
4622
|
+
tts._isPaused = _isPaused;
|
|
4623
|
+
function _resume() {
|
|
4624
|
+
speechSynthesis.resume();
|
|
4625
|
+
}
|
|
4626
|
+
tts._resume = _resume;
|
|
4627
|
+
function _cancel() {
|
|
4628
|
+
speechSynthesis.cancel();
|
|
4629
|
+
}
|
|
4630
|
+
tts._cancel = _cancel;
|
|
4631
|
+
function getVoiceForLanguage(language) {
|
|
4632
|
+
language = language.toLowerCase();
|
|
4633
|
+
const generalCode = language.substring(0, 2);
|
|
4634
|
+
let bestMatch;
|
|
4635
|
+
let bestNonlocalMatch;
|
|
4636
|
+
for (const voice of speechSynthesis.getVoices()) {
|
|
4637
|
+
const current = voice.lang.toLowerCase();
|
|
4638
|
+
if (current === language) {
|
|
4639
|
+
if (voice.localService)
|
|
4640
|
+
return voice;
|
|
4641
|
+
else
|
|
4642
|
+
bestNonlocalMatch = voice;
|
|
4643
|
+
}
|
|
4644
|
+
else if (current.substring(0, 2) === generalCode) {
|
|
4645
|
+
if (!bestMatch && voice.localService)
|
|
4646
|
+
bestMatch = voice;
|
|
4647
|
+
if (!bestNonlocalMatch && !voice.localService)
|
|
4648
|
+
bestNonlocalMatch = voice;
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
return bestMatch || bestNonlocalMatch || (language !== "en-us" ? getVoiceForLanguage("en-US") : undefined);
|
|
4652
|
+
}
|
|
4653
|
+
})(tts = pxsim.tts || (pxsim.tts = {}));
|
|
4654
|
+
})(pxsim || (pxsim = {}));
|
|
4655
|
+
var pxsim;
|
|
4571
4656
|
(function (pxsim) {
|
|
4572
4657
|
function thermometerState() {
|
|
4573
4658
|
return pxsim.board().thermometerState;
|