Color picker 100% SVG
New version runing with Firefox 1.5, Opera 9 and Batik 1.6
Design and script are separated.
Script is load on begin
Design is load on request and removed after use.
You can create your design, save it in SVG or SVGZ files.
In main SVG, for using color picker, you have to
1) load script with
<script xlink:href="js/pickcolor_HSL.js"/>
manage tool
<script xlink:href="js/opera.js"/>
emulate getURL() and parseXML()
<script xlink:href="js/tools.js"/> move
tool's window
2) reserve at the end place for design with <g id="messages" transform="translate(100,50)"></g>
by example
3) put gradients used by tool in <defs> section
4) call it with
add_pick_color("svg/pickcolor_HSL.svg","messages",num);
in order: file for design, name of group where put fragment,number for using
5) create function to use result in main SVG as this
function use_messages_pickcolor_HSL(result,data,num_w)
{
if (!result)
return
switch(num_w)
{
case 0:
obj=svgdoc.getElementById("rect1");
obj.setAttribute("fill",data);
break;
.............
}
}
( svgdoc must be name for SVGDocument and name of group +"_use_pick_color" name of function )
In SVG design, this function is called when you close window with
onclick="close_pick_color(true)".
Function pick_color_tape allow using Enter and Escape
keys to close window.
You have to keep id for objects in design or modify script.
When color picker is closed with OK, it return color as RGB string in data
variable.