4 Replies - 754 Views - Last Post: 28 May 2012 - 04:22 PM Rate Topic: -----

#1 geertv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-February 12

How to center a cursor at the top of a line in freehand painting.

Posted 27 May 2012 - 03:10 PM

How to center a cursor at the top of a line in freehand painting.

I made a freehand painting program in Visual Basic 2010,
I used m_Graphics.FillEllipse(brush1, e.X, e.Y, 40, 40)
for painting a broad line.
It works.. But.. the cusor is not centered on the front of the broad line.
He is at the Left Top of the rectangle that describes the FillEllipse.
How can I make the cursor to stay in the middle of the front , while moving around,
so that I can more precise paint with him ?


Public Class Form1
    Private m_Drawing As Boolean
    Private m_LastX As Integer
    Private m_LastY As Integer
    Private m_Graphics As Graphics '= Graphics.FromImage(m_Bitmap)
    Private m_Bitmap As Bitmap
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        m_Bitmap = New Bitmap(300, 300)
        Me.Width = 350
        Me.Height = 400
        m_Graphics = Graphics.FromImage(m_Bitmap)
        PicCanvas.Image = m_Bitmap
        PicCanvas.Width = m_Bitmap.Width
        PicCanvas.Height = m_Bitmap.Height
        PicCanvas.Left = 12
        PicCanvas.Top = 12
    End Sub
    Private Sub PicCanvas_MouseDown(sender As Object, e As MouseEventArgs) Handles PicCanvas.MouseDown        
        m_Drawing = True
        m_LastX = e.X
        m_LastY = e.Y
    End Sub
    Private Sub PicCanvas_MouseMove(sender As Object, e As MouseEventArgs) Handles PicCanvas.MouseMove
        If m_Drawing Then
            Dim brush1 As New SolidBrush(Color.Blue)
            m_Graphics.FillEllipse(brush1, e.X, e.Y, 40, 40)
            PicCanvas.Image = m_Bitmap
            m_LastX = e.X
            m_LastY = e.Y
        End If
    End Sub
    Private Sub PicCanvas_MouseUp(sender As Object, e As MouseEventArgs) Handles PicCanvas.MouseUp
        m_Drawing = False
    End Sub
End Class





Is This A Good Question/Topic? 0
  • +

Replies To: How to center a cursor at the top of a line in freehand painting.

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8893
  • View blog
  • Posts: 33,351
  • Joined: 12-June 08

Re: How to center a cursor at the top of a line in freehand painting.

Posted 27 May 2012 - 03:16 PM

Would you attach and image so we have a better idea what you are talking about?
Was This Post Helpful? 0
  • +
  • -

#3 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: How to center a cursor at the top of a line in freehand painting.

Posted 27 May 2012 - 05:25 PM

How wide is your line?

A custom cursor with a hotpoint on another position could do if your line is less than 32 pixels.
Or you could have your line drawn with a different method. See here:
http://www.dreaminco...&#entry1581436.

Also if you have an invisible cursor and you move a small sprite with it, it could simulate the effect:
http://www.dreaminco...&#entry1592291.
Was This Post Helpful? 0
  • +
  • -

#4 geertv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-February 12

Re: How to center a cursor at the top of a line in freehand painting.

Posted 28 May 2012 - 02:23 AM

View Postmodi123_1, on 27 May 2012 - 03:16 PM, said:

Would you attach and image so we have a better idea what you are talking about?


I atatched a printscreen with th eposition of the cursor at the top of the broad line.
Was This Post Helpful? 0
  • +
  • -

#5 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 73
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: How to center a cursor at the top of a line in freehand painting.

Posted 28 May 2012 - 04:22 PM

Could you upload the picture again. It doesn't show.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1