typedef struct
{
float x
float y
}Point2D
void ComputeBezier (Point2D *cp, int numberOfPoints, Point2D *curve)
int main(int argc, const char * argv[])
{
Point2D cp[] = {{10,100},{30,20},{120,20},{200,100}}
int number = 100
Point2D curve[number]
ComputeBezier(cp, number, curve)//因为是数组,所以不用加星号。
for (int i=0i<numberi++) {
printf("curve[%d].x=%f,curve[%d].y=%f\n",i,curve[i].x,i,curve[i].y)
}
return 0
}
Point2D PointOnCubicBezier (Point2D *cp, float t)
{
float ax, bx, cx
float ay, by, cy
float tSquared, tCubed
Point2D result
/*计算多项式系数*/
cx = 3.0 * (cp[1].x - cp[0].x)
bx = 3.0 * (cp[2].x - cp[1].x) - cx
ax = cp[3].x - cp[0].x - cx - bx
cy = 3.0 * (cp[1].y - cp[0].y)
by = 3.0 * (cp[2].y - cp[1].y) - cy
ay = cp[3].y - cp[0].y - cy - by
/*计算位於参数值t的曲线点*
tSquared = t * t
tCubed = tSquared * t
result.x = (ax * tCubed) + (bx * tSquared) + (cx * t) + cp[0].x
result.y = (ay * tCubed) + (by * tSquared) + (cy * t) + cp[0].y
return result
void ComputeBezier (Point2D *cp, int numberOfPoints, Point2D *curve)
float dt
int i
dt = 1.0 / ( numberOfPoints - 1 )
for( i = 0i <numberOfPointsi++)
curve[i] = PointOnCubicBezier( cp, i*dt )
}
新建一个c工程可以直接运行。
调用:<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.bxslider.js"></script>
$(function(){
$('#marquee').bxSlider({
mode:'vertical', //默认的是水平
displaySlideQty:1,//显示li的个数
moveSlideQty: 1,//移动li的个数
captions: true,//自动控制
auto: true,
controls: false//隐藏左右按钮
})
})
<div style="width:450pxheight:296pxfloat:leftoverflow:hiddenmargin-left:200px">
<ul id="marquee">
<li><img src="img/1.jpg" alt="banner_腋臭" style="width:450pxheight:296px"></li>
<li><img src="img/2.jpg" alt="banner_腋臭" style="width:450pxheight:296px"></li>
</ul>
</div>
.bx-prev{ width:12pxheight:26pxbackground:#f00text-indent: -999999pxz-index: 999 position: absolutefloat:leftleft:455pxtop:110px}
.bx-next{ width:12pxheight:26px background:#f00text-indent: -999999pxz-index: 999 position: absolutetop:110pxleft:-15px}
<?php
$content = <<<EOF
<link rel="stylesheet" type="text/css" href="/css/reset.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="shortcut icon" href="favicon.ico">
<link rel="shortcut icon" href="favicon.png">
<script type="text/javascript" src="/js/main.js"></script>
<script type="text/javascript" src="/js/jquery.bxslider.js"></script>
EOF
preg_match_all('/(?:href|src)="(.*?[css|js])"/', $content, $matchs)
var_dump($matchs)