This commit is contained in:
caizhitao
2020-01-16 23:33:46 +08:00
parent f58540ead2
commit f1256c5185
3 changed files with 8 additions and 6 deletions

View File

@@ -56,13 +56,15 @@ export default class RoundCornerCropV2EffectScene extends cc.Component {
this._examplesParentNode.children.forEach(childNode => {
childNode.getComponents(cc.RenderComponent).forEach(renderComponent => {
// 计算半径px分别相对于纹理宽高的比例也叫归一化
let xRadiux = param.radiusInPx / renderComponent.node.width;
// 约束范围在区间 [0.0, 0.5]
let xRadiux = param.radiusInPx / childNode.width;
// 约束范围在区间 [0.0, 0.5]
xRadiux = xRadiux >= 0.5 ? 0.5 : xRadiux;
let yRadius = param.radiusInPx / renderComponent.node.height;
let yRadius = param.radiusInPx / childNode.height;
yRadius = yRadius >= 0.5 ? 0.5 : yRadius;
if (childNode.name === "Rectangle1") cc.log(`${childNode.name} : (${xRadiux}, ${yRadius})`);
// 更新材质
let material: cc.Material = renderComponent.getMaterial(0);