How to mark different marked areas with different colors when marking with the paintWidget?

For PaintWidget(vtk.js) In the examples of vtk.js website, I want to dynamic change the RGBpoint’s color, i have try many ways ,but not find a correct method. can you help me?

You should be able to modify the RGB points for a color transfer function. If not, you can always recreate the transfer function object whenever you modify your color map, and set the new object as the RGBTransferFunction.

I have tried, but the color of all points marked before will be changed. My purpose is to change the color of the current mark, and the color of the previous points will not change

If I want paint more label in labelmap( three or more label in labelmap ,like segmentation in 3DSlicer),

not only change color of the labelmap,what should I do?
Thank you a lot.

The paint widget itself doesn’t actually do the painting. It uses vtkPaintFilter, which controls what labels get painted. You will need to look at the paint widget example to see the use of the vtkPaintFilter and how it sets the current label value.