Skip to content

Commit

Permalink
fix: code style in generators for field colour blocks (#2233)
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-fenichel committed Apr 2, 2024
1 parent 78c52d4 commit 3bb1b42
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
15 changes: 5 additions & 10 deletions plugins/field-colour/src/blocks/colourBlend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ function ${generator.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
}
`,
);
const code =
functionName + '(' + colour1 + ', ' + colour2 + ', ' + ratio + ')';
const code = `${functionName}(${colour1}, ${colour2}, ${ratio})`;
return [code, JavascriptOrder.FUNCTION_CALL];
}

Expand Down Expand Up @@ -147,8 +146,7 @@ String ${generator.FUNCTION_NAME_PLACEHOLDER_}(String c1, String c2, num ratio)
}
`,
);
const code =
functionName + '(' + colour1 + ', ' + colour2 + ', ' + ratio + ')';
const code = `${functionName}(${colour1}, ${colour2}, ${ratio})`;
return [code, DartOrder.UNARY_POSTFIX];
}

Expand Down Expand Up @@ -187,8 +185,7 @@ end
const colour2 =
generator.valueToCode(block, 'COLOUR2', LuaOrder.NONE) || "'#000000'";
const ratio = generator.valueToCode(block, 'RATIO', LuaOrder.NONE) || 0;
const code =
functionName + '(' + colour1 + ', ' + colour2 + ', ' + ratio + ')';
const code = `${functionName}(${colour1}, ${colour2}, ${ratio})`;
return [code, LuaOrder.HIGH];
}

Expand Down Expand Up @@ -231,8 +228,7 @@ function ${generator.FUNCTION_NAME_PLACEHOLDER_}($c1, $c2, $ratio) {
}
`,
);
const code =
functionName + '(' + colour1 + ', ' + colour2 + ', ' + ratio + ')';
const code = `${functionName}(${colour1}, ${colour2}, ${ratio})`;
return [code, PhpOrder.FUNCTION_CALL];
}

Expand Down Expand Up @@ -267,8 +263,7 @@ def ${generator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio):
const colour2 =
generator.valueToCode(block, 'COLOUR2', PythonOrder.NONE) || "'#000000'";
const ratio = generator.valueToCode(block, 'RATIO', PythonOrder.NONE) || 0;
const code =
functionName + '(' + colour1 + ', ' + colour2 + ', ' + ratio + ')';
const code = `${functionName}(${colour1}, ${colour2}, ${ratio})`;
return [code, PythonOrder.FUNCTION_CALL];
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/field-colour/src/blocks/colourRandom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function toJavascript(
'colourRandom',
`
function ${generator.FUNCTION_NAME_PLACEHOLDER_}() {
var num = Math.floor(Math.random() * Math.pow(2, 24));
var num = Math.floor(Math.random() * 0x1000000);
return '#' + ('00000' + num.toString(16)).substr(-6);
}
`,
Expand Down
8 changes: 4 additions & 4 deletions plugins/field-colour/src/blocks/colourRgb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function ${generator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
}
`,
);
const code = functionName + '(' + red + ', ' + green + ', ' + blue + ')';
const code = `${functionName}(${red}, ${green}, ${blue})`;
return [code, JavascriptOrder.FUNCTION_CALL];
}

Expand Down Expand Up @@ -125,7 +125,7 @@ String ${generator.FUNCTION_NAME_PLACEHOLDER_}(num r, num g, num b) {
}
`,
);
const code = functionName + '(' + red + ', ' + green + ', ' + blue + ')';
const code = `${functionName}(${red}, ${green}, ${blue})`;
return [code, DartOrder.UNARY_POSTFIX];
}

Expand Down Expand Up @@ -155,7 +155,7 @@ end
const red = generator.valueToCode(block, 'RED', LuaOrder.NONE) || 0;
const green = generator.valueToCode(block, 'GREEN', LuaOrder.NONE) || 0;
const blue = generator.valueToCode(block, 'BLUE', LuaOrder.NONE) || 0;
const code = functionName + '(' + red + ', ' + green + ', ' + blue + ')';
const code = `${functionName}(${red}, ${green}, ${blue})`;
return [code, LuaOrder.HIGH];
}

Expand Down Expand Up @@ -189,7 +189,7 @@ function ${generator.FUNCTION_NAME_PLACEHOLDER_}($r, $g, $b) {
}
`,
);
const code = functionName + '(' + red + ', ' + green + ', ' + blue + ')';
const code = `${functionName}(${red}, ${green}, ${blue})`;
return [code, PhpOrder.FUNCTION_CALL];
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/field-colour/test/golden/golden.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function colourRandom() {
var num = Math.floor(Math.random() * Math.pow(2, 24));
var num = Math.floor(Math.random() * 0x1000000);
return '#' + ('00000' + num.toString(16)).substr(-6);
}

Expand Down

0 comments on commit 3bb1b42

Please sign in to comment.