javascript - 如何使用 HTML5-Canvas 为图像着色?

标签 javascript html canvas

如何使用 HTML5-Canvas 为图像着色? 基于十六进制或 RGB 颜色值作为输入?

最佳答案

尝试 CamanJS .

Colorize 过滤器看起来正是您想要的:http://camanjs.com/docs/filters.html#section-13

Uniformly shifts the colors in an image towards the given color.

The adjustment range is from 0 to 100. The higher the value, the closer the colors in the image shift towards the given adjustment color.

Caman("#image", function () {
    // Explicitly give the R, G, and B values of the
    // color to shift towards.
    //
    // Arguments: (R, G, B, strength)
    this.colorize(25, 180, 200, 20);

    // The other way is to specify a color in hex form:
    this.colorize("#4090D5", 20);
});

有关内置过滤器的更多示例:http://camanjs.com/guides/#BuiltIn

关于javascript - 如何使用 HTML5-Canvas 为图像着色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6498720/

相关文章:

javascript - 如何根据包含所有信息的对象数组绘制成绩图表?

html - 如何使用 CSS 设置输入和提交按钮的样式?

javascript - 画一条 Canvas 线,末端有一个点

html - CSS 文本布局问题

html - 将旋转的文本与 Canvas 左侧对齐

javascript - canvas和SVG的区别(填充效果)

Canvas 标签的 Javascript Sprite 动画库

javascript 数字验证

javascript - Mongoose 和 Node.js 中的类型错误 : [function name] is not a function,

javascript - 在 Bootstrap 模式上提交信用卡表单