好吧,我正在绘制一个画布对象上的描边线,这项工作正常我想要做的就是删除线条或在一段时间之后淡出它们我一直在阅读关于保存状态和刷新但我可以'似乎让它工作我还尝试将画布上下文存储到一个数组中并在它超过一定长度时拼接其中的项目但又一次没有运气......这是我的代码(这是巨大的所以我'设立了一个plunkr):
`var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.canvas = $('#spiro')[0];
$scope.canvascanvasContext = $scope.canvas.getContext("2d");
//interval
$scope.timerId = 0;
console.log($scope.canvas);
//MOUSE OVER
/*
$scope.getMousePos = function getMousePos(evt) {
var rect = $scope.canvas.getBoundingClientRect();
$scope.mouseX = evt.clientX - rect.left;
$scope.mouseY = evt.clientY - rect.top;
$scope.canvascanvasContext.fillStyle = "rgb("+$scope.red+", "+$scope.green+", "+$scope.blue+")";
$scope.canvascanvasContext.fillRect($scope.mouseX, $scope.mouseY, 4, 4);
console.log(evt.clientX);
}
*/
$scope.clearit = function clearit(){
// Store the current transformation matrix
// $scope.canvascanvasContext.save();
// Use the identity matrix while clearing the canvas
$scope.canvascanvasContext.setTransform(1, 0, 0, …Run Code Online (Sandbox Code Playgroud)