[英]Change svg fill color via colorpicker
I have the following question. 我有以下问题。 is it possible to change the fill color of the svg file with the colorpicker.
是否可以使用选色器更改svg文件的填充颜色。 So far I have come to a moment where I can change the color of the background, but it would be best to change the color of the graphics as if it were a background or foreground.
到目前为止,我已经可以更改背景的颜色了,但是最好将图形的颜色更改为背景或前景。 I would be very grateful for the help because I am a person who is just learning to program in jquery and does not understand everything yet.
我将非常感谢您提供的帮助,因为我是一个刚学会用jquery编程并且还不了解所有内容的人。 Underneath I attach my code.
我在下面附加我的代码。 Pictures placed in the diva are changed using the buttons so they change dynamically.
使用按钮更改放置在女主角中的图片,以便动态更改它们。 Once again, I will be very grateful for your help.
再次感谢您的帮助。
<style>
.inner1
{
width: 500px;
height: 500px;
margin:0 auto;
position: absolute;
margin-bottom:0;
border:solid 2px black;
overflown:none;
}
</style>
<html>
<div id="Image-Holder-fg" class="inner1 " >
<img class="popart1" src ="img/DCIM/Animal/animal5.svg" style="width:
1425px; height: 1425px;" />
<img class="popart2" src ="img/DCIM/Animal/animal6.svg" style="width:
1425px; height: 1425px;" />
<img class="popart3" src ="img/DCIM/Animal/animal7.svg" style="width:
1425px; height: 1425px;" />
<img class="popart4" src ="img/DCIM/Animal/animal8.svg" style="width:
1425px; height: 1425px;" />
</div>
<div id="picker-fg"></div>
</html>
<script>
$('#picker-fg').colpick({
flat:true,
layout:'hex',
submit:0,
colorScheme:'dark',
onChange:function(hsb,hex,rgb,el,bySetColor) {
$("#Image-Holder-fg").css('background-color','#'+hex);
if(!bySetColor) $(el).val(hex);
}
}).keyup(function(){
$(this).colpickSetColor(this.value);
});
</script>
使用SVG内联,这样您可以选择特定的节点并使用JS设置填充。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.