|
|
|
@ -91,8 +91,8 @@ function process_stroke(state, zoom, stroke) {
@@ -91,8 +91,8 @@ function process_stroke(state, zoom, stroke) {
|
|
|
|
|
return npoints; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function rdp_find_max2(points, start, end) { |
|
|
|
|
const EPS = 0.25; |
|
|
|
|
function rdp_find_max2(zoom, points, start, end) { |
|
|
|
|
const EPS = 1.0 / zoom; |
|
|
|
|
|
|
|
|
|
let result = -1; |
|
|
|
|
let max_dist = 0; |
|
|
|
@ -119,7 +119,7 @@ function rdp_find_max2(points, start, end) {
@@ -119,7 +119,7 @@ function rdp_find_max2(points, start, end) {
|
|
|
|
|
const x = rx + a.x; |
|
|
|
|
const y = ry + a.y; |
|
|
|
|
|
|
|
|
|
const dist = Math.abs(y - a.y); |
|
|
|
|
const dist = Math.abs(y - a.y) + Math.abs(a.pressure - p.pressure) / 255 + Math.abs(b.pressure - p.pressure) / 255; |
|
|
|
|
|
|
|
|
|
if (dist > EPS && dist > max_dist) { |
|
|
|
|
result = i; |
|
|
|
@ -130,30 +130,30 @@ function rdp_find_max2(points, start, end) {
@@ -130,30 +130,30 @@ function rdp_find_max2(points, start, end) {
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function process_rdp_r2(points, start, end) { |
|
|
|
|
function process_rdp_r2(zoom, points, start, end) { |
|
|
|
|
let result = []; |
|
|
|
|
|
|
|
|
|
const max = rdp_find_max2(points, start, end); |
|
|
|
|
const max = rdp_find_max2(zoom, points, start, end); |
|
|
|
|
|
|
|
|
|
if (max !== -1) { |
|
|
|
|
const before = process_rdp_r2(points, start, max); |
|
|
|
|
const after = process_rdp_r2(points, max, end); |
|
|
|
|
const before = process_rdp_r2(zoom, points, start, max); |
|
|
|
|
const after = process_rdp_r2(zoom, points, max, end); |
|
|
|
|
result = [...before, points[max], ...after]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function process_rdp2(points) { |
|
|
|
|
const result = process_rdp_r2(points, 0, points.length - 1); |
|
|
|
|
function process_rdp2(zoom, points) { |
|
|
|
|
const result = process_rdp_r2(zoom, points, 0, points.length - 1); |
|
|
|
|
result.unshift(points[0]); |
|
|
|
|
result.push(points[points.length - 1]); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: unify with regular process stroke
|
|
|
|
|
function process_stroke2(points) { |
|
|
|
|
const result = process_rdp2(points); |
|
|
|
|
function process_stroke2(zoom, points) { |
|
|
|
|
const result = process_rdp2(zoom, points); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|