Release v0.6.54: adjustable pencil smoothing and unsaved settings state

This commit is contained in:
agrynco committed 2026-11-06 14:46:53 +02:00
1 parent 727dc96908
commit 63b7b879a3
14 files changed
+318 -18

No files matched your search

+27
View File
@@ -122,4 +122,31 @@ inline void testStrokeImprovement() {
double deviation=0; for(auto p:smooth) deviation+=std::abs(p.y-100);
require(deviation/smooth.size()<1.5 && smooth.front().y==jitter.front().y && smooth.back().y==jitter.back().y,
"smoothing reduces jitter and preserves endpoints");
auto equal=[](const auto &a,const auto &b){return a.size()==b.size() && std::equal(a.begin(),a.end(),b.begin(),
[](POINT x,POINT y){return x.x==y.x && x.y==y.y;});};
require(equal(ks::smoothScreenshotStroke(jitter,0),jitter),"zero smoothing preserves exact mouse samples");
std::vector<POINT> waves;
for(int i=0;i<=200;++i) waves.push_back({30+i,100+LONG(std::lround(6*std::sin(i*.5)))});
auto roughness=[](const auto &p){double total=0; for(size_t i=1;i<p.size();++i) total+=std::abs(p[i].y-p[i-1].y); return total;};
auto low=ks::smoothScreenshotStroke(waves,25),high=ks::smoothScreenshotStroke(waves,100);
require(roughness(high)<roughness(low) && roughness(low)<roughness(waves),"higher smoothing removes more jitter");
require(high.front().x==waves.front().x && high.front().y==waves.front().y &&
high.back().x==waves.back().x && high.back().y==waves.back().y,"smoothing preserves both endpoints");
ks::ScreenshotMark mark{waves.front(),waves.back(),0}; mark.freehand=true; mark.points=waves;
ks::setScreenshotSmoothing(mark,100); ks::setScreenshotSmoothing(mark,25);
require(equal(mark.points,low),"lowering smoothing recomputes from original instead of accumulating filters");
ks::setScreenshotSmoothing(mark,0);
require(equal(mark.points,waves),"zero restores original after multiple adjustments");
ks::setScreenshotSmoothing(mark,100);
auto moved=ks::dragScreenshotMark(mark,ks::MarkPart::Body,{0,0},{10,15},500,500);
ks::setScreenshotSmoothing(moved,0);
require(moved.points[40].x==waves[40].x+10 && moved.points[40].y==waves[40].y+15,
"moving preserves the original path in moved coordinates");
auto resized=ks::dragScreenshotMark(mark,ks::MarkPart::End,mark.to,{260,130},500,500);
ks::setScreenshotSmoothing(resized,0);
require(resized.points.back().x==260 && resized.points.back().y==130,"endpoint editing survives smoothing changes");
auto duplicate=ks::cloneScreenshotMark(mark,{mark},500,500);
ks::setScreenshotSmoothing(duplicate,0);
require(duplicate.points[40].x==waves[40].x+16 && duplicate.points[40].y==waves[40].y+16,
"cloning retains independent original geometry");
}