[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

gregbacchus

10/16/2004 12:33:00 PM

I want to make a control onto which i can draw points (or lines), but
continuously all the previous points are fading into black at a
constant rate. I am trying to show what a laser beam moving around
would look like - emulating the optical persistance that our eyes
observe when looking at bright lights. Does anyone have any ideas on
ways of doing this?

Cheer
Greg

6 Answers

Morten Wennevik [C# MVP]

10/16/2004 3:51:00 PM

0

Hi Greg,

Create an array(list) of points or lines and set a timer to redraw each
object in the list in a darker shade. Remove black objects from the list.
(Disable timer when there are no objects)

--
Happy Coding!
Morten Wennevik [C# MVP]

Bob Powell

10/16/2004 6:29:00 PM

0

You could draw onto a bitmap and then overpaint the bitmap with a
transparent black colour. the black would accumulate obliterating everything
below it.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob''s Blog: http://bobpowelldotnet.blogspot.co...






<gregbacchus@hotmail.com> wrote in message
news:1097930000.715314.236680@c13g2000cwb.googlegroups.com...
> I want to make a control onto which i can draw points (or lines), but
> continuously all the previous points are fading into black at a
> constant rate. I am trying to show what a laser beam moving around
> would look like - emulating the optical persistance that our eyes
> observe when looking at bright lights. Does anyone have any ideas on
> ways of doing this?
>
> Cheer
> Greg
>


Bob Powell

10/16/2004 6:41:00 PM

0

Like this :-)) (after my sig)



--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob''s Blog: http://bobpowelldotnet.blogspot.co...


-------------------------------------------------------------------

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

namespace fadefun

{

/// <summary>

/// Summary description for Form1.

/// </summary>

public class Form1 : System.Windows.Forms.Form

{

Bitmap bm;

bool draw=false;

private System.Windows.Forms.Timer timer1;

private System.ComponentModel.IContainer components;

public Form1()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

this.timer1 = new System.Windows.Forms.Timer(this.components);

//

// timer1

//

this.timer1.Enabled = true;

this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 266);

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;

this.Name = "Form1";

this.Text = "Form1";

this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

protected override void OnLoad(EventArgs e)

{

bm=new Bitmap(this.ClientSize.Width,this.ClientSize.Height);

Graphics g=Graphics.FromImage(bm);

g.Clear(Color.Black);

g.Dispose();

base.OnLoad (e);

}



private void Form1_SizeChanged(object sender, System.EventArgs e)

{

bm=new Bitmap(this.ClientSize.Width,this.ClientSize.Height);

Graphics g=Graphics.FromImage(bm);

g.Clear(Color.Black);

g.Dispose();

}

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs
e)

{

if(bm!=null)

e.Graphics.DrawImageUnscaled(bm,0,0);

}

private void timer1_Tick(object sender, System.EventArgs e)

{

if(bm!=null)

{

Graphics g=Graphics.FromImage(bm);

SolidBrush sb=new SolidBrush(Color.FromArgb(40,Color.Black));

g.FillRectangle(sb,this.ClientRectangle);

g.Dispose();

Invalidate();

}

}

protected override void OnMouseDown(MouseEventArgs e)

{

draw=true;

base.OnMouseDown (e);

}

protected override void OnMouseUp(MouseEventArgs e)

{

draw=false;

base.OnMouseUp (e);

}

protected override void OnMouseMove(MouseEventArgs e)

{

if(draw && bm!=null)

{

Graphics g=Graphics.FromImage(bm);

g.FillEllipse(Brushes.Red,e.X-3,e.Y-3,6,6);

g.Dispose();

Invalidate();

}

base.OnMouseMove (e);

}



protected override void OnPaintBackground(PaintEventArgs pevent)

{


}





}

}

-------------------------------------------------------------------



<gregbacchus@hotmail.com> wrote in message
news:1097930000.715314.236680@c13g2000cwb.googlegroups.com...
> I want to make a control onto which i can draw points (or lines), but
> continuously all the previous points are fading into black at a
> constant rate. I am trying to show what a laser beam moving around
> would look like - emulating the optical persistance that our eyes
> observe when looking at bright lights. Does anyone have any ideas on
> ways of doing this?
>
> Cheer
> Greg
>


John Doe

10/16/2004 11:59:00 PM

0

Have I ever told you that you are a genious? :) That''s an absolutely
astoundingly creative solution.

Ok, I feel better. Had to get that out. :)

-----
Lee

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OmqT5$6sEHA.3200@TK2MSFTNGP09.phx.gbl...
> Like this :-)) (after my sig)
>
>
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/gdipl...
>
> The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
> Bob''s Blog: http://bobpowelldotnet.blogspot.co...
>
>
> -------------------------------------------------------------------
>
> using System;
>
> using System.Drawing;
>
> using System.Collections;
>
> using System.ComponentModel;
>
> using System.Windows.Forms;
>
> using System.Data;
>
> namespace fadefun
>
> {
>
> /// <summary>
>
> /// Summary description for Form1.
>
> /// </summary>
>
> public class Form1 : System.Windows.Forms.Form
>
> {
>
> Bitmap bm;
>
> bool draw=false;
>
> private System.Windows.Forms.Timer timer1;
>
> private System.ComponentModel.IContainer components;
>
> public Form1()
>
> {
>
> //
>
> // Required for Windows Form Designer support
>
> //
>
> InitializeComponent();
>
> //
>
> // TODO: Add any constructor code after InitializeComponent call
>
> //
>
> }
>
> /// <summary>
>
> /// Clean up any resources being used.
>
> /// </summary>
>
> protected override void Dispose( bool disposing )
>
> {
>
> if( disposing )
>
> {
>
> if (components != null)
>
> {
>
> components.Dispose();
>
> }
>
> }
>
> base.Dispose( disposing );
>
> }
>
> #region Windows Form Designer generated code
>
> /// <summary>
>
> /// Required method for Designer support - do not modify
>
> /// the contents of this method with the code editor.
>
> /// </summary>
>
> private void InitializeComponent()
>
> {
>
> this.components = new System.ComponentModel.Container();
>
> this.timer1 = new System.Windows.Forms.Timer(this.components);
>
> //
>
> // timer1
>
> //
>
> this.timer1.Enabled = true;
>
> this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
>
> //
>
> // Form1
>
> //
>
> this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
>
> this.ClientSize = new System.Drawing.Size(292, 266);
>
> this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
>
> this.Name = "Form1";
>
> this.Text = "Form1";
>
> this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
>
> this.Paint += new
> System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
>
> }
>
> #endregion
>
> /// <summary>
>
> /// The main entry point for the application.
>
> /// </summary>
>
> [STAThread]
>
> static void Main()
>
> {
>
> Application.Run(new Form1());
>
> }
>
> protected override void OnLoad(EventArgs e)
>
> {
>
> bm=new Bitmap(this.ClientSize.Width,this.ClientSize.Height);
>
> Graphics g=Graphics.FromImage(bm);
>
> g.Clear(Color.Black);
>
> g.Dispose();
>
> base.OnLoad (e);
>
> }
>
>
>
> private void Form1_SizeChanged(object sender, System.EventArgs e)
>
> {
>
> bm=new Bitmap(this.ClientSize.Width,this.ClientSize.Height);
>
> Graphics g=Graphics.FromImage(bm);
>
> g.Clear(Color.Black);
>
> g.Dispose();
>
> }
>
> private void Form1_Paint(object sender,
> System.Windows.Forms.PaintEventArgs
> e)
>
> {
>
> if(bm!=null)
>
> e.Graphics.DrawImageUnscaled(bm,0,0);
>
> }
>
> private void timer1_Tick(object sender, System.EventArgs e)
>
> {
>
> if(bm!=null)
>
> {
>
> Graphics g=Graphics.FromImage(bm);
>
> SolidBrush sb=new SolidBrush(Color.FromArgb(40,Color.Black));
>
> g.FillRectangle(sb,this.ClientRectangle);
>
> g.Dispose();
>
> Invalidate();
>
> }
>
> }
>
> protected override void OnMouseDown(MouseEventArgs e)
>
> {
>
> draw=true;
>
> base.OnMouseDown (e);
>
> }
>
> protected override void OnMouseUp(MouseEventArgs e)
>
> {
>
> draw=false;
>
> base.OnMouseUp (e);
>
> }
>
> protected override void OnMouseMove(MouseEventArgs e)
>
> {
>
> if(draw && bm!=null)
>
> {
>
> Graphics g=Graphics.FromImage(bm);
>
> g.FillEllipse(Brushes.Red,e.X-3,e.Y-3,6,6);
>
> g.Dispose();
>
> Invalidate();
>
> }
>
> base.OnMouseMove (e);
>
> }
>
>
>
> protected override void OnPaintBackground(PaintEventArgs pevent)
>
> {
>
>
> }
>
>
>
>
>
> }
>
> }
>
> -------------------------------------------------------------------
>
>
>
> <gregbacchus@hotmail.com> wrote in message
> news:1097930000.715314.236680@c13g2000cwb.googlegroups.com...
>> I want to make a control onto which i can draw points (or lines), but
>> continuously all the previous points are fading into black at a
>> constant rate. I am trying to show what a laser beam moving around
>> would look like - emulating the optical persistance that our eyes
>> observe when looking at bright lights. Does anyone have any ideas on
>> ways of doing this?
>>
>> Cheer
>> Greg
>>
>
>


