图形处理 有个多边形数组点 可能画出一个多边形 能否在这个数组点基础上实现向外或向内一个像素 画出一个同样的多边形 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在弄一个组坐标,坐标值向里收一个像素就行了,比如现在x=5,那么新的的就是x=6,或x=4,看具体方向了 可以 .o.....a... ..b .c通过ab两点及o点,可以确定ab夹角的大小,从而可以画出c,那么向内的点必定在c上,同理从其他各个点也可以求出其他的各两边之间的中心线,必有一交点。从各个起始点(此处o点),按一定的比例向内或外延伸,连接所有在类c上的点即可 可以使用矩阵的乘法来做,比如一个矩阵{m11,m12,n11,n12,z11,z12},其中m11,n12表示缩放,m12,n11表示旋转,z11,z12表示平移,图形中的每个点的坐标乘这个矩阵。 class CustomButton : UIElement { VisualCollection childs; DrawingVisual dvrectangle = new DrawingVisual(); DrawingContext dcrectangle; int i = 0; Brush bl = Brushes.Blue; Brush w = new RadialGradientBrush(Colors.White, Colors.Red); Brush bb = new RadialGradientBrush(Colors.Yellow, Colors.Blue); Pen p = new Pen(Brushes.Yellow, 3); MatrixTransform mt = new MatrixTransform(); System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-cn");//FormattedText字体参数 FlowDirection fd = FlowDirection.LeftToRight;//FormattedText字体参数 Typeface tf = new Typeface("宋体");//FormattedText字体参数 double d = 25;//FormattedText字体参数 FormattedText ft; public CustomButton(string s) { bl.Freeze(); w.Freeze(); p.Freeze(); ft = new FormattedText(s, ci, fd, tf, d, w); double fk = ft.Width; double fh = ft.Height; childs = new VisualCollection(this); dcrectangle = dvrectangle.RenderOpen(); dcrectangle.DrawEllipse(bb, p, new Point(40, 40), 40, 40); dcrectangle.DrawText(ft, new Point(40 - fk / 2, 40 - fh / 2)); dcrectangle.Close(); dvrectangle.Transform = mt; childs.Add(dvrectangle); CompositionTarget.Rendering += CompositionTarget_Rendering; } public void CompositionTarget_Rendering(object sender, EventArgs e) { double n11 = (Math.Sin(i * 0.2) * 0.2 + 1); double m11 = Math.Cos(i * 0.01) * n11; double m12 = Math.Sin(i * 0.01) * n11; mt.Matrix = new Matrix(m11, m12, -m12, m11, 40 * (1 - m11 + m12), 40 * (1 - m12 - m11)); i++; } protected override int VisualChildrenCount { get { return childs.Count; } } protected override Visual GetVisualChild(int index) { if (index < 0 || index >= childs.Count) { throw new ArgumentOutOfRangeException(); } return childs[index]; } }这是我用WPF做的一个旋转的同时不断缩放的按钮,里面的旋转和缩放都是通过坐标乘一个矩阵来做的。 XML文件多层节点读取问题.[在线等,解决后马上给分,谢谢大家] Intptr的释放问题 请问大家怎么样通过C#清空AD中一个帐户隶属的所有组? 菜鸟发问,高手请进(关于datagrid和数据库) 请问在DataTable.ColumnChanged事件下,怎么才能让光标不离开? 问一下如何使用C#,来清空剪切板? 再问一个.Net服务器配置的问题 求救timer控制使用问题,分不多,帮帮忙吧 请教各位两个方向性的问题 C#阈值分割处理图像 关于SQL数据库中删除记录后标志列的排序问题 做过触摸屏应用的同行请解答,谢谢
.o.....a
..
. .
.b .c
通过ab两点及o点,可以确定ab夹角的大小,从而可以画出c,那么向内的点必定在c上,同理从其他各个点也可以求出其他的各两边之间的中心线,必有一交点。
从各个起始点(此处o点),按一定的比例向内或外延伸,连接所有在类c上的点即可
class CustomButton : UIElement
{
VisualCollection childs;
DrawingVisual dvrectangle = new DrawingVisual();
DrawingContext dcrectangle;
int i = 0;
Brush bl = Brushes.Blue;
Brush w = new RadialGradientBrush(Colors.White, Colors.Red);
Brush bb = new RadialGradientBrush(Colors.Yellow, Colors.Blue);
Pen p = new Pen(Brushes.Yellow, 3);
MatrixTransform mt = new MatrixTransform();
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-cn");//FormattedText字体参数
FlowDirection fd = FlowDirection.LeftToRight;//FormattedText字体参数
Typeface tf = new Typeface("宋体");//FormattedText字体参数
double d = 25;//FormattedText字体参数
FormattedText ft;
public CustomButton(string s)
{
bl.Freeze();
w.Freeze();
p.Freeze();
ft = new FormattedText(s, ci, fd, tf, d, w);
double fk = ft.Width;
double fh = ft.Height;
childs = new VisualCollection(this);
dcrectangle = dvrectangle.RenderOpen();
dcrectangle.DrawEllipse(bb, p, new Point(40, 40), 40, 40);
dcrectangle.DrawText(ft, new Point(40 - fk / 2, 40 - fh / 2));
dcrectangle.Close();
dvrectangle.Transform = mt;
childs.Add(dvrectangle);
CompositionTarget.Rendering += CompositionTarget_Rendering;
}
public void CompositionTarget_Rendering(object sender, EventArgs e)
{
double n11 = (Math.Sin(i * 0.2) * 0.2 + 1);
double m11 = Math.Cos(i * 0.01) * n11;
double m12 = Math.Sin(i * 0.01) * n11;
mt.Matrix = new Matrix(m11, m12, -m12, m11, 40 * (1 - m11 + m12), 40 * (1 - m12 - m11));
i++;
}
protected override int VisualChildrenCount
{
get { return childs.Count; }
}
protected override Visual GetVisualChild(int index)
{
if (index < 0 || index >= childs.Count)
{
throw new ArgumentOutOfRangeException();
}
return childs[index];
}
}这是我用WPF做的一个旋转的同时不断缩放的按钮,里面的旋转和缩放都是通过坐标乘一个矩阵来做的。