Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
C
12345678910111213141516171819202122232425262728293031323334353637383940#pragma once#include <cstdint>
#include <list>#include "Pointer.h"// an input stream tracking a single pointer, adding other pointers (ie with different sdl ids) will be ignoredclass PointerStream { std::list<PointerEvent> rawInputs; PointerEvent initialInput; unsigned long consumedRawNanos = 0; unsigned long lastResampledNanos = 0; unsigned long lastStabilizedNanos = 0; std::list<PointerEvent> filteredInputs; unsigned long consumedFilteredNanos = 0; bool emitedDown = false; bool firstPull = false; bool cancelled = false; bool isComplete = false; // if true, no more inputs will be added, automatically set by AddInput void stats(); // prints statistics static PointerEvent findNearestEventBeforeTimestamp(std::list<PointerEvent> events, unsigned long timestamp); static PointerEvent findNearestEventAfterTimestamp(std::list<PointerEvent> events, unsigned long timestamp); void resampleTimespans(uint64_t resolutionNanos); // changes input to fit timespan distances, pulls from raw and inserts into filtered void stabilize(double alpha); // moves events to be more stabilized using an exponential moving average, recomended to resize timespans to have more/consistent events available, always uses filtered void screenToCanvas(float screenX, float screenY, float* canvasX, float* canvasY); double zoom = 1.0, panX = 0.0, panY = 0.0, rotation = 0.0, canvasWidth = 0.0, canvasHeight = 0.0;public: bool GetComplete(); PointerStream(PointerEvent input); void AddInput(PointerEvent input); void MakeCancelled(); void ApplyCanvasTranslation(double zoom, double panX, double panY, double rotation, double canvasWidth, double canvasHeight); std::list<PointerEvent> PullRawInputs(); // returns held inputs PointerEvent GetInitialInput(); PointerEvent PeekLatestInput() const; bool IsCancelled(); void PullDeltaInput(float* deltaX, float* deltaY); std::list<PointerEvent> PullFilteredInputs(uint64_t resolutionNanos, double alpha); // returns held filtered inputs, resamples and stabilizes if required static PointerStream CreatePreviewStream(double width, double height); // returns a pointerstream with a sine curve with speed and pressure being highest at the middle, has events x y in rect (0,0,width,height)};