Compare commits

...

25 Commits

Author SHA1 Message Date
e6e6016bc0 0.1.43 2018-05-04 10:37:55 -07:00
3f23f5afa8 bump pxt-core to 3.12.19, bump pxt-common-packages to 0.22.7, 2018-05-04 10:37:48 -07:00
f0df0222c0 Fixes for High contrast mode as per lego design. Most changes are in PXT. Adding high contrast theme in the simulator (#564) 2018-05-04 10:36:48 -07:00
2a371b9cc6 Release electron v0.1.40 2018-05-04 10:04:39 -04:00
3211999583 0.1.42 2018-05-03 17:07:09 -07:00
b29862d566 update packaglock 2018-05-03 17:04:22 -07:00
b262d944b7 bump pxt-core to 3.12.18, bump pxt-common-packages to 0.22.2, 2018-05-03 17:03:16 -07:00
1b89d08337 Reduce size of tutorial gifs (#562) 2018-05-03 17:02:22 -07:00
6bdae6547a 0.1.41 2018-05-03 15:03:24 -07:00
30a67b729d Align all modules to a minimum height. (#563) 2018-05-03 15:02:13 -07:00
3e2c61e212 0.1.40 2018-05-03 11:59:50 -07:00
7a37dec196 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-05-03 11:48:19 -07:00
bac792f188 upgrade firmware -> troubleshoot 2018-05-03 11:48:10 -07:00
e4c3fa0e57 Make the light around the color sensor appear bright and not a reflection of the current color detected. (#561) 2018-05-03 08:39:06 -07:00
76f7df7579 Update favicon 2018-05-03 08:06:39 -07:00
d7e671175c 0.1.39 2018-05-03 06:57:18 -07:00
f4b7230a67 remove "pxtrequire" 2018-05-03 06:55:50 -07:00
afe0f9b0f7 updated pxt 2018-05-03 06:54:30 -07:00
23b6edc4bf Release app 0.1.36 2018-05-03 09:22:18 -04:00
13b3c1a194 Attempt to shorten color sensor ambient and reflected blocks by removing detected keyword (#560) 2018-05-02 22:09:04 -07:00
7e58b9b699 Motor angle (#559)
* control angle with slider

* called changed state

* remove logging
2018-05-02 22:04:29 -07:00
08a860bd80 Update tutorial gifs to match new sim inputs (#558) 2018-05-02 17:15:29 -07:00
4a966a73f1 0.1.38 2018-05-02 16:24:41 -07:00
542216000c 0.1.37 2018-05-02 16:24:35 -07:00
b323929f03 Fix color grid on IE. (#556) 2018-05-02 16:23:53 -07:00
27 changed files with 120 additions and 108 deletions

View File

@ -1,6 +0,0 @@
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
import * as path from "path";
export let pxtCore = require("pxt-core");
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir
export let pxtCoreDir = path.resolve(require.resolve("pxt-core"), "..", "..");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 KiB

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 KiB

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -185,7 +185,7 @@ namespace sensors {
* @param handler the code to run when detected
*/
//% help=sensors/color-sensor/on-light-detected
//% block="on **color sensor** %this|detected %mode|%condition"
//% block="on **color sensor** %this|%mode|%condition"
//% blockId=colorOnLightDetected
//% parts="colorsensor"
//% blockNamespace=sensors
@ -202,7 +202,7 @@ namespace sensors {
* @param color the color to detect
*/
//% help=sensors/color-sensor/pause-until-light-detected
//% block="pause until **color sensor** %this|detected %mode|%condition"
//% block="pause until **color sensor** %this|%mode|%condition"
//% blockId=colorPauseUntilLightDetected
//% parts="colorsensor"
//% blockNamespace=sensors

70
package-lock.json generated
View File

@ -1,25 +1,25 @@
{
"name": "pxt-ev3",
"version": "0.1.36",
"version": "0.1.43",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/bluebird": {
"version": "2.0.33",
"resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-2.0.33.tgz",
"integrity": "sha512-iq7ss0qO31YCYeLEPrBoVMDLw1dBotOS7394a+Dj2CSvQNjQfJvryVo9es5ghvQZmIqO7Q0tlCe9YpwTZKOoXg==",
"integrity": "sha1-J3wmM9z1qAgDvXGHEMK4VyWWYoU=",
"dev": true
},
"@types/marked": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@types/marked/-/marked-0.3.0.tgz",
"integrity": "sha512-CSf9YWJdX1DkTNu9zcNtdCcn6hkRtB5ILjbhRId4ZOQqx30fXmdecuaXhugQL6eyrhuXtaHJ7PHI+Vm7k9ZJjg==",
"integrity": "sha1-WDwiPdMzhaHdoBqvd7DNBBHEtSQ=",
"dev": true
},
"@types/node": {
"version": "8.0.53",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.53.tgz",
"integrity": "sha512-54Dm6NwYeiSQmRB1BLXKr5GELi0wFapR1npi8bnZhEcu84d/yQKqnwwXQ56hZ0RUbTG6L5nqDZaN3dgByQXQRQ==",
"integrity": "sha1-OWs1r4JvpmqtRyyMt7jV4nf05tg=",
"dev": true
},
"JSONStream": {
@ -34,7 +34,7 @@
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"integrity": "sha1-+PLIh60Qv2f2NPAFtph/7TF5qsg=",
"dev": true
},
"acorn": {
@ -361,7 +361,7 @@
"aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
"integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw=="
"integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo="
},
"are-we-there-yet": {
"version": "1.1.4",
@ -499,7 +499,7 @@
"base64-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz",
"integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw=="
"integrity": "sha1-qRlH2h9KUW6jjltOwOw3c2deCIY="
},
"bcrypt-pbkdf": {
"version": "1.0.1",
@ -763,7 +763,7 @@
"bufferstreams": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.3.tgz",
"integrity": "sha512-HaJnVuslRF4g2kSDeyl++AaVizoitCpL9PglzCYwy0uHHyvWerfvEb8jWmYbF1z4kiVFolGomnxSGl+GUQp2jg==",
"integrity": "sha1-qFFawCT6kOj6fVjBGxPeofKKvnI=",
"dev": true,
"requires": {
"readable-stream": "2.3.3"
@ -864,7 +864,7 @@
"cipher-base": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
"integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=",
"requires": {
"inherits": "2.0.3",
"safe-buffer": "5.1.1"
@ -873,7 +873,7 @@
"clap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/clap/-/clap-1.2.3.tgz",
"integrity": "sha512-4CoL/A3hf90V3VIEjeuhSvlGFEHKzOz+Wfc2IVZc+FaUgU0ZQafJTP49fvnULipOPcAfqhyI2duwQyns6xqjYA==",
"integrity": "sha1-TzZ0WzIAhJJVf0ZBLWbVDLmbzlE=",
"requires": {
"chalk": "1.1.3"
}
@ -1544,7 +1544,7 @@
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
@ -1654,7 +1654,7 @@
"hash.js": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz",
"integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==",
"integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=",
"requires": {
"inherits": "2.0.3",
"minimalistic-assert": "1.0.0"
@ -2277,6 +2277,11 @@
"object-visit": "1.0.1"
}
},
"marked": {
"version": "0.3.19",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz",
"integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg=="
},
"math-expression-evaluator": {
"version": "1.2.17",
"resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz",
@ -2349,7 +2354,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
"requires": {
"brace-expansion": "1.1.8"
}
@ -2541,7 +2546,7 @@
"npmlog": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
"integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
"requires": {
"are-we-there-yet": "1.1.4",
"console-control-strings": "1.1.0",
@ -3279,19 +3284,17 @@
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
},
"pxt-common-packages": {
"version": "0.22.1",
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.22.1.tgz",
"integrity": "sha512-GdqA/7tk1OQbkeMeCiPG4oRocV7lMb9HCya6gp5RuCPLKNpbLaCDHyLsXQGR8sXJOoFqrLjUWaQILbMKhCGNMQ==",
"version": "0.22.2",
"resolved": "https://registry.npmjs.org/pxt-common-packages/-/pxt-common-packages-0.22.2.tgz",
"integrity": "sha512-bndrU1Aqig0O504QuaQYICrSQfQF7QFBoOArl0hdY7NWfq2yNJu8CHoW2oKJm+r+LTz150D4XuHjCIGLEv2MBQ==",
"requires": {
"autoprefixer": "6.7.7",
"pxt-core": "3.12.12",
"rtlcss": "2.2.1"
"pxt-core": "3.12.18"
}
},
"pxt-core": {
"version": "3.12.12",
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.12.12.tgz",
"integrity": "sha512-o/u+Qxt2Xuid8f6f2KHDYnJ7qcxOvcbiUqxoOMFZrQkgnME7Pekly+mQPn2w1kjpO9M84BX70Mi9ld8dY/nLRg==",
"version": "3.12.18",
"resolved": "https://registry.npmjs.org/pxt-core/-/pxt-core-3.12.18.tgz",
"integrity": "sha512-Dd1XHjMjSR6gqf8B2LB7mtppD+VI49wckd/jCK8dHZcjb7RbngqTnfjOuHcDbXfSrvDrGFNzBhYvYaLf70AV7g==",
"requires": {
"bluebird": "3.5.1",
"browserify": "16.2.0",
@ -3300,6 +3303,7 @@
"keytar": "4.2.1",
"less": "2.7.3",
"lzma": "2.3.2",
"marked": "0.3.19",
"node-hid": "0.5.7",
"pngjs": "3.3.2",
"postcss": "6.0.21",
@ -3468,7 +3472,7 @@
"readable-stream": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
"integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
"integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=",
"requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
@ -3482,7 +3486,7 @@
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
"requires": {
"safe-buffer": "5.1.1"
}
@ -3727,12 +3731,12 @@
"safe-buffer": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
"integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM="
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
"integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk="
},
"semantic-ui-less": {
"version": "2.2.14",
@ -4044,7 +4048,7 @@
"stream-http": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz",
"integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==",
"integrity": "sha1-QKBQ7I3DtTsz2ZCUFcAsC/Gr+60=",
"requires": {
"builtin-status-codes": "3.0.0",
"inherits": "2.0.3",
@ -4195,7 +4199,7 @@
"commander": {
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz",
"integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==",
"integrity": "sha1-D1lGxCftnsDZGka7ne9T5UZQ5VU=",
"dev": true
}
}
@ -4355,7 +4359,7 @@
"pako": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
"integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
"integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=",
"dev": true
}
}
@ -4510,7 +4514,7 @@
"uuid": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
"integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g=="
"integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ="
},
"varstream": {
"version": "0.3.2",
@ -4606,7 +4610,7 @@
"which": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
"integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==",
"integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=",
"dev": true,
"requires": {
"isexe": "2.0.0"
@ -4615,7 +4619,7 @@
"wide-align": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
"integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=",
"requires": {
"string-width": "1.0.2"
}

View File

@ -1,6 +1,6 @@
{
"name": "pxt-ev3",
"version": "0.1.36",
"version": "0.1.43",
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
"private": true,
"keywords": [
@ -30,8 +30,6 @@
"docs/*/*.md",
"docs/*/*/*.md"
],
"main": "built/pxtrequire.js",
"typings": "built/pxtrequire.d.ts",
"devDependencies": {
"typescript": "2.6.1",
"semantic-ui-less": "2.2.14",
@ -41,8 +39,8 @@
"webfonts-generator": "^0.4.0"
},
"dependencies": {
"pxt-common-packages": "0.22.1",
"pxt-core": "3.12.16"
"pxt-common-packages": "0.22.7",
"pxt-core": "3.12.19"
},
"scripts": {
"test": "node node_modules/pxt-core/built/pxt.js travis"

View File

@ -81,7 +81,6 @@
"accentColor": "#0089BF",
"logoUrl": "https://education.lego.com/",
"logo": "./static/lego_education_logo.png",
"highContrastLogo": "./static/lego_education_logo_white.png",
"docsLogo": "./static/lego-logo.svg",
"portraitLogo": "./static/lego-logo.svg",
"footerLogo": "./static/lego-logo.svg",
@ -110,8 +109,8 @@
"path": "http://service.lego.com"
},
{
"name": "Upgrade Firmware",
"path": "https://ev3manager.education.lego.com/"
"name": "Troubleshoot",
"path": "/troubleshoot"
},
{
"name": "Blocks",

View File

@ -17,7 +17,8 @@ namespace pxsim {
private speedCmdTime: number;
private _synchedMotor: MotorNode; // non-null if synchronized
private manualSpeed: number = undefined;
private manualReferenceAngle: number = undefined;
private manualAngle: number = undefined;
constructor(port: number, large: boolean) {
super(port);
@ -103,14 +104,18 @@ namespace pxsim {
}
manualMotorDown() {
this.manualReferenceAngle = this.angle;
this.manualAngle = 0;
}
manualMotorMove(speed: number) {
this.manualSpeed = speed;
// position: 0, 360
manualMotorAngle(angle: number) {
this.manualAngle = angle;
}
manualMotorUp() {
this.manualSpeed = undefined;
delete this.manualReferenceAngle;
delete this.manualAngle;
}
updateState(elapsed: number) {
@ -126,7 +131,7 @@ namespace pxsim {
}
private updateStateStep(elapsed: number) {
if (!this.manualSpeed) {
if (this.manualAngle === undefined) {
// compute new speed
switch (this.speedCmd) {
case DAL.opOutputSpeed:
@ -202,7 +207,11 @@ namespace pxsim {
}
}
else {
this.speed = this.manualSpeed;
// the user is holding the handle - so position is the angle
this.speed = 0;
// rotate by the desired angle change
this.angle = this.manualReferenceAngle + this.manualAngle;
this.setChangedState();
}
this.speed = Math.round(this.speed); // integer only
@ -217,7 +226,8 @@ namespace pxsim {
// if the motor was stopped or there are no speed commands,
// let it coast to speed 0
if (this.speed && !(this.started || this.speedCmd)) {
if ((this.manualReferenceAngle === undefined)
&& this.speed && !(this.started || this.speedCmd)) {
// decay speed 5% per tick
this.speed = Math.round(Math.max(0, Math.abs(this.speed) - 10) * sign(this.speed));
}

View File

@ -101,10 +101,13 @@ namespace pxsim.visuals {
export const SCREEN_HEIGHT = 128;
export interface IBoardTheme {
accent?: string;
highContrast?: boolean;
display?: string;
buttonOuter?: string;
buttonUps: string[];
buttonDown?: string;
wireColor?: string;
backgroundViewColor?: string;
}
export var themes: IBoardTheme[] = ["#3ADCFE"].map(accent => {
@ -112,12 +115,21 @@ namespace pxsim.visuals {
accent: accent,
buttonOuter: "#979797",
buttonUps: ["#a8aaa8", "#393939", "#a8aaa8", "#a8aaa8", "#a8aaa8", '#a8aaa8'],
buttonDown: "#000"
buttonDown: "#000",
wireColor: '#5A5A5A',
backgroundViewColor: '#d6edff'
}
});
export function randomTheme(highContrast?: boolean, light?: boolean): IBoardTheme {
return themes[Math.floor(Math.random() * themes.length)];
let theme = themes[Math.floor(Math.random() * themes.length)];
if (highContrast) {
theme = JSON.parse(JSON.stringify(theme)) as IBoardTheme;
theme.highContrast = true;
theme.wireColor = '#ffffff';
theme.backgroundViewColor = '#ffffff';
}
return theme;
}
export interface IBoardProps {
@ -334,7 +346,7 @@ namespace pxsim.visuals {
this.style.textContent = EV3_STYLE;
this.layoutView = new LayoutView();
this.layoutView.inject(this.element);
this.layoutView.inject(this.element, this.props.theme);
const brick = new BrickViewPortrait(-1);
this.layoutView.setBrick(brick);

View File

@ -13,7 +13,7 @@ namespace pxsim.visuals {
'x': 0, 'y': 0,
'width': '100%',
'height': '100%',
'style': `fill: #d6edff; stroke: #A8A9A8; stroke-width: 3px; stroke-opacity: 0.2`
'style': `fill: ${this.theme.backgroundViewColor};stroke: #A8A9A8; stroke-width: 3px; stroke-opacity: 0.2`
}) as SVGRectElement;
return this.backgroundGroup;
}

View File

@ -8,6 +8,8 @@ namespace pxsim.visuals {
private static colorIds = ['red', 'yellow', 'blue', 'green', 'black', 'grey', 'white'];
private static colorValue = [5, 4, 2, 3, 1, 7, 6];
private colorDivs: Element[] = [];
getInnerView() {
this.group = svg.elt("g") as SVGGElement;
this.group.setAttribute("transform", `translate(2, 2.5) scale(0.6)`)
@ -23,6 +25,7 @@ namespace pxsim.visuals {
const circle = pxsim.svg.child(this.group, "circle", {
'class': `sim-color-grid-circle sim-color-grid-${colorIds[c]}`,
'cx': cx, 'cy': cy, 'r': '2', 'style': `fill: ${colors[c]}` });
this.colorDivs.push(circle);
pointerEvents.down.forEach(evid => circle.addEventListener(evid, ev => {
this.setColor(ColorGridControl.colorValue[c]);
}));
@ -30,7 +33,8 @@ namespace pxsim.visuals {
}
const whiteCircleWrapper = pxsim.svg.child(this.group, "g", { 'id': 'white-cirlce-wrapper' });
pxsim.svg.child(whiteCircleWrapper, "circle", { 'class': 'sim-color-grid-circle sim-color-grid-white', 'cx': 2.2, 'cy': '16', 'r': '2', 'style': `fill: #fff` });
const circle = pxsim.svg.child(whiteCircleWrapper, "circle", { 'class': 'sim-color-grid-circle sim-color-grid-white', 'cx': 2.2, 'cy': '16', 'r': '2', 'style': `fill: #fff` });
this.colorDivs.push(circle);
pxsim.svg.child(whiteCircleWrapper, "circle", { 'cx': 2.2, 'cy': '16', 'r': '2', 'style': `fill: none;stroke: #94989b;stroke-width: 0.1px` });
pointerEvents.down.forEach(evid => whiteCircleWrapper.addEventListener(evid, ev => {
this.setColor(6);
@ -56,7 +60,7 @@ namespace pxsim.visuals {
for (let c = 0; c < ColorGridControl.colorValue.length; c++) {
const colorId = ColorGridControl.colorIds[c];
const colorValue = ColorGridControl.colorValue[c];
const colorDiv = this.group.getElementsByClassName(`sim-color-grid-${colorId}`)[0] as HTMLElement;
const colorDiv = this.colorDivs[c] as HTMLElement;
if (colorValue == color) {
pxsim.U.addClass(colorDiv, 'sim-color-selected');

View File

@ -13,7 +13,7 @@ namespace pxsim.visuals {
private static SLIDER_RADIUS = 100;
private internalSpeed: number = 0;
private internalAngle: number = 0;
getInnerView(parent: SVGSVGElement, globalDefs: SVGDefsElement) {
this.group = svg.elt("g") as SVGGElement;
@ -102,9 +102,9 @@ namespace pxsim.visuals {
} else if (dx >= 0 && dy <= 0) {
deg = 90 - deg;
}
const value = Math.abs(Math.ceil((deg % 360) / 360 * this.getMax()));
const value = Math.abs(Math.ceil((deg % 360)));
this.internalSpeed = value;
this.internalAngle = value;
this.updateDial();
this.prevVal = deg;
@ -119,7 +119,7 @@ namespace pxsim.visuals {
private handleSliderMove() {
this.dial.setAttribute('cursor', '-webkit-grabbing');
const state = this.state;
state.manualMotorMove(this.internalSpeed);
state.manualMotorAngle(this.internalAngle);
}
private handleSliderUp() {
@ -127,19 +127,18 @@ namespace pxsim.visuals {
const state = this.state;
state.manualMotorUp();
this.internalSpeed = 0;
this.internalAngle = 0;
this.updateDial();
}
private updateDial() {
let speed = this.internalSpeed;
let angle = this.internalAngle;
// Update dial position
const deg = speed / this.getMax() * 360; // degrees
const radius = MotorSliderControl.SLIDER_RADIUS;
const dialRadius = 5;
const x = Math.ceil((radius - dialRadius) * Math.sin(deg * Math.PI / 180)) + radius;
const y = Math.ceil((radius - dialRadius) * -Math.cos(deg * Math.PI / 180)) + radius;
const x = Math.ceil((radius - dialRadius) * Math.sin(angle * Math.PI / 180)) + radius;
const y = Math.ceil((radius - dialRadius) * -Math.cos(angle * Math.PI / 180)) + radius;
this.dial.setAttribute('transform', `translate(${x}, ${y})`);
}
@ -148,18 +147,10 @@ namespace pxsim.visuals {
return;
}
const node = this.state;
const speed = node.getSpeed();
const angle = node.getAngle() % 360;
// Update reporter
this.reporter.textContent = `${speed}`;
}
private getMin() {
return 0;
}
private getMax() {
return 100;
this.reporter.textContent = `${angle}°`;
}
}

View File

@ -12,6 +12,7 @@ namespace pxsim.visuals {
export const MODULE_INNER_PADDING_RATIO = 1 / 35;
export const MAX_MODULE_WIDTH = 100;
export const MIN_MODULE_HEIGHT = 40;
export const CLOSE_ICON_GAP_MULTIPLIER = 0.3;
@ -78,8 +79,8 @@ namespace pxsim.visuals {
public setBrick(brick: BrickView) {
this.brick = brick;
this.brick.inject(this.scrollGroup);
this.brickLandscape.inject(this.scrollGroup);
this.brick.inject(this.scrollGroup, this.theme);
this.brickLandscape.inject(this.scrollGroup, this.theme);
this.brick.setSelected(false);
this.brickLandscape.setSelected(true);
this.brickLandscape.setVisible(false);
@ -211,16 +212,16 @@ namespace pxsim.visuals {
// Inject all wires
for (let port = 0; port < DAL.NUM_OUTPUTS; port++) {
this.outputWires[port].inject(this.scrollGroup);
this.outputWires[port].inject(this.scrollGroup, this.theme);
}
for (let port = 0; port < DAL.NUM_INPUTS; port++) {
this.inputWires[port].inject(this.scrollGroup);
this.inputWires[port].inject(this.scrollGroup, this.theme);
}
// Inject all view containers
for (let i = 0; i < 4; i++) {
this.inputContainers[i].inject(this.scrollGroup);
this.outputContainers[i].inject(this.scrollGroup);
this.inputContainers[i].inject(this.scrollGroup, this.theme);
this.outputContainers[i].inject(this.scrollGroup, this.theme);
}
// Inject all ports
@ -252,6 +253,12 @@ namespace pxsim.visuals {
}
public updateTheme(theme: IBoardTheme) {
this.inputWires.forEach(n => {
n.updateTheme(theme);
})
this.outputWires.forEach(n => {
n.updateTheme(theme);
})
this.inputs.forEach(n => {
n.updateTheme(theme);
})
@ -372,7 +379,7 @@ namespace pxsim.visuals {
// Translate and resize view
view.resize(inputWidth - inputPadding * 2, inputHeight);
const viewHeight = view.getActualHeight();
const viewHeight = Math.max(view.getActualHeight(), MIN_MODULE_HEIGHT);
view.translate(inputPadding, 0, true);
// Resize control

View File

@ -36,7 +36,10 @@ namespace pxsim.visuals {
private updateSensorLightVisual(color: string) {
const sensorHole = this.content.getElementById(this.normalizeId(ColorSensorView.sensor_hole_id)) as SVGCircleElement;
sensorHole.style.fill = color;
sensorHole.style.stroke = color;
if (color != '#ffffff') {
sensorHole.style.strokeWidth = '2px';
}
}
}
}

View File

@ -19,8 +19,9 @@ namespace pxsim.visuals {
public abstract getInnerWidth(): number;
public abstract getInnerHeight(): number;
public inject(parent: SVGElement, width?: number, visible = true) {
public inject(parent: SVGElement, theme: IBoardTheme, width?: number, visible = true) {
this.width = width;
this.theme = theme;
parent.appendChild(this.getView());
if (visible) {
@ -276,7 +277,7 @@ namespace pxsim.visuals {
}
public addView(view: View) {
view.inject(this.element);
view.inject(this.element, this.theme);
}
public clear() {

View File

@ -41,6 +41,11 @@ namespace pxsim.visuals {
return this.wire;
}
public updateThemeCore() {
let theme = this.theme;
this.path.setAttribute('stroke', theme.wireColor);
}
updatePath() {
if (!this.hasDimensions) return;
const height = this.endY - this.startY;

View File

@ -15,6 +15,6 @@
"Maker": "maker"
},
"electronManifest": {
"latest": "v0.1.30"
"latest": "v0.1.40"
}
}

View File

@ -155,22 +155,6 @@
}
}
/** high contrast **/
.hc {
.ui.menu, #downloadArea,
.menubar .ui.menu.fixed .ui.item.editor-menuitem .item.active {
background-color: black !important;
color: white !important;
}
.ui.red.corner.label {
border-color: #d4000d!important;
}
.menubar .ui.menu.fixed .item.editor-menuitem .ui.grid {
border-color: white !important;
}
}
/*******************************
Custom icons
*******************************/