Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: code style in generators for field colour blocks #2233

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading