Example #1
0
        ///////////////////////////////////////////////Method\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

        /************************************************************************************************
        * Method: Wanderer()
        * Effect: Receives an object of strucure when thread is started. A random color will be chosen,
        *         and will draw pixels based on a random direction/velocity.
        * **********************************************************************************************/
        public static void Wanderer(object holder)
        {
            DrawingData info         = (DrawingData)(holder); //Unboxes structure
            Color       drawingColor = RandColor.GetColor();  //Holds random color for drawing
            Point       newPoint     = info.m_pCoor;

            drawSpace.SetBBScaledPixel(info.m_pCoor.X, info.m_pCoor.Y, drawingColor);
            drawSpace.Render();


            //Draw pixels
            for (int i = 0; i < info.m_iPixels; i++)
            {
                newPoint.X += rnd.Next(-1, 2);
                newPoint.Y += rnd.Next(-1, 2);
                newPoint.X  = (newPoint.X < 0) ? 0 : newPoint.X;
                newPoint.Y  = (newPoint.Y < 0) ? 0 : newPoint.Y;
                newPoint.X  = (newPoint.X > 799) ? 799 : newPoint.X;
                newPoint.Y  = (newPoint.Y > 599) ? 599 : newPoint.Y;

                drawSpace.SetBBScaledPixel(newPoint.X, newPoint.Y, drawingColor);
                Thread.Sleep(1);
                drawSpace.Render();
            }


            //lock gdi drawer during loop
        }
Example #2
0
        //When Timer tick occurs
        private void UI_Timer1_Tick(object sender, EventArgs e)
        {
            drawSpace.GetLastMouseLeftClickScaled(out getPoint);
            //Periodically check mouse in drawer window
            if (getPoint != lastPoint && getPoint.X >= 0)
            {
                lastPoint = getPoint;
                //Create new thread

                //Apply method
                DrawingData newData = new DrawingData(getPoint, numPixels);
                Wanderer((object)newData); //pass to wanderer method
            }
        }