javascript - 无法更改图像绘图 Canvas 上的颜色

标签 javascript jquery css canvas html5-canvas

我创建了一个图像绘图 Canvas ,但绘图颜色无法更改。也许它是 javascript 设置颜色但找不到。如果有人知道请帮助我。这是演示链接

http://affibe.com/erevo/

HTML 代码: `

<html class="gr__adsterra_com">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="js/jquery-2.2.4.min.js"></script> 
<script type="text/javascript" src="js/pixi.min.js"></script> 
<script type="text/javascript" src="js/animationFrame.js"></script> 
<script type="text/javascript" src="js/nodes.js"></script>
<style>body{margin: 0; background-color: transparent;}</style>
</head>
<body data-gr-c-s-loaded="true">
    <header> 
    <script>lowPerformance=function (){var ua=navigator.userAgent.toLowerCase(); if (ua.indexOf("iphone") !=-1 || ua.indexOf("mobile") !=-1) return true; if ($(window).width()==0) return; return ($(window).width() <=480) ? true : false;}; var ie=false; var w=window, d=document, documentElement=d.documentElement, body=d.getElementsByTagName('body')[0], height=w.innerHeight|| documentElement.clientHeight|| body.clientHeight; if (navigator.appName=='Microsoft Internet Explorer') ie=true; Nodes.multipleInit([{"post_name": "AFFIBE", "drawnImage": (height>860)?"http:\/\/affibe.com\/erevo\/images\/main\/logo_header_er.png":"http:\/\/affibe.com\/erevo\/images\/main\/logo_header_er.png", "linkTitle": "AFFIBE", "particleDensity": ie?"11":"7", "particleWidth": "0.5", "particleHeight": "0.5"}]); </script>
    </header>
</body>
</html>

pixi.min.js: http://affibe.com/erevo/js/pixi.min.js

animationFrame.js

!function(){for(var n=0,i=["ms","moz","webkit","o"],e=0;e<i.length&&!window.requestAnimationFrame;++e)window.requestAnimationFrame=window[i[e]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[i[e]+"CancelAnimationFrame"]||window[i[e]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(i){var e=(new Date).getTime(),a=Math.max(0,16-(e-n)),o=window.setTimeout(function(){i(e+a)},a);return n=e+a,o}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(n){clearTimeout(n)})}();

最佳答案

如果我理解它,下面的代码对你有帮助

var c = document.getElementById("canvas");
var ctx= c.getContext("2d");
ctx.fillStyle="#66bfff";

例如

var c   = document.getElementById('canvas');
var ctx = c.getContext("2d");
ctx.fillStyle = "#f00";
ctx.fillRect(40, 40, 40, 40);
#canvas{
    border: 2px solid #333;
}
<html>
<body>
    <canvas id="canvas" width="100" height="100"></canvas>
</body>
</html>

关于javascript - 无法更改图像绘图 Canvas 上的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51129507/

相关文章:

javascript - 参数化 Angular 请求的优缺点

c# - 用于特定搜索功能的服务器端缓存 JQuery 自动完成

javascript - 使用ajax动态调用PHP函数

jQuery 验证不验证表单,但不抛出错误

html - 段落和文本区域内的字体大小

javascript - 使用 document.location.href 时出现 ajax 错误 "error loading page'

javascript - Nativescript-vue $emit 未按预期工作

css - SCSS 值(value)倍数

javascript - ReactJS - TypeError : requests. map 不是函数

css - 没有 www 的 FontAwesome 不显示