## 原理解析

• 圆内放大
• 圆内缩小
• 向某一点拉伸

float dis=distance(vec2(gPosition.x,gPosition.y/uXY),vec2(centerPoint.x,centerPoint.y));
gl_FragColor=texture2D(vTexture,vec2(aCoordinate.x/2.0+0.25,aCoordinate.y/2.0+0.25));
}
gl_FragColor=orignalColor;


#### 圆内放大

//圆内放大
vec2 enlargeFun(vec2 curCoord,vec2 circleCenter,float radius,float intensity,float curve)
{
float currentDistance = distance(curCoord,circleCenter);

{

weight = 1.0-intensity*(1.0-pow(weight,curve));//默认curve 为2 ,当 curve 越大时, 会放大得越大的,
weight = clamp(weight,0.0,1.0);
curCoord = circleCenter+(curCoord-circleCenter)*weight;
}
return curCoord;
}


curve 是我们的pow函数的次方值,由于我们考虑的都是[0,1]区间的,所以该值越大,离中心点向外扩散也越厉害,放大效果越大.
intensity 的取值是[0,1]当它取1时就是我们上面分析的情况,会最大化的利用pow次方产生的坐标偏移来取像素,若它为0,则不会产生任何缩放效果,intensity 是一个影响因子,一个对 pow函数产生的坐标偏移的采用度,intensity越大则会更大化利用 pow 函数产生坐标便宜作为最后的坐标偏移.

#### 圆内缩小

vec2 narrowFun(vec2 curCoord,vec2 circleCenter,float radius,float intensity,float curve)
{
float currentDistance = distance(curCoord,circleCenter);

{
weight = 1.0-intensity*(1.0-pow(weight,curve));//默认curve 为2 ,当curve 越大时, 会缩小得越小的,
weight = clamp(weight,0.0001,1.0);
curCoord = circleCenter+(curCoord-circleCenter)/weight;
}
return curCoord;
}


#### 向某一点拉伸

// 拉伸
vec2 stretchFun(vec2 textureCoord, vec2 originPosition, vec2 targetPosition, float radius,float curve)
{
vec2 offset = vec2(0.0);
vec2 result = vec2(0.0);

vec2 direction = targetPosition - originPosition;

infect = pow(infect,curve);// 默认 curve 为1,这个值越大,拉伸到指定点越圆润,越小越尖
infect = 1.0-infect;
infect = clamp(infect,0.0,1.0);
offset = direction * infect;
result = textureCoord - offset;

return result;
}


11-13

10-06
04-24
05-24
03-16 1911
10-11
12-21 1109