请问一个关于GDI+的问题 先得到中点, 用TranslateTransform将原点设为该点, 再调用RotateTransform 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先用TranslateTransform把原点移到图形的中心,再用RotateTransform旋转,知道仿射变换吗,知道的话可以直接设Transform属性用Matrix,可以看一下C# wndows 程序设计,charles petzold写得,里面有一章介绍了 假如x,y是中心点,grfx.TranslateTransform(x,y)是不是就是将原点移到中心点?; 这个好像不是这样的吧,楼上说的书我也有,不过给的例子都是没有绕中心旋转的,而是绕屏幕中心旋转的,grfx.TranslateTransform(x,y)移动后,还是围绕一个点发散似的旋转,而不是绕中心旋转的. 我猜你想做个时钟控件吧。可以参考这个:http://www.thecodeproject.com/cs/miscctrl/clock.asp?target=clockhttp://www.thecodeproject.com/useritems/simpleclock.asp?target=clock即使你不是做时钟控件,同样对你的问题有效。 http://www.thecodeproject.com/useritems/simpleclock.asp?target=clock to 假如x,y是中心点,grfx.TranslateTransform(x,y)是不是就是将原点移到中心点?;要确保这一点, 在此句之前调用ResetTransform grfx.DrawLine(new Pen(Color.Red),20,20,80,20);grfx.ResetTransform();grfx.TranslateTransform(50,20);grfx.RotateTransform(20);grfx.DrawLine(new Pen(Color.Red),20,20,80,20);这个效果吗,两条线段并不是中心相交的,我不是要实现时钟,时钟是绕某一点放射旋转的,我要的是绕图形本身的中点旋转形成中心相交的线段 grfx.TranslateTransform(50,20);grfx.RotateTransform(20);grfx.TranslateTransform(-50,-20);grfx.DrawLine(new Pen(Color.Red),20,20,80,20); 不回吧, 兄弟! 这是我测试用的代码, 你试试看protected override void OnPaint(PaintEventArgs e){ Graphics grfx = e.Graphics; grfx.DrawLine(new Pen(Color.Red),20,20,80,20); Rectangle r = new Rectangle(50, 20, 0, 0); r.Inflate(1, 1); grfx.DrawRectangle(Pens.Black, r); grfx.TranslateTransform(50,20); grfx.RotateTransform(45); grfx.TranslateTransform(-50,-20); grfx.DrawLine(new Pen(Color.Red),20,20,80,20);} to cheng_young(古道西风瘦马) 我还是那样的结果,你可以将完整程序发给我吗? //csc test.csusing System; using System.Windows.Forms;using System.Drawing;using System.Drawing.Drawing2D;class Test : Form{ Test() { } protected override void OnPaint(PaintEventArgs e) { Graphics grfx = e.Graphics; grfx.DrawLine(new Pen(Color.Red),20,20,80,20); Rectangle r = new Rectangle(50, 20, 0, 0); r.Inflate(1, 1); grfx.DrawRectangle(Pens.Black, r); grfx.TranslateTransform(50,20); grfx.RotateTransform(45); grfx.TranslateTransform(-50,-20); grfx.DrawLine(new Pen(Color.Red),20,20,80,20); } static public void Main() { Application.Run(new Test()); }} 问个linq问题 关于线程的问题 c#调用c++dll的问题 快速解决。。。。 录制视频文件 SqlDataReader 没有被关闭的问题 如何才能控制form中的控件的大小和位置不发生变化? 菜鸟问题,大家都来看看.... 求助,看看怎样写? 如何将word文件转换成tif格式文件? 用remoting时delegate不起作用 刷新语句怎么写?
http://www.thecodeproject.com/cs/miscctrl/clock.asp?target=clock
http://www.thecodeproject.com/useritems/simpleclock.asp?target=clock即使你不是做时钟控件,同样对你的问题有效。
grfx.TranslateTransform(50,20);
grfx.RotateTransform(20);
grfx.DrawLine(new Pen(Color.Red),20,20,80,20);
这个效果吗,两条线段并不是中心相交的,我不是要实现时钟,时钟是绕
某一点放射旋转的,我要的是绕图形本身的中点旋转形成中心相交的线段
grfx.RotateTransform(20);
grfx.TranslateTransform(-50,-20);
grfx.DrawLine(new Pen(Color.Red),20,20,80,20);
protected override void OnPaint(PaintEventArgs e)
{
Graphics grfx = e.Graphics;
grfx.DrawLine(new Pen(Color.Red),20,20,80,20);
Rectangle r = new Rectangle(50, 20, 0, 0);
r.Inflate(1, 1);
grfx.DrawRectangle(Pens.Black, r); grfx.TranslateTransform(50,20);
grfx.RotateTransform(45);
grfx.TranslateTransform(-50,-20);
grfx.DrawLine(new Pen(Color.Red),20,20,80,20);
}
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;class Test : Form
{
Test()
{
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics grfx = e.Graphics;
grfx.DrawLine(new Pen(Color.Red),20,20,80,20);
Rectangle r = new Rectangle(50, 20, 0, 0);
r.Inflate(1, 1);
grfx.DrawRectangle(Pens.Black, r); grfx.TranslateTransform(50,20);
grfx.RotateTransform(45);
grfx.TranslateTransform(-50,-20);
grfx.DrawLine(new Pen(Color.Red),20,20,80,20);
}
static public void Main()
{
Application.Run(new Test());
}
}