Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace _06_Hodiny
- {
- public partial class Form1 : Form
- {
- Thread thread;
- Graphics graphics01;
- Graphics graphics02;
- Bitmap bitmap;
- bool drawing = true;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- bitmap = new Bitmap(580, 580);
- graphics01 = Graphics.FromImage(bitmap);
- graphics02 = CreateGraphics();
- thread = new Thread(Draw);
- thread.IsBackground = true;
- thread.Start();
- //graphics01.RotateTransform(-99);
- //graphics02.RotateTransform(-99);
- }
- public void Draw()
- {
- float angle = 0.0f;
- float angleM = 0.0f;
- float angleH = 0.0f;
- PointF pointF = new PointF(250, 250);
- float rad = 250;
- Pen pen = new Pen(Color.Azure, 3.0f);
- RectangleF area = new RectangleF(30, 30, 500, 500);
- RectangleF circle = new RectangleF(0, 0, 50, 50);
- RectangleF circleM = new RectangleF(0, 0, 50, 50);
- RectangleF circleH = new RectangleF(0, 0, 50, 50);
- PointF loc = PointF.Empty;
- PointF img = new PointF(20, 20);
- graphics02.Clear(Color.Black);
- while (drawing)
- {
- graphics01.Clear(Color.Black);
- graphics01.DrawEllipse(pen, area);
- loc = CirclePoint(rad, angle, pointF);
- circle.X = loc.X - (circle.Width / 2) + area.X;
- circle.Y = loc.Y - (circle.Height / 2) + area.Y;
- loc = CirclePoint(rad, angleM, pointF);
- circleM.X = loc.X - (circleM.Width / 2) + area.X;
- circleM.Y = loc.Y - (circleM.Height / 2) + area.Y;
- loc = CirclePoint(rad, angleH, pointF);
- circleH.X = loc.X - (circleH.Width / 2) + area.X;
- circleH.Y = loc.Y - (circleH.Height / 2) + area.Y;
- //graphics01.DrawEllipse(pen, circle);
- graphics01.DrawLine(pen, 275, 275, circle.X + 25, circle.Y + 25);
- graphics01.DrawLine(pen, 275, 275, circleM.X + 25, circleM.Y + 25);
- graphics01.DrawLine(pen, 275, 275, circleH.X + 25, circleH.Y + 25);
- graphics02.DrawImage(bitmap, img);
- if (angle < 360)
- {
- angle += 6;
- }
- else if (angle == 360)
- {
- angle = 0;
- angleM += 6;
- }
- else if (angleM == 360)
- {
- angleM = 0;
- angleH += 6;
- }
- else if (angleH == 360)
- {
- angleH = 0;
- }
- Thread.Sleep(1000);
- }
- }
- public PointF CirclePoint(float radius, float angleIsDangre, PointF original)
- {
- float x = (float)(radius * Math.Cos(angleIsDangre * Math.PI / 180F)) + original.X;
- float y = (float)(radius * Math.Sin(angleIsDangre * Math.PI / 180F)) + original.Y;
- return new PointF(x, y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement