Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Rotating Image boxes and graphics.draw?


  • Please log in to reply
1 reply to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:00 AM

Posted 08 January 2009 - 03:56 PM

Hi,

i want to be able to use somthing like this:

PictureBox1.CreateGraphics.FillRectangle(Brushes.Yellow, 0, 0, 5, 10)

But rotated 30 degrees? Is this possible and i am not very good at math and all other examples in volve Triggannomatry and SIN, COS and TAN which i do not understand atall.

Any help would be greatly apprechated, Thanks, Wolfy87.

BC AdBot (Login to Remove)

 


#2 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:11:00 AM

Posted 10 January 2009 - 06:20 AM

Dont worry, i have got it to work, heres my code if you are interested:

Private Sub PictureBox1_Paint(ByVal sender As Object, _
		ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
		'Define a point at the centre of the PictureBox: 
		Dim p As New Point(PictureBox1.Width / 2, PictureBox1.Height / 2)
		'Create a matrix: 
		Dim mtx As New Drawing2D.Matrix
		'Rotate the matrix 30 degrees clockwise around point p:
		mtx.RotateAt(30, p)
		'Apply the matrix to the graphics object:
		e.Graphics.Transform = mtx
		'Now draw the rectangle:
		e.Graphics.FillRectangle(Brushes.Yellow, p.X - 20, p.Y - 30, 40, 60)
	End Sub

This code produses a yellow rectangle rotated 30 degrees clockwise. All praise must go too boops boops, for he is the auther of this code.

Regards, Wolfy87.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users