// SPDX-License-Identifier: MIT
// Derived from Rough.js 4.0.4, Copyright (c) 2019 Preet Shihn.

package rough

import 

type dashedFiller struct {
	helper renderHelper
}

func ( *dashedFiller) ( []Point,  *ResolvedOptions) OpSet {
	 := polygonHachureLines(, )
	return OpSet{Type: OpSetFillSketch, Ops: .dashedLine(, )}
}

func ( *dashedFiller) ( []Line,  *ResolvedOptions) []Op {
	 := .DashOffset
	if  < 0 {
		if .HachureGap < 0 {
			 = .StrokeWidth * 4
		} else {
			 = .HachureGap
		}
	}
	 := .DashGap
	if  < 0 {
		if .HachureGap < 0 {
			 = .StrokeWidth * 4
		} else {
			 = .HachureGap
		}
	}
	 := make([]Op, 0)
	for ,  := range  {
		 := lineLength()
		// Hachure endpoints are integer scan-line intersections before they are
		// rotated back. Go and V8's trigonometric implementations can leave the
		// rotation-preserved length on opposite sides of an exact dash boundary
		// by one ULP (for example, 1.9999999999999998 versus 2). Snap only that
		// immediately adjacent representation so the structural Math.floor
		// decision remains stable while all non-boundary arithmetic is unchanged.
		 := math.Floor(snapOneULPToInteger( / ( + )))
		 := ( +  - *(+)) / 2
		,  := [0], [1]
		if [0] > [0] {
			,  = [1], [0]
		}
		 := math.Atan(([1] - [1]) / ([0] - [0]))
		for  := 0.0;  < ; ++ {
			 :=  * ( + )
			 :=  + 
			 := Point{
				[0] + *math.Cos() + *math.Cos(),
				[1] + *math.Sin() + *math.Sin(),
			}
			 := Point{
				[0] + *math.Cos() + *math.Cos(),
				[1] + *math.Sin() + *math.Sin(),
			}
			 = append(, .helper.doubleLineOps([0], [1], [0], [1], )...)
		}
	}
	return 
}

func snapOneULPToInteger( float64) float64 {
	 := math.Round()
	if  ==  || math.Nextafter(, ) ==  {
		return 
	}
	return 
}