WEB开发网
开发学院WEB开发ASP.NET C#中实现文字按指定的路径排列 阅读

C#中实现文字按指定的路径排列

 2012-08-28 13:18:15 来源:WEB开发网   
核心提示:id = (int)(_height + _height);do{if (lStep == _stepWitdth){_tmpPoints[lCount].X = _p1.X;_tmpPoints[lCount].Y = _p1.Y;lCount += 1;}else{lStep += _stepWitdth;}if
id = (int)(_height + _height);

do
{
if (lStep == _stepWitdth)
{
_tmpPoints[lCount].X = _p1.X;
_tmpPoints[lCount].Y = _p1.Y;
lCount += 1;
}
else
{
lStep += _stepWitdth;
}
if (Convert.ToInt32(_p1.X) == Convert.ToInt32(_p2.X))
break;

_p1.X += ix;
d += id;

if (d > _width)
{
_p1.Y += iy;
d -= dd;
}
} while (true);


}
else
{
dd = (int)(_height + _height);
id = (int)(_width + _width);

do
{
if (lStep == _stepWitdth)
{
_tmpPoints[lCount].X = _p1.X;
_tmpPoints[lCount].Y = _p1.Y;
lCount += 1;
}
else
{
lStep += _stepWitdth;
}
if (Convert.ToInt32(_p1.Y) == Convert.ToInt32(_p2.Y))
break; // TODO: might not be correct. Was : Exit Do
_p1.Y += iy;
d += id;

if (d > _height)
{
_p1.X += ix;
d -= dd;
}
} while (true);
}

PointF[] _tmpPoints2 = null;
_tmpPoints2 = new PointF[lCount + 1];
Array.Copy(_tmpPoints, _tmpPoints2, lCount);
return _tmpPoints2;
}
}
}

下为测试部分的核心源代码:

PointF[] _points = new PointF[8];
TextOnPath _top = new TextOnPath();

//初始化的相关代码:

_points[0] = new PointF(303, 485);
_points[1] = new PointF(476, 616);
_points[2] = new PointF(745, 599);
_points[3] = new PointF(876, 434);
_points[4] = new PointF(829, 179);
_points[5] = new PointF(657, 73);
_points[6] = new PointF(518, 269);
_points[7] = new PointF(308, 349);

_top.FontTOP = new Font("楷体_GB2312", 48, FontStyle.Bold);
_top.FillColorTOP = Color.Red;
_top.ColorTOP = Color.Black;
_top.TextTOP = "龙岗民生网http://www.lgms.net";
_top.ShowPath = true;
_top.PathAlignTOP = PathAlign.Left;
_top.LetterSpacePercentage = 80;
_top.TextPathPosition = TextPosition.OverPath;

//关键的调用方法:
private Image DrawText()
{
GraphicsPath _gp = new GraphicsPath();
_gp.AddClosedCurve(_points);

_top.PathDataTOP = _gp.PathData;

return _top.TextOnPathBitmap();
}

在相应地方加上DrawText()即可。

上一页  1 2 3 4 5 

Tags:实现 文字 指定

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接