LCOV - code coverage report
Current view: top level - src/components/curve - CurveEditor.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 12 12
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1            3 : <template>
       2            4 :   <svg
       3              :     ref="svgRef"
       4              :     data-testid="curve-editor"
       5              :     viewBox="-0.04 -0.04 1.08 1.08"
       6              :     preserveAspectRatio="xMidYMid meet"
       7              :     :class="
       8              :       cn(
       9              :         'aspect-square w-full rounded-[5px] bg-node',
      10              :         disabled ? 'cursor-default' : 'cursor-crosshair'
      11              :       )
      12              :     "
      13              :     @pointerdown.stop="onSvgPointerDown"
      14              :     @contextmenu.prevent.stop
      15              :   >
      16           12 :     <line
      17              :       v-for="v in [0.25, 0.5, 0.75]"
      18              :       :key="'h' + v"
      19              :       :x1="0"
      20              :       :y1="v"
      21              :       :x2="1"
      22              :       :y2="v"
      23              :       stroke="currentColor"
      24              :       stroke-opacity="0.1"
      25              :       stroke-width="0.003"
      26              :     />
      27           12 :     <line
      28              :       v-for="v in [0.25, 0.5, 0.75]"
      29              :       :key="'v' + v"
      30              :       :x1="v"
      31              :       :y1="0"
      32              :       :x2="v"
      33              :       :y2="1"
      34              :       stroke="currentColor"
      35              :       stroke-opacity="0.1"
      36              :       stroke-width="0.003"
      37              :     />
      38              : 
      39              :     <line
      40              :       x1="0"
      41              :       y1="1"
      42              :       x2="1"
      43              :       y2="0"
      44              :       stroke="currentColor"
      45              :       stroke-opacity="0.15"
      46              :       stroke-width="0.003"
      47              :     />
      48              : 
      49              :     <path
      50              :       v-if="histogramPath"
      51              :       data-testid="histogram-path"
      52              :       :d="histogramPath"
      53              :       :fill="curveColor"
      54              :       fill-opacity="0.15"
      55              :       stroke="none"
      56              :     />
      57              : 
      58              :     <path
      59              :       data-testid="curve-path"
      60              :       :d="curvePath"
      61              :       fill="none"
      62              :       :stroke="curveColor"
      63              :       stroke-width="0.008"
      64              :       stroke-linecap="round"
      65              :       :opacity="disabled ? 0.5 : 1"
      66              :     />
      67              : 
      68              :     <template v-if="!disabled">
      69            9 :       <circle
      70              :         v-for="(point, i) in modelValue"
      71              :         :key="i"
      72              :         data-testid="curve-point"
      73              :         :cx="point[0]"
      74              :         :cy="1 - point[1]"
      75              :         r="0.02"
      76              :         :fill="curveColor"
      77              :         stroke="white"
      78              :         stroke-width="0.004"
      79              :         class="cursor-grab"
      80              :         @pointerdown.stop="startDrag(i, $event)"
      81              :       />
      82              :     </template>
      83              :   </svg>
      84              : </template>
      85              : 
      86              : <script setup lang="ts">
      87              : import { computed, toRef, useTemplateRef } from 'vue'
      88              : 
      89              : import { useCurveEditor } from '@/composables/useCurveEditor'
      90              : import { cn } from '@comfyorg/tailwind-utils'
      91              : 
      92              : import type { CurveInterpolation } from '@comfyorg/graph-model/curve'
      93              : import type { PointTuple as CurvePoint } from '@comfyorg/shared-frontend-utils/geometry'
      94              : 
      95              : import { histogramToPath } from '@/utils/histogramUtil'
      96              : 
      97              : const {
      98              :   curveColor = 'white',
      99              :   histogram,
     100              :   disabled = false,
     101              :   interpolation = 'monotone_cubic'
     102              : } = defineProps<{
     103              :   curveColor?: string
     104              :   histogram?: Uint32Array | null
     105              :   disabled?: boolean
     106              :   interpolation?: CurveInterpolation
     107              : }>()
     108              : 
     109            3 : const modelValue = defineModel<CurvePoint[]>({
     110              :   required: true
     111              : })
     112              : 
     113            3 : const emit = defineEmits<{
     114              :   editEnd: []
     115              : }>()
     116              : 
     117            3 : const svgRef = useTemplateRef<SVGSVGElement>('svgRef')
     118              : 
     119            3 : const { curvePath, handleSvgPointerDown, startDrag } = useCurveEditor({
     120              :   svgRef,
     121              :   modelValue,
     122              :   interpolation: toRef(() => interpolation),
     123              :   onEditEnd: () => emit('editEnd')
     124              : })
     125              : 
     126            1 : function onSvgPointerDown(e: PointerEvent) {
     127            1 :   if (!disabled) handleSvgPointerDown(e)
     128              : }
     129              : 
     130            3 : const histogramPath = computed(() =>
     131              :   histogram ? histogramToPath(histogram) : ''
     132              : )
     133              : </script>
        

Generated by: LCOV version 2.0-1