小编Pat*_*ick的帖子

将画布保存为 SVG

向大家提出一个简单的问题(希望如此)。我用 C# 制作了一个画布,这个画布上有形状。现在我想将画布及其形状保存到 .svg 中,以便将其用于其他用途。那么,如何将画布保存为 svg 文件呢?

希望你能帮忙。

c# wpf svg canvas

4
推荐指数
1
解决办法
2805
查看次数

HTML5 Canvas,更好的像素控制和更快的速度

我正在尝试使用画布在 HTML5 和 Javascript 的帮助下创建一个小模拟。然而,我的问题是,我真的想不出一种方法来控制我的像素行为,而不是让每个像素都成为一个对象,这会导致我的模拟速度严重减慢。

到目前为止的代码如下:

var pixels = [];
class Pixel{
    constructor(color){
        this.color=color;
    }
}

window.onload=function(){
    canv = document.getElementById("canv");
    ctx = canv.getContext("2d");
    createMap();
    setInterval(game,1000/60);
};

function createMap(){
    pixels=[];
    for(i = 0; i <= 800; i++){
        pixels.push(sub_pixels = []);
        for(j = 0; j <= 800; j++){
            pixels[i].push(new Pixel("green"));
        }
    }
    pixels[400][400].color="red";
}

function game(){
    ctx.fillStyle = "white";
    ctx.fillRect(0,0,canv.width,canv.height);
    for(i = 0; i <= 800; i++){
        for(j = 0; j <= 800; j++){
            ctx.fillStyle=pixels[i][j].color;
            ctx.fillRect(i,j,1,1);
        }
    }
    for(i = 0; i …
Run Code Online (Sandbox Code Playgroud)

html javascript simulation canvas pixel

2
推荐指数
1
解决办法
1226
查看次数

标签 统计

canvas ×2

c# ×1

html ×1

javascript ×1

pixel ×1

simulation ×1

svg ×1

wpf ×1