Canvas绘制

Canvas绘制

  • 一、介绍
    • 效果图
  • 二、画圆
    • 1 写一个页面
    • 2 画一个圆(点)
    • 3 效果
  • 三 画直线
    • 1 写一个页面
    • 2 画直线
    • 3 效果
  • 四 用直线连接两个点
    • 1 写一个页面
    • 2 连线
    • 3 效果
  • 五 画随机点
    • 1 写一个页面
    • 2 随机点
    • 3 效果
  • 六 画随机点并连线
    • 1 写一个页面
    • 2 画点连线
    • 3 效果
  • 七 动起来(动画)
    • 1 写一个页面
    • 2 动起来
    • 3 效果
  • 八 添加鼠标
    • 1 写一个页面
    • 2 添加鼠标
    • 3 效果
  • 九 鼠标吸附
    • 1 写一个页面
    • 2 鼠标吸附
    • 3 效果

Canvas是HTML5新增的一个元素,它提供了JS绘制图形的API。

一、介绍

Canvas常用的4种API:

  • 画直线 lineTo
  • 画弧线 arc
  • 画文字 fillText 或 strokeText
  • 画图片 drawImage

今日任务:手撸下面的动图(使用了弧线,直线,鼠标监听,动画)

  • 编写步骤:
画点 --> 画线 -> 随机N个点 -> 所有点连线 -> 动画 -> 鼠标进入/移出 -> 鼠标吸附 -> 完成

效果图

在这里插入图片描述

二、画圆

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 画一个圆(点)

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');

// 初始化画布
function init() {
    cvs.width = window.innerWidth;
    cvs.height = window.innerHeight;
}

init()

// 画一个空心圆
ctx.beginPath();
// xy 圆心坐标, 半径, 起始角度,结束角度
ctx.arc(100,50,6,0,2 * Math.PI)
// 描边颜色
ctx.strokeStyle = '#fff';
// 画 描边
ctx.stroke();


// 画一个实心圆
ctx.beginPath();
// xy 圆心坐标, 半径, 起始角度,结束角度
ctx.arc(200,100,6,0,2 * Math.PI)
// 填充颜色
ctx.fillStyle = '#fff';
// 画 填充
ctx.fill();

3 效果

在这里插入图片描述

三 画直线

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 画直线

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');

// 初始化画布
function init() {
    cvs.width = window.innerWidth;
    cvs.height = window.innerHeight;
}

init()

// 开启画路径
ctx.beginPath();
// 将画笔移动到此处 开始画
ctx.moveTo(100,50);
// 画笔经过的点
ctx.lineTo(200,100);
ctx.lineTo(300,300);
ctx.lineTo(300,500);
// 关闭路径(首位自动相连)
ctx.closePath();
// // 描边颜色
// ctx.strokeStyle = '#fff';
// // 画 描边
// ctx.stroke(); 

// 填充颜色
ctx.fillStyle = '#fff';
// 画 填充
ctx.fill();

3 效果

在这里插入图片描述在这里插入图片描述

四 用直线连接两个点

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 连线

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');

// 初始化画布
function init() {
    cvs.width = window.innerWidth;
    cvs.height = window.innerHeight;
}

init()

// 开启画路径
ctx.beginPath();
ctx.moveTo(100,100);
ctx.lineTo(300,200);
ctx.strokeStyle = '#fff'
ctx.stroke();

// 画点 ()
ctx.beginPath();
ctx.arc(100,100,6,0,2 * Math.PI);
ctx.fillStyle='#fff';
ctx.fill();

ctx.beginPath();
ctx.arc(300,200,6,0,2 * Math.PI);
ctx.fillStyle='#fff';
ctx.fill();

3 效果

在这里插入图片描述

五 画随机点

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 随机点

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');
// 点数量
const pointNumber = 88;
// 初始化画布
function init() {
    cvs.width = window.innerWidth * devicePixelRatio;
    cvs.height = window.innerHeight * devicePixelRatio;
}
init()

/**
 * 获取[min, max]范围内的随机整数
 */
function getRandom(min, max) {
    return Math.floor(Math.random() * (max + 1 - min) + min)
}

