Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by registered user sane4eg ( 13 years ago )
#!/usr/bin/python
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
import math


class View(QtGui.QDialog):
    def __init__(self):
        super(View, self).__init__()
        self.resize(640, 480)

        # self.timer = QtCore.QTimer(self)
        # self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.repaint)
        # self.timer.start(500)

    def paintEvent(self, QPaintEvent):
        gc = QtGui.QPainter()
        gc.begin(self)
        gc.setPen(QtGui.QColor(255, 0, 0))

        cx, cy = 320, 240  # центральная точка
        R = 50  # радиус круга
        N = 5  # количество лучшей
        S = 3  # скорость
        for t in xrange(1, N+1):
            angle = t * (360.0 / N)
            radiansPerDegree = math.pi / 180
            pointX = int(round(R * math.sin(angle * radiansPerDegree)))
            pointY = int(round(R * math.cos(angle * radiansPerDegree)))
            gc.drawPoint(pointX+cx, pointY+cy)
            vx, vy = pointX/float(cx), pointY/float(cy)  # вектор направления
            tx, ty = cx, cy
            for i in xrange(1, 300, 5):
                gc.drawPoint(tx + vx*i*S, ty + vy*i*S)  # вектор направления * скорость * время == текущее положение

        gc.end()

app = QtGui.QApplication([])
view = View()
view.show()
app.exec_()

 

Revise this Paste

Your Name: Code Language: