Skip to content

Commit 8f113a3

Browse files
authored
LegoBricks block (#4743)
* test-1 * test-1-phraseMaker-error-fix * Icons-PitchOrder-Instruments * linting-error-test-2
1 parent 5cd923f commit 8f113a3

File tree

14 files changed

+3266
-7
lines changed

14 files changed

+3266
-7
lines changed

README.md

Lines changed: 782 additions & 0 deletions
Large diffs are not rendered by default.

css/activities.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,8 @@ table {
20212021
max-width: 80%;
20222022
}
20232023

2024+
2025+
20242026
.chatInterface{
20252027
display: flex;
20262028
flex-direction: column;
@@ -2070,3 +2072,17 @@ table {
20702072
align-self: flex-end;
20712073
background-color: #DCF8C6;
20722074
}
2075+
2076+
2077+
.lego-brick {
2078+
display: inline-block;
2079+
background-color: #FF0000;
2080+
border: 1px solid #880000;
2081+
margin: 2px;
2082+
}
2083+
2084+
.lego-size-1 { width: 20px; height: 10px; }
2085+
.lego-size-2 { width: 40px; height: 10px; }
2086+
/* ... more sizes ... */
2087+
2088+

css/style.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,15 @@ input[type="range"]:focus::-ms-fill-lower {
9999
input[type="range"]:focus::-ms-fill-upper {
100100
background: #90c100;
101101
}
102+
103+
.lego-brick {
104+
display: inline-block;
105+
background-color: #FF0000;
106+
border: 1px solid #880000;
107+
margin: 2px;
108+
}
109+
110+
.lego-size-1 { width: 20px; height: 10px; }
111+
.lego-size-2 { width: 40px; height: 10px; }
112+
/* ... more sizes ... */
113+

header-icons/upload-button.svg

Lines changed: 5 additions & 0 deletions
Loading

header-icons/webcam-button.svg

Lines changed: 3 additions & 0 deletions
Loading

js/activity.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ if (_THIS_IS_MUSIC_BLOCKS_) {
174174
"widgets/oscilloscope",
175175
"widgets/sampler",
176176
"widgets/reflection",
177+
"widgets/legobricks",
177178
"activity/lilypond",
178179
"activity/abc",
179180
"activity/midi",

js/block.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,6 +4246,7 @@ class Block {
42464246
case "pitch staircase":
42474247
case "status":
42484248
case "phrase maker":
4249+
case "lego bricks":
42494250
case "custom mode":
42504251
case "music keyboard":
42514252
case "pitch drum":

js/blocks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,7 @@ class Blocks {
15791579
case "pitch staircase":
15801580
case "status":
15811581
case "phrase maker":
1582+
case "lego bricks":
15821583
case "custom mode":
15831584
case "music keyboard":
15841585
case "pitch drum":
@@ -2035,6 +2036,7 @@ class Blocks {
20352036
case "pitch staircase":
20362037
case "status":
20372038
case "phrase maker":
2039+
case "lego bricks":
20382040
case "custom mode":
20392041
case "music keyboard":
20402042
case "pitch drum":

js/blocks/PitchBlocks.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,17 @@ function setupPitchBlocks(activity) {
16141614
// convert hertz to note/octave
16151615
const note = obj;
16161616
tur.singer.lastNotePlayed = [note[0] + note[1], 4];
1617+
} else if (logo.inLegoWidget) {
1618+
logo.legoWidget.addRowBlock(blk);
1619+
if (!logo.pitchBlocks.includes(blk)) {
1620+
logo.pitchBlocks.push(blk);
1621+
}
1622+
1623+
logo.legoWidget.rowLabels.push(activity.blocks.blockList[blk].name);
1624+
logo.legoWidget.rowArgs.push(arg.toFixed(0));
1625+
// convert hertz to note/octave
1626+
const note = obj;
1627+
tur.singer.lastNotePlayed = [note[0] + note[1], 4];
16171628
} else if (logo.inMusicKeyboard) {
16181629
logo.musicKeyboard.instruments.push(last(tur.singer.instrumentNames));
16191630
logo.musicKeyboard.noteNames.push("hertz");

js/blocks/RhythmBlockPaletteBlocks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ function setupRhythmBlockPaletteBlocks(activity) {
112112
if (logo.inMatrix || logo.tuplet) {
113113
if (logo.inMatrix) {
114114
logo.phraseMaker.addColBlock(blk, arg0);
115+
116+
// Add individual entries for each beat to avoid extra × blocks
117+
for (let i = 0; i < arg0; i++) {
118+
logo.tupletRhythms.push(["individual", 1, noteBeatValue]);
119+
}
115120
}
116121

117122
for (let i = 0; i < args[0]; i++) {

0 commit comments

Comments
 (0)