PDA

View Full Version : سوال: کمک در مورد رسم دایره با پیکسل ها



kamran_14
جمعه 19 اسفند 1390, 01:38 صبح
سلام
این برنامه ی دراز و طولانی فقط یک نقطه می ذاره آیا برای گذاشتن یک نقطه این همه کار لازمه؟می شه در رسم دایره کمکم کنید؟
این کد را در داخل کلاسی با نام GD می نویسیم


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace GD1
{
class GD
{
public Device device3d;
public PresentParameters pp;
public GD(Form1 frm)
{
pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
device3d = new Device(0, DeviceType.Hardware, frm, CreateFlags.SoftwareVertexProcessing, pp);
}
}
}

و این کدها را هم در فرم اصلی برنامه می نویسم


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace GD1
{
public partial class Form1 : Form
{
GD gi;
CustomVertex.TransformedColored v;
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.Opaque, true);
gi = new GD(this);
v = new CustomVertex.TransformedColored(100, 300, 0, 1, Color.Yellow.ToArgb());

}
protected override void OnPaint(PaintEventArgs e)
{
gi.device3d.Clear(ClearFlags.Target, Color.Black, 1, 0);
gi.device3d.BeginScene();
gi.device3d.VertexFormat = CustomVertex.TransformedColored.Format;
for (int i = 1; i <= 7;i++ )
gi.device3d.DrawUserPrimitives(PrimitiveType.Point List, 1, v);
gi.device3d.EndScene();
gi.device3d.Present();
Invalidate();
}
}
}