Skip to content

Commit

Permalink
update Color
Browse files Browse the repository at this point in the history
  • Loading branch information
star-e committed Oct 15, 2024
1 parent 872df78 commit fd73f66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions cocos/gfx/base/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,21 +987,21 @@ export class Color {
public w: number = 0,
) {}

public set (x: number, y: number, z: number, w: number): Color {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
return this;
}

public copy (info: Readonly<Color>): Color {
this.x = info.x;
this.y = info.y;
this.z = info.z;
this.w = info.w;
return this;
}

public set (x: number, y: number, z: number, w: number): Color {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
return this;
}
}

export class MarkerInfo {
Expand Down
22 changes: 11 additions & 11 deletions native/tools/gfx-define-generator/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,6 @@ for (const name of Object.keys(structMap)) {

output += ` ) {}\n`;

if (name === 'Color') {
output += `\n`;
output += ` public set (x: number, y: number, z: number, w: number): Color {\n`;
output += ` this.x = x;\n`;
output += ` this.y = y;\n`;
output += ` this.z = z;\n`;
output += ` this.w = w;\n`;
output += ` return this;\n`;
output += ` }\n`;
}

if (!Object.keys(struct.member).some((k) => struct.member[k].readonly)) {
output += `\n public copy (info: Readonly<${name}>): ${name} {\n`;
for (const key in struct.member) {
Expand All @@ -320,6 +309,17 @@ for (const name of Object.keys(structMap)) {
output += ` }\n`;
}

if (name === 'Color') {
output += `\n`;
output += ` public set (x: number, y: number, z: number, w: number): Color {\n`;
output += ` this.x = x;\n`;
output += ` this.y = y;\n`;
output += ` this.z = z;\n`;
output += ` this.w = w;\n`;
output += ` return this;\n`;
output += ` }\n`;
}

output += `}\n\n`;
}

Expand Down

0 comments on commit fd73f66

Please sign in to comment.