Skip to content

Instantly share code, notes, and snippets.

@CoderJackLiu
Last active July 2, 2024 11:41
Show Gist options
  • Save CoderJackLiu/dfe206bfec0bb6c694daa5299d50cd79 to your computer and use it in GitHub Desktop.
Save CoderJackLiu/dfe206bfec0bb6c694daa5299d50cd79 to your computer and use it in GitHub Desktop.
//圆角
float2 UV = uvs;
float PixelRange = min(min(SizeX/2,SizeY/2),Range);
//当前绘制的像素
float2 CurrentP = float2(UV.x*SizeX,UV.y*SizeY);
//像素坐标参照点
//float2 MiddleP=float2(0.5*SizeX,0.5*SizeY);
//左上角圆心像素坐标
float2 MP1=float2(PixelRange , PixelRange);
//右上角圆心像素坐标
float2 MP2=float2(SizeX - PixelRange , PixelRange);
//左下角圆心像素坐标
float2 MP3=float2(PixelRange , SizeY - PixelRange);
//右下角圆心像素坐标
float2 MP4=float2(SizeX - PixelRange , SizeY - PixelRange);
if (CurrentP.x<MP1.x&&CurrentP.y<MP1.y)
{
/* 左上角 */
if (length((CurrentP-MP1))<PixelRange)
{
/* code */
return 1;
}
return 0;
}else if (CurrentP.x>MP2.x&&CurrentP.y<MP2.y)
{
/* 右上角 */
if (length((CurrentP-MP2))<PixelRange)
{
/* code */
return 1;
}
return 0;
}else if (CurrentP.x<MP3.x&&CurrentP.y>MP3.y)
{
/* 左下角 */
if (length((CurrentP-MP3))<PixelRange)
{
/* code */
return 1;
}
return 0;
}else if (CurrentP.x>MP4.x&&CurrentP.y>MP4.y)
{
/* 右下角 */
if (length((CurrentP-MP4))<PixelRange)
{
/* code */
return 1;
}
return 0;
}
return 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment