What just happened?

We added two kinds of properties to the element. By introducing lineWidth, we can manipulate the width of the line that visualizes the heartbeat. The points variable stores an array of already calculated function values. We initialize it to an empty array. The arg variable stores the function argument that was last evaluated. The argument of the function should be in the range from −π to +π; thus, we initialize arg to -Math.PI. Then, we add a timer that ticks in regular intervals, incrementing arg by 1° until it reaches +π, in which case it is reset to the initial value.

Changes to arg are intercepted in the handler we implement next. In there, we push a new item to the array of points. The value is calculated by the ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.