/**
 * 画点
 * 随机生成点坐标
 */
class Point {
    //构造
    constructor() {
        this.r = 6;
        this.x = getRandom(0,cvs.width - this.r / 2)
        this.y = getRandom(0,cvs.height - this.r / 2)
    }
    // 开始画
    draw(){
        //画点
        ctx.beginPath();
        ctx.arc(this.x,this.y,this.r,0,2 * Math.PI);
        ctx.fillStyle='rgb(200,200,200)';
        ctx.fill();
        this.lastDrawTime = Date.now();
    }
}

class Graph{
    constructor() {
        this.points = new Array(pointNumber).fill(0).map(() => new Point())
    }

    draw(){
        for (let i = 0; i < this.points.length; i++) {
            const p1 = this.points[i];
            p1.draw();
        }
    }
}

const g = new Graph();
g.draw();

3 效果

在这里插入图片描述

六 画随机点并连线

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 画点连线

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');
// 点数量
const pointNumber = 88;
// 两点连线最大距离
const maxDis = 150;

// 初始化画布
function init() {
    cvs.width = window.innerWidth * devicePixelRatio;
    cvs.height = window.innerHeight * devicePixelRatio;
}

init()

/**
 * 获取[min, max]范围内的随机整数
 */
function getRandom(min, max) {
    return Math.floor(Math.random() * (max + 1 - min) + min)
}

/**
 * 画点
 * 随机生成点坐标
 */
class Point {
    //构造
    constructor() {
        this.r = 6;
        this.x = getRandom(0,cvs.width - this.r / 2)
        this.y = getRandom(0,cvs.height - this.r / 2)
    }
    // 开始画
    draw(){
        //画点
        ctx.beginPath();
        ctx.arc(this.x,this.y,this.r,0,2 * Math.PI);
        ctx.fillStyle='rgb(200,200,200)';
        ctx.fill();
        this.lastDrawTime = Date.now();
    }
}

class Graph{
    constructor() {
        this.points = new Array(pointNumber).fill(0).map(() => new Point())
    }

    draw(){
        for (let i = 0; i < this.points.length; i++) {
            const p1 = this.points[i];
            p1.draw();
            for (let i = 0; i < this.points.length; i++) {
                const p1 = this.points[i];

                for (let j = 0; j < this.points.length; j++) {
                    const p2 = this.points[j];
                    // 计算两点间距离(利用直角三角形  a方 = b方 = c方, c就是两点间距离)
                    const d = Math.sqrt((p1.x-p2.x)**2 + (p1.y-p2.y)**2)
                    if(d > maxDis){
                        continue;
                    }

                    ctx.beginPath();
                    ctx.moveTo(p1.x,p1.y);
                    ctx.lineTo(p2.x, p2.y);
                    ctx.strokeStyle = `rgba(200,200,200, ${1 - d / maxDis})`
                    ctx.stroke();
                }


            }
        }
    }
}

const g = new Graph();
g.draw();

3 效果

在这里插入图片描述

七 动起来(动画)

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 动起来

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');
// 点数量
const pointNumber = 88;
// 两点连线最大距离
const maxDis = 150;
// 初始化画布
function init() {
    cvs.width = window.innerWidth * devicePixelRatio;
    cvs.height = window.innerHeight * devicePixelRatio;
}

init()

/**
 * 获取[min, max]范围内的随机整数
 */
function getRandom(min, max) {
    return Math.floor(Math.random() * (max + 1 - min) + min)
}

/**
 * 画点
 * 随机生成点坐标
 */
class Point {
    //构造
    constructor() {
        this.r = 2;
        this.x = getRandom(0,cvs.width - this.r / 2)
        this.y = getRandom(0,cvs.height - this.r / 2)

        this.xSpeed = getRandom(-50,50);
        this.ySpeed = getRandom(-50,50);
        this.lastDrawTime = null;
    }
    // 开始画
    draw(){
        //更新坐标
        if(this.lastDrawTime){
            const duration = (Date.now() - this.lastDrawTime) / 1000;
            //距离
            const xDis = this.xSpeed * duration,
                yDis = this.ySpeed * duration;
            // 新的坐标
            let x = this.x + xDis,
                y = this.y + yDis;
            // 点到边界回弹
            if(x > cvs.width - this.r / 2){
                x = cvs.width - this.r / 2
                this.xSpeed = -this.xSpeed;
            }else if(x < 0){
                x = 0;
                this.xSpeed = -this.xSpeed;
            }
            if(y > cvs.height - this.r / 2){
                y = cvs.height - this.r / 2
                this.ySpeed = -this.ySpeed;
            }else if(y < 0){
                y = 0;
                this.ySpeed = -this.ySpeed;
            }

            this.x = x;
            this.y = y;
        }

        //画点
        ctx.beginPath();
        ctx.arc(this.x,this.y,this.r,0,2 * Math.PI);
        ctx.fillStyle='rgb(200,200,200)';
        ctx.fill();
        this.lastDrawTime = Date.now();
    }
}



class Graph{
    constructor() {
        this.points = new Array(pointNumber).fill(0).map(() => new Point())
    }

    draw(){
        requestAnimationFrame(() => {
            this.draw()
        })
        // 清除画布
        ctx.clearRect(0,0,cvs.width,cvs.height)

        for (let i = 0; i < this.points.length; i++) {
            const p1 = this.points[i];
            p1.draw();

            for (let j = 0; j < this.points.length; j++) {
                const p2 = this.points[j];
                // 计算两点间距离(利用直角三角形  a方 = b方 = c方, c就是两点间距离)
                const d = Math.sqrt((p1.x-p2.x)**2 + (p1.y-p2.y)**2)
                if(d > maxDis){
                    continue;
                }

                ctx.beginPath();
                ctx.moveTo(p1.x,p1.y);
                ctx.lineTo(p2.x, p2.y);
                ctx.strokeStyle = `rgba(200,200,200, ${1 - d / maxDis})`
                ctx.stroke();
            }


        }
    }
}

const g = new Graph();
g.draw();

3 效果

不上动图了,还要制作gif,麻烦…
在这里插入图片描述

八 添加鼠标

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 添加鼠标

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');
//鼠标最后的坐标
let mouseLastX = 0;
let mouseLastY = 0;
// 点数量
const pointNumber = 88;
// 两点连线最大距离
const maxDis = 150;
// 初始化画布
function init() {
    cvs.width = window.innerWidth * devicePixelRatio;
    cvs.height = window.innerHeight * devicePixelRatio;

    // 鼠标移动事件
    cvs.addEventListener('mousemove', function(event) {
        // 鼠标进入 怎加鼠标 点,
        var canvasRect = cvs.getBoundingClientRect();
        var mouseX = event.clientX - canvasRect.left;
        var mouseY = event.clientY - canvasRect.top;
        // console.log("鼠标在canvas中的坐标:(" + mouseX + ", " + mouseY + ")");
        const d = Math.sqrt((mouseLastX-mouseX)**2 + (mouseLastY-mouseY)**2)
        // 移动距离
        if(d > 5){
            if(g.points.length > pointNumber){
                g.points.pop();
            }
            g.points.push(new Point(mouseX,mouseY,0));
            mouseLastX = mouseX;
            mouseLastY = mouseY;
        }
    });

    // 添加鼠标离开事件监听器
    cvs.addEventListener('mouseleave', function(event) {
        g.points.pop();
        mouseLastX = 0;
        mouseLastY = 0;
    });
}

init()

/**
 * 获取[min, max]范围内的随机整数
 */
function getRandom(min, max) {
    return Math.floor(Math.random() * (max + 1 - min) + min)
}

/**
 * 画点
 * 随机生成点坐标
 */
class Point {
    //构造
    constructor(x = null,y = null, r = 2) {
        this.r = r;
        if(x == null){
            this.x = getRandom(0,cvs.width - this.r / 2)
            this.y = getRandom(0,cvs.height - this.r / 2)
        }else{
            this.x =x;
            this.y =y;
        }

        this.xSpeed = getRandom(-50,50);
        this.ySpeed = getRandom(-50,50);;
        this.lastDrawTime = null;
    }
    // 开始画
    draw(isUpdate = true){
        // 是否需要更新坐标
        if(isUpdate){
            //更新坐标
            if(this.lastDrawTime){
                const duration = (Date.now() - this.lastDrawTime) / 1000;
                //距离
                const xDis = this.xSpeed * duration,
                    yDis = this.ySpeed * duration;
                // 新的坐标
                let x = this.x + xDis,
                    y = this.y + yDis;
                // 点到边界回弹
                if(x > cvs.width - this.r / 2){
                    x = cvs.width - this.r / 2
                    this.xSpeed = -this.xSpeed;
                }else if(x < 0){
                    x = 0;
                    this.xSpeed = -this.xSpeed;
                }
                if(y > cvs.height - this.r / 2){
                    y = cvs.height - this.r / 2
                    this.ySpeed = -this.ySpeed;
                }else if(y < 0){
                    y = 0;
                    this.ySpeed = -this.ySpeed;
                }

                this.x = x;
                this.y = y;
            }
        }

        //画点
        ctx.beginPath();
        ctx.arc(this.x,this.y,this.r,0,2 * Math.PI);
        ctx.fillStyle='rgb(200,200,200)';
        ctx.fill();
        this.lastDrawTime = Date.now();
    }
}

class Graph{
    constructor() {
        this.points = new Array(pointNumber).fill(0).map(() => new Point())
    }

    draw(){
        requestAnimationFrame(() => {
            this.draw()
        })
        // 清除画布
        ctx.clearRect(0,0,cvs.width,cvs.height)

        for (let i = 0; i < this.points.length; i++) {
            const p1 = this.points[i];
            // 最后一个是鼠标,不更新坐标
            p1.draw(i < pointNumber);

            for (let j = 0; j < this.points.length; j++) {
                const p2 = this.points[j];
                // 计算两点间距离(利用直角三角形  a方 = b方 = c方, c就是两点间距离)
                const d = Math.sqrt((p1.x-p2.x)**2 + (p1.y-p2.y)**2)
                if(d > maxDis){
                    continue;
                }

                ctx.beginPath();
                ctx.moveTo(p1.x,p1.y);
                ctx.lineTo(p2.x, p2.y);
                ctx.strokeStyle = `rgba(200,200,200, ${1 - d / maxDis})`
                ctx.stroke();
            }


        }
    }
}

const g = new Graph();
g.draw();

3 效果

在这里插入图片描述

九 鼠标吸附

1 写一个页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        canvas {
            position: fixed;
            left: 0px;
            top: 0px;
            background: #222;
        }
    </style>
</head>
<body>
    <canvas></canvas>
    <script src="./canvasjs03.js"></script>
</body>
</html>

2 鼠标吸附

// 在画布上画 随机点,点与点之间连线,鼠标移动,鼠标移出,吸附   例子

// 获取画布
const cvs = document.querySelector('canvas');
// 获取画笔
const ctx = cvs.getContext('2d');
//鼠标最后的坐标
let mouseLastX = 0;
let mouseLastY = 0;
// 点数量
const pointNumber = 88;
// 两点连线最大距离
const maxDis = 150;
// 初始化画布
function init() {
    cvs.width = window.innerWidth * devicePixelRatio;
    cvs.height = window.innerHeight * devicePixelRatio;

    // 鼠标移动事件
    cvs.addEventListener('mousemove', function(event) {
        // 鼠标进入 怎加鼠标 点,
        var canvasRect = cvs.getBoundingClientRect();
        var mouseX = event.clientX - canvasRect.left;
        var mouseY = event.clientY - canvasRect.top;
        // console.log("鼠标在canvas中的坐标:(" + mouseX + ", " + mouseY + ")");
        const d = Math.sqrt((mouseLastX-mouseX)**2 + (mouseLastY-mouseY)**2)
        // 移动距离
        if(d > 2){
            if(g.points.length > pointNumber){
                //移除鼠标  点
                g.points.pop();
            }
            //添加鼠标  点
            g.points.push(new Point(mouseX,mouseY,0));

            // 鼠标移动 吸附效果()
            if(mouseLastX > 0){
                // 最后一个是 鼠标  不计算
                for (let i = 0; i < g.points.length - 1; i++) {
                    const p0 = g.points[i];
                    // 计算点与鼠标的距离
                    const d0 = Math.sqrt((p0.x-mouseX)**2 + (p0.y-mouseY)**2)
                    // 在鼠标附近的点  进入 吸附效果
                    if(d0 < maxDis && d0 > maxDis-50){
                        // 计算xy 是加是减
                        p0.x > mouseX ? p0.x -= 2 : p0.x += 2;
                        p0.y > mouseY ? p0.y -= 2 : p0.y += 2;
                        // // 无需重画
                        // p0.draw();
                    }
                }
            }
            //记录鼠标坐标
            mouseLastX = mouseX;
            mouseLastY = mouseY;
        }
    });

    // 添加鼠标离开事件监听器
    cvs.addEventListener('mouseleave', function(event) {
        // 移出鼠标 点
        g.points.pop();
        mouseLastX = 0;
        mouseLastY = 0;
    });
}

init()

/**
 * 获取[min, max]范围内的随机整数
 */
function getRandom(min, max) {
    return Math.floor(Math.random() * (max + 1 - min) + min)
}

/**
 * 画点
 * 随机生成点坐标
 */
class Point {
    /**
     * 构造
     * @param x 点x坐标
     * @param y 点y左边
     * @param r 点半径
     */
    constructor(x = null,y = null, r = 2) {
        this.r = r;
        if(x == null){
            this.x = getRandom(0,cvs.width - this.r / 2)
            this.y = getRandom(0,cvs.height - this.r / 2)
        }else{
            this.x =x;
            this.y =y;
        }
        // 点随机变化位置时的 步长
        this.xSpeed = getRandom(-50,50);
        this.ySpeed = getRandom(-50,50);
        this.lastDrawTime = null;
    }
    // 开始画
    draw(isUpdate = true){
        // 是否需要更新坐标
        if(isUpdate){
            //更新坐标
            if(this.lastDrawTime){
                const duration = (Date.now() - this.lastDrawTime) / 1000;
                //距离
                const xDis = this.xSpeed * duration,
                    yDis = this.ySpeed * duration;
                // 新的坐标
                let x = this.x + xDis,
                    y = this.y + yDis;

                // 点到边界回弹
                if(x > cvs.width - this.r / 2){
                    x = cvs.width - this.r / 2
                    this.xSpeed = -this.xSpeed;
                }else if(x < 0){
                    x = 0;
                    this.xSpeed = -this.xSpeed;
                }
                if(y > cvs.height - this.r / 2){
                    y = cvs.height - this.r / 2
                    this.ySpeed = -this.ySpeed;
                }else if(y < 0){
                    y = 0;
                    this.ySpeed = -this.ySpeed;
                }

                this.x = x;
                this.y = y;
            }
        }

        //画点
        ctx.beginPath();
        ctx.arc(this.x,this.y,this.r,0,2 * Math.PI);
        ctx.fillStyle='rgb(200,200,200)';
        ctx.fill();
        this.lastDrawTime = Date.now();
    }
}


/**
 * 画线
 */
class Graph{
    constructor() {
        // 生成 pointNumber 个点
        this.points = new Array(pointNumber).fill(0).map(() => new Point())
    }

    draw(){
        /**
         * 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
         */
        requestAnimationFrame(() => {
            this.draw()
        })
        // 清除画布
        ctx.clearRect(0,0,cvs.width,cvs.height)

        for (let i = 0; i < this.points.length; i++) {
            const p1 = this.points[i];
            // 最后一个是鼠标,不更新坐标
            p1.draw(i < pointNumber);

            // 链接两点间 直线
            for (let j = 0; j < this.points.length; j++) {
                const p2 = this.points[j];
                // 计算两点间距离(利用直角三角形  a方 = b方 = c方, c就是两点间距离)
                const d = Math.sqrt((p1.x-p2.x)**2 + (p1.y-p2.y)**2)
                if(d > maxDis){
                    continue;
                }

                ctx.beginPath();
                ctx.moveTo(p1.x,p1.y);
                ctx.lineTo(p2.x, p2.y);
                ctx.strokeStyle = `rgba(200,200,200, ${1 - d / maxDis})`
                ctx.stroke();
            }
        }
    }
}

const g = new Graph();
g.draw();

3 效果

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/399876.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

项目成本和收益管理,用易趋就够了,项目价值可量化

最近看到一个吐槽贴&#xff0c;项目经理小刘说&#xff0c;“去年很多项目都成功交付了&#xff0c;为啥项目奖金还是这么少呢&#xff1f;一问领导是由于项目的绩效没有达成&#xff0c;尤其是很多项目的成本都超支了。”总结来说&#xff0c;这主要是由于没有达成项目预期的…

理论学习-ARM-内核

ARM内核 函数的调用加载、存储计算中断异常线程的切换 为了提高学习效率&#xff0c;我们要提前想好学习策略。 首先&#xff0c;使用频率越高的知识点&#xff0c;越要首先学习。假使&#xff0c;我们学习了一个知识点&#xff0c;能覆盖工作中80%的工作量&#xff0c;那是不是…

MySQL数据库进阶第三篇(MySQL性能优化)

文章目录 一、插入数据优化二、主键优化三、order by优化四、group by优化五、limit优化六、count优化七、update优化&#xff08;避免行锁升级为表锁&#xff09; 这篇博客详细探讨了MySQL数据库的多项优化技巧。包括如何进行数据插入优化&#xff0c;采用批量插入和MySQL的lo…

四非保研之旅

大家好&#xff0c;我是工藤学编程&#xff0c;虽有万分感概&#xff0c;但是话不多说&#xff0c;先直接进入正题&#xff0c;抒情环节最后再说&#xff0c;哈哈哈 写在开头 我的分享是来给大家涨信心的&#xff0c;网上的大佬们都太强了&#xff0c;大家拿我涨涨信心&#…

在linux环境如何使用Anaconda安装指定的python版本

首先我们可以查看一下服务器现有的环境 conda info --envs 发现没有我需要的版本&#xff0c;那么可以用如下命令 conda create --name py36 python3.6 我这里安装了python 3.6的版本 再次输入 conda info --envs 可以通过以下命令激活刚刚创建的环境 conda activate py36…

Docker中如何删除某个镜像

1. 停止使用镜像的容器 首先&#xff0c;您需要停止所有正在使用该镜像的容器。您可以使用 docker stop 命令来停止容器&#xff1a; docker stop 11184993a106如果有多个容器使用该镜像&#xff0c;您需要对每个容器都执行停止命令。您可以通过 docker ps -a | grep core-ba…

C语言------------指针笔试题目深度剖析

1. #include <stdio.h> int main() { int a[5] { 1, 2, 3, 4, 5 }; int *ptr (int *)(&a 1); printf( "%d,%d", *(a 1), *(ptr - 1)); return 0; } 首先要明白这个强制类型转换&#xff0c;即int(*)[5]类型转换成int(*)类型&#xff1b; *&#xff…

联发科将展示6G环境运算和次世代卫星宽带 | 百能云芯

联发科技术有限公司&#xff08;MediaTek&#xff09;近日宣布&#xff0c;将在2024年世界移动通信大会&#xff08;MWC&#xff09;上展示其在移动通信技术领域的最新成就&#xff0c;包括6G环境运算、Pre-6G卫星宽带以及智能手机生成式人工智能&#xff08;AI&#xff09;应用…

相机图像质量研究(40)常见问题总结:显示器对成像的影响--画面泛白

系列文章目录 相机图像质量研究(1)Camera成像流程介绍 相机图像质量研究(2)ISP专用平台调优介绍 相机图像质量研究(3)图像质量测试介绍 相机图像质量研究(4)常见问题总结&#xff1a;光学结构对成像的影响--焦距 相机图像质量研究(5)常见问题总结&#xff1a;光学结构对成…

C++学习Day08之类模板中的成员函数分文件编写问题及解决

目录 一、程序及输出1.1 .h文件cpp1.2 包含hpp 二、分析与总结 一、程序及输出 1.1 .h文件cpp person.h #pragma once #define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std;template<class T1, class T2> class Person { public:Person(T1…

