Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Returns a point positioned a t% along the Bézier curve defined by the 4 points.
- point BezierCurvePoint (fixed t, point p0, point p1, point p2, point p3)
- {
- fixed u = 1-t;
- fixed tt = t*t;
- fixed uu = u*u;
- fixed uuu = uu*u;
- fixed ttt = tt*t;
- fixed vX = uuu*PointGetX(p0);
- fixed vY = uuu*PointGetY(p0);
- vX += 3*uu*t*PointGetX(p1);
- vY += 3*uu*t*PointGetY(p1);
- vX += 3*u*tt*PointGetX(p2);
- vY += 3*u*tt*PointGetY(p2);
- vX += ttt*PointGetX(p3);
- vY += ttt*PointGetY(p3);
- return Point(vX,vY);
- }
- // Returns a point positioned a t% along the Bézier curve defined by 2 points between [0,0] and [1,1].
- point BezierFactorPoint (fixed t, point p1, point p2)
- {
- return BezierCurvePoint(t,Point(0,0),p1,p2,Point(1,1));
- }
- // Returns a fixed value representing the progress of the transition at step t.
- fixed BezierFactor (fixed t, point p1, point p2)
- {
- return PointGetY(BezierFactorPoint(t,p1,p2));
- }
- // Crude test script demonstrating it.
- void Test_Init ()
- {
- // pseudo constants
- playergroup g = PlayerGroupAll();
- string image = "Assets\\Textures\\ui_battlenet_glue_checkcirclemark.dds";
- int imageSize = 24;
- int dialogSize = 300;
- int dialog = Dialog(dialogSize+imageSize,dialogSize+imageSize,c_anchorCenter,0,0,Visible,Onscreen,NotFullscreen,"Assets\\Textures\\ui_challenge_iconborder.dds",NoTitle,NoTransparency,DefaultChannel);
- point pointA = Point(0.42,0);
- point pointB = Point(0.58,1);
- // vars
- point pointC;
- fixed factor;
- int offsetX;
- int offsetY;
- for (factor = 0.0048828125; factor < 1.0; factor+=0.0048828125)
- {
- pointC = GetBezierValuePoint(factor,pointA,pointB);
- offsetX = FloorI(PointGetX(pointC)*dialogSize);
- offsetY = FloorI(PointGetY(pointC)*dialogSize);
- ImageSimple(dialog,DialogContainer,g,imageSize,imageSize,c_anchorBottomLeft,offsetX,offsetY,NotRelative,NoRelativeAnchor,NoTooltip,DefaultColor,image,Stretch,DefaultImageType,DefaultBlendMode,DefaultRotation);
- }
- ImageSimple(dialog,DialogContainer,g,imageSize,imageSize,c_anchorBottomLeft,0,0,NotRelative,NoRelativeAnchor,NoTooltip,DefaultColor,"Assets\\Textures\\stimsplat.dds",Stretch,DefaultImageType,DefaultBlendMode,DefaultRotation);
- ImageSimple(dialog,DialogContainer,g,imageSize,imageSize,c_anchorTopRight,0,0,NotRelative,NoRelativeAnchor,NoTooltip,DefaultColor,"Assets\\Textures\\stimsplat.dds",Stretch,DefaultImageType,DefaultBlendMode,DefaultRotation);
- }
- // It draws this image: http://i.imgur.com/2nRuB.jpg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement