如何在 cornerstonejs 中更改手绘多边形的颜色

How to change the colors off freehand polygons in cornerstonejs

我想在我的 DICOM 查看器中添加一个选项来更改由手绘工具制作的多边形的颜色(每个多边形的颜色不同)。

我查看了官方示例,似乎 cornerstoneTools 允许您进行的唯一颜色自定义是更改全局工具颜色,该颜色适用于所有多边形 [colorTools.setToolColor(..)]。

谢谢

终于想出办法了

// Listening to new measurement tools
// (in our case, this event raises everytime a new ROI is added)
$(canvas).on('cornerstonetoolsmeasurementadded', (e) => {
  // Making sure this is the type is 'freehand' 
  // which is the tool used for drawing ROI
  if (e.detail.toolType == 'freehand')
    // Changing the color.
    e.detail.measurementData.color = this.pickColor
})