Bob Powell

10/17/2004 10:30:00 AM

0

Aww shucks...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdipl...

The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tips...
Bob''s Blog: http://bobpowelldotnet.blogspot.co...






"Lee" <nobody@nowhere.com> wrote in message
news:O76dnRO7F_83KOzcRVn-vA@giganews.com...
> Have I ever told you that you are a genious? :) That''s an absolutely
> astoundingly creative solution.
>
> Ok, I feel better. Had to get that out. :)
>
> -----
> Lee
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:OmqT5$6sEHA.3200@TK2MSFTNGP09.phx.gbl...
> > Like this :-)) (after my sig)
> >
> >
> >
> > --
> > Bob Powell [MVP]
> > Visual C#, System.Drawing
> >
> > Answer those GDI+ questions with the GDI+ FAQ
> > http://www.bobpowell.net/gdipl...
> >
> > The GDI+ FAQ RSS feed: http://www.bobpowell.net/f...
> > Windows Forms Tips and Tricks RSS:
http://www.bobpowell.net/tips...
> > Bob''s Blog: http://bobpowelldotnet.blogspot.co...
> >
> >
> > -------------------------------------------------------------------
> >
> > using System;
> >
> > using System.Drawing;
> >
> > using System.Collections;
> >
> > using System.ComponentModel;
> >
> > using System.Windows.Forms;
> >
> > using System.Data;
> >
> > namespace fadefun
> >
> > {
> >
> > /// <summary>
> >
> > /// Summary description for Form1.
> >
> > /// </summary>
> >
> > public class Form1 : System.Windows.Forms.Form
> >
> > {
> >
> > Bitmap bm;
> >
> > bool draw=false;
> >
> > private System.Windows.Forms.Timer timer1;
> >
> > private System.ComponentModel.IContainer components;
> >
> > public Form1()
> >
> > {
> >
> > //
> >
> > // Required for Windows Form Designer support
> >
> > //
> >
> > InitializeComponent();
> >
> > //
> >
> > // TODO: Add any constructor code after InitializeComponent call
> >
> > //
> >
> > }
> >
> > /// <summary>
> >
> > /// Clean up any resources being used.
> >
> > /// </summary>
> >
> > protected override void Dispose( bool disposing )
> >
> > {
> >
> > if( disposing )
> >
> > {
> >
> > if (components != null)
> >
> > {
> >
> > components.Dispose();
> >
> > }
> >
> > }
> >
> > base.Dispose( disposing );
> >
> > }
> >
> > #region Windows Form Designer generated code
> >
> > /// <summary>
> >
> > /// Required method for Designer support - do not modify
> >
> > /// the contents of this method with the code editor.
> >
> > /// </summary>
> >
> > private void InitializeComponent()
> >
> > {
> >
> > this.components = new System.ComponentModel.Container();
> >
> > this.timer1 = new System.Windows.Forms.Timer(this.components);
> >
> > //
> >
> > // timer1
> >
> > //
> >
> > this.timer1.Enabled = true;
> >
> > this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
> >
> > //
> >
> > // Form1
> >
> > //
> >
> > this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
> >
> > this.ClientSize = new System.Drawing.Size(292, 266);
> >
> > this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
> >
> > this.Name = "Form1";
> >
> > this.Text = "Form1";
> >
> > this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
> >
> > this.Paint += new
> > System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
> >
> > }
> >
> > #endregion
> >
> > /// <summary>
> >
> > /// The main entry point for the application.
> >
> > /// </summary>
> >
> > [STAThread]
> >
> > static void Main()
> >
> > {
> >
> > Application.Run(new Form1());
> >
> > }
> >
> > protected override void OnLoad(EventArgs e)
> >
> > {
> >
> > bm=new Bitmap(this.ClientSize.Width,this.ClientSize.Height);
> >
> > Graphics g=Graphics.FromImage(bm);
> >
> > g.Clear(Color.Black);
> >
> > g.Dispose();
> >
> > base.OnLoad (e);
> >
> > }
> >
> >
> >
> > private void Form1_SizeChanged(object sender, System.EventArgs e)
> >
> > {
> >
> > bm=new Bitmap(this.ClientSize.Width,this.ClientSize.Height);
> >
> > Graphics g=Graphics.FromImage(bm);
> >
> > g.Clear(Color.Black);
> >
> > g.Dispose();
> >
> > }
> >
> > private void Form1_Paint(object sender,
> > System.Windows.Forms.PaintEventArgs
> > e)
> >
> > {
> >
> > if(bm!=null)
> >
> > e.Graphics.DrawImageUnscaled(bm,0,0);
> >
> > }
> >
> > private void timer1_Tick(object sender, System.EventArgs e)
> >
> > {
> >
> > if(bm!=null)
> >
> > {
> >
> > Graphics g=Graphics.FromImage(bm);
> >
> > SolidBrush sb=new SolidBrush(Color.FromArgb(40,Color.Black));
> >
> > g.FillRectangle(sb,this.ClientRectangle);
> >
> > g.Dispose();
> >
> > Invalidate();
> >
> > }
> >
> > }
> >
> > protected override void OnMouseDown(MouseEventArgs e)
> >
> > {
> >
> > draw=true;
> >
> > base.OnMouseDown (e);
> >
> > }
> >
> > protected override void OnMouseUp(MouseEventArgs e)
> >
> > {
> >
> > draw=false;
> >
> > base.OnMouseUp (e);
> >
> > }
> >
> > protected override void OnMouseMove(MouseEventArgs e)
> >
> > {
> >
> > if(draw && bm!=null)
> >
> > {
> >
> > Graphics g=Graphics.FromImage(bm);
> >
> > g.FillEllipse(Brushes.Red,e.X-3,e.Y-3,6,6);
> >
> > g.Dispose();
> >
> > Invalidate();
> >
> > }
> >
> > base.OnMouseMove (e);
> >
> > }
> >
> >
> >
> > protected override void OnPaintBackground(PaintEventArgs pevent)
> >
> > {
> >
> >
> > }
> >
> >
> >
> >
> >
> > }
> >
> > }
> >
> > -------------------------------------------------------------------
> >
> >
> >
> > <gregbacchus@hotmail.com> wrote in message
> > news:1097930000.715314.236680@c13g2000cwb.googlegroups.com...
> >> I want to make a control onto which i can draw points (or lines), but
> >> continuously all the previous points are fading into black at a
> >> constant rate. I am trying to show what a laser beam moving around
> >> would look like - emulating the optical persistance that our eyes
> >> observe when looking at bright lights. Does anyone have any ideas on
> >> ways of doing this?
> >>
> >> Cheer
> >> Greg
> >>
> >
> >
>
>


gregbacchus

10/18/2004 4:11:00 AM

0

Nice one. Cheers :)