gpt4 book ai didi

javascript - 在 raphael.js 中更改线宽和颜色

转载 作者:行者123 更新时间:2023-11-29 21:36:40 24 4
gpt4 key购买 nike

请耐心等待我刚开始使用 raphael.js 库,我需要更改线条的宽度和颜色。
我查看了此处的文档和其他答案,但我完全迷路了。
目前它太薄了,我也需要它是另一种颜色。 enter image description here

代码

function Line(startX, startY, endX, endY, raphael) {
var start = {
x: startX,
y: startY
};
var end = {
x: endX,
y: endY
};
var getPath = function() {
return "M" + start.x + " " + start.y + " L" + end.x + " " + end.y;
};
var redraw = function() {
node.attr("path", getPath());
}

var node = raphael.path(getPath());
return {
updateStart: function(x, y) {
start.x = x;
start.y = y;
redraw();
return this;
},
updateEnd: function(x, y) {
end.x = x;
end.y = y;
redraw();
return this;
}
};
};



$(document).ready(function() {
var paper = Raphael("raphaelContainer",1280,470, 0, 0);
$("#raphaelContainer").mousedown(

function(e) {
x = e.offsetX;
y = e.offsetY;
line = Line(x, y, x, y, paper);
$("#raphaelContainer").bind('mousemove', function(e) {
x = e.offsetX;
y = e.offsetY;
line.updateEnd(x, y);
});
});

$("#raphaelContainer").mouseup(

function(e) {
$("#raphaelContainer").unbind('mousemove');
});
});

有什么帮助吗?

最佳答案

你可以看看 stroke-width 和 stroke。

element.attr({ stroke-width: 3, stroke: 'red' }); for example

“attr”的文档 here

关于javascript - 在 raphael.js 中更改线宽和颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34675466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com