package d2isometricimg

import (
	

	
)

// Explicit paints keep their authored meaning. Otherwise a stable muted hue
// helps follow an individual route through a bundle without depending on scene
// traversal order or introducing a new semantic grouping.
func nativeRouteTint( d2isometric.Edge) string {
	if .StrokeExplicit {
		return .Stroke
	}
	 := [...]string{"#3d6d8f", "#36776b", "#786391", "#957245", "#586d86", "#8c606b"}
	 := fnv.New32a()
	_, _ = .Write([]byte(.ID))
	return [int(.Sum32())%len()]
}

func nativeRouteRadius( d2isometric.Edge) float64 {
	return max(.012, min(.075, float64(.StrokeWidth)*.012))
}

// Diagram ink is a flat, unlit ribbon. Its authored path and any crossing
// bridge remain in three dimensions, while illumination cannot change the
// perceived color or weight of the stroke with its direction.
func ( *meshBuilder) ( []Vec,  float64,  *Material) {
	if len() < 2 ||  <= 0 {
		return
	}
	,  := make([]Vertex, len()), make([]Vertex, len())
	for ,  := range  {
		,  := [max(0, -1)], [min(len()-1, +1)]
		 := nunit(nsub(, ))
		 := nunit(ncross(, nv(0, 1, 0)))
		 := nunit(ncross(, ))
		[] = Vertex{Position: nadd(, nmul(, )), Normal: }
		[] = Vertex{Position: nsub(, nmul(, )), Normal: }
	}
	for  := 1;  < len(); ++ {
		.triangle([-1], [], [-1], , false)
		.triangle([-1], [], [], , false)
	}
}

// A lower ribbon provides a narrow paper-colored casing under the colored ink.
// It follows the same local bridge geometry, so its depth occludes only the
// route below a crossing.
func ( *meshBuilder) ( []Vec,  float64,  float64) {
	if len() < 2 {
		return
	}
	 := nativeMaterial("#f5f7fb", 1, 0, )
	.Unlit = true
	,  := make([]Vertex, len()), make([]Vertex, len())
	for ,  := range  {
		,  := [max(0, -1)], [min(len()-1, +1)]
		 := nunit(nsub(, ))
		 := nunit(ncross(, nv(0, 1, 0)))
		 := nunit(ncross(, ))
		 :=  * .8
		if .routeCasingFloor > 0 && .Y > 1e-9 {
			// The paper casing is a decorative backing below the same route.
			// Keep it above raised container caps without moving the ink path
			// or flattening local crossing bridges.
			 = min(, max(0, (.Y-.routeCasingFloor)/.Y))
		}
		 := nsub(, nmul(, ))
		[] = Vertex{Position: nadd(, nmul(, *1.3)), Normal: }
		[] = Vertex{Position: nsub(, nmul(, *1.3)), Normal: }
	}
	for  := 1;  < len(); ++ {
		.triangle([-1], [], [-1], , false)
		.triangle([-1], [], [], , false)
	}
}