AnsweredAssumed Answered

Color Palette on graphics

Question asked by ihussein1 on Sep 15, 2014
Latest reply on Sep 15, 2014 by ihussein1

Hello,

example - jsFiddle

Answer - jsFiddle

If you look at the example above, when you click a text field a color Palette comes up; is there an easy way to do this for a graphic (eclipse, triangle...) as well?

 

edit - Answer -

 

 

  var myPalette = new ColorPalette({

  palette: "7x10",

  onChange: function(val){

 

  if(grfx.geometry.type==="point")

  {return;}

 

 

 

  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(val);

  var r = parseInt(result[1], 16)

  var g = parseInt(result[2], 16)

  var b = parseInt(result[3], 16)

 

 

  var symbol =  new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

  new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,

  new Color([0,0,0]), 2),new Color([r,g,b,0.75]));

 

 

  grfx.setSymbol(symbol);

  }

  }, "colorPal").startup();

 

On graphic click, I set the symbol to the color palette.

Outcomes