判断一个dll/exe是32位还是64位

通过记事本判断&#xff08;可判断C或者C#&#xff09; 64位、将dll用记事本打开&#xff0c;可以看到一堆乱码&#xff0c;但是找到乱码行的第一个PE&#xff0c;如果后面是d?则为64位 32位、将dll用记事本打开&#xff0c;可以看到一堆乱码&#xff0c;但是找到乱码行的第…

三防加固平板在房地产行业的应用|亿道三防onerugged

近期&#xff0c;有一款引人注目的解决方案——亿道三防onerugged平板电脑&#xff0c;它以其出色的性能和多功能的设计&#xff0c;为房地产行业带来了全新的应用体验。 首先&#xff0c;亿道三防onerugged平板电脑的NFC功能在小区业主身份验证中发挥着重要作用。传统的身份验…

Excel SUMPRODUCT函数用法(乘积求和,分组排序)

SUMPRODUCT函数是Excel中功能比较强大的一个函数&#xff0c;可以实现sum,count等函数的功能&#xff0c;也可以实现一些基础函数无法直接实现的功能&#xff0c;常用来进行分类汇总&#xff0c;分组排序等 SUMPRODUCT 函数基础 SUMPRODUCT函数先计算多个数组的元素之间的乘积…

【RL】Policy Gradient Methods(策略梯度方法)

Lecture 9: Policy Gradient Methods Basic idea of policy gradient 之前&#xff0c;policy是用表格表示的&#xff1a; 所有state的action概率都存储在表 π ( a ∣ s ) \pi(a|s) π(a∣s)中。 表的每个条目都由state和action索引。 因此可以直接访问或更改表中的值。 …

药物检测设备行业分析:市场年均复合增长速度为14.04%

在制药行业中&#xff0c;质量检验检测过程尤为重要。因为药品质量关系到人们的身体健康&#xff0c;如何控制好药品的质量安全&#xff0c;做好药品生产管理过程中的质量风险管理工作&#xff0c;是药品生产企业面临的重要问题。 为保证做好药品质量、安全方面的控制&#xff…

☀️将大华摄像头画面接入Unity 【1】配置硬件和初始化摄像头

一、硬件准备 目前的设想是后期采用网口供电的形式把画面传出来&#xff0c;所以这边我除了大华摄像头还准备了POE供电交换机&#xff0c;为了方便索性都用大华的了&#xff0c;然后全都连接电脑主机即可。 二、软件准备 这边初始化摄像头需要用到大华的Configtool软件&#…

ipad作为扩展屏的最简单方式(无需数据线)

ipad和win都下载安装toDesk&#xff0c;并且都处于同一局域网下 连接ipad&#xff0c;在ipad中输入win设备的设备密码和临时密码&#xff0c;连接上后可以看到ipad会是win屏幕的镜像&#xff0c;此时退出连接&#xff0c;准备以扩展模式再次连接。 注意&#xff0c;如果直接从…

#gStore-weekly | gMaster功能详解之数据库管理

gMaster提供了数据库管理功能。该功能可以对集群中的数据库进行集中管理&#xff0c;可以查看各个数据库详细信息。能够方便的对数据库进行新建、构建、导出、备份、还原、删除操作。 登录gMaster&#xff0c;点击左侧菜单【数据库】下的【数据库管理】&#xff0c;进入数据库…

数据脱敏(六)脱敏算法-加密算法

脱敏算法篇使用阿里云数据脱敏算法为模板,使用算子平台快速搭建流程来展示数据 "加密脱敏"是一种数据处理技术&#xff0c;主要用于保护个人隐私和数据安全。它通过将敏感信息&#xff08;如姓名、身份证号、电话号码等&#xff09;进行加密处理&#xff0c;使其无法…

linux 系统的目录结构

为什么某些执行程序位于/bin、/sbin、/usr/bin或/usr/sbin目录下&#xff1f;例如&#xff0c;less命令位于/usr/bin目录下。为什么不是/bin、/sbin或/usr/sbin&#xff1f;这些目录之间有什么区别呢&#xff1f; 在这篇文章中&#xff0c;让我们主要讲述一下Linux文件系统结构…
最新文章