【学习笔记】Windows GDI绘图(七)图形路径GraphicsPath详解(下)

news2024/9/23 13:27:48

文章目录

  • 前三篇回顾
  • GraphicsPath方法
    • Flatten压平(将曲线转成线段)
    • GetBounds获取外接矩形
    • GetLastPoint获取路径最后一个点
    • IsOutlineVisible
    • IsVisiable是否在轮廓上或内部
    • Reset重置
    • Reverse逆转点的顺序
    • Transform矩阵变换
    • Wrap扭曲变换
    • Widen将路径替换为指定画笔的填充区域

前三篇回顾

【学习笔记】Windows GDI绘图(五)图形路径GraphicsPath详解(上)

  • 图形路径GraphicsPath
    填充模式FillMode
  • 构造函数
    GraphicsPath()
    GraphicsPath(FillMode)
    GraphicsPath(Point[],Byte[])和GraphicsPath(PointF[], Byte[])
    GraphicsPath(Point[], Byte[], FillMode)和GraphicsPath(PointF[], Byte[], FillMode)
    PathPointType
  • 属性
    FillMode
    PathData
    PathPoints、PathTypes
    PointCount
  • 方法
    AddArc添加椭圆弧
    AddBezier添加贝赛尔曲线
    AddClosedCurve添加封闭基数样条曲线
    AddCurve添加基数样条曲线(开放)
    AddEllipse添加椭圆
    AddLine添加线段

【学习笔记】Windows GDI绘图(六)图形路径GraphicsPath详解(中)

  • AddLines添加线段
  • AddPath附加路径
  • AddPie添加饼形
  • AddPolygon添加多边形
  • AddRectangle和AddRectangles 添加矩形
  • AddString添加字符串
  • SetMarkers设置标记
  • ClearMarkers清空标记
  • StartFigure开始新的图形
  • CloseAllFigures闭合所有图形、CloseFigure闭合当前图形

Window GDI+ API有BUG?GetBounds测不准?

  • 详细说明GetBounds方法
    全文图像
    全文图像

GraphicsPath方法

Flatten压平(将曲线转成线段)

原型:

public void Flatten ();
public void Flatten (System.Drawing.Drawing2D.Matrix? matrix);//默认flatness=0.25
public void Flatten (System.Drawing.Drawing2D.Matrix? matrix, float flatness);
参数说明
martix变换矩阵
flatness曲线转线段的最大误差,默认值是0.25。
值越小,越接近曲线,线段数量越多。

将此路径中的每条曲线转换为一系列连接的线段。

GraphicsPath myPath = new GraphicsPath();
Matrix translateMatrix = new Matrix();
translateMatrix.Translate(0, 0);
Point point1 = new Point(20, 200);
Point point2 = new Point(100, 30);
Point point3 = new Point(230, 300);
Point point4 = new Point(380, 150);
Point[] points = { point1, point2, point3, point4 };
myPath.AddCurve(points);

e.Graphics.DrawPath(new Pen(Color.LightGreen, 5), myPath);
myPath.Flatten(translateMatrix, 25f);
e.Graphics.DrawPath(new Pen(Color.Black, 1), myPath);

//原曲线控制点
foreach (var pt in points)
{
    e.Graphics.FillEllipse(Brushes.Red, pt.X - 5, pt.Y - 5, 10, 10);
}

//Flatten后的点
foreach( var pt in myPath.PathPoints )
{
    e.Graphics.FillEllipse(Brushes.Black, pt.X - 3, pt.Y - 3, 6, 6);
}

Flatten

GetBounds获取外接矩形

原型:

public System.Drawing.RectangleF GetBounds ();
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Pen? pen);

获取路径的外接矩形,关于使用pen参数后,获取结果貌似“松弛”问题,可查阅Window GDI+ API有BUG?GetBounds测不准?

var rect = new Rectangle(200, 200, 300, 200);

using(var path=new GraphicsPath())
{
    path.AddEllipse(rect);

    //用于确定椭圆的矩形
    e.Graphics.DrawRectangle(new Pen(Color.LightGreen,10),rect);

    var pathPen = new Pen(Color.Green, 50);
    pathPen.MiterLimit = 1;

    var bboxWithPen = path.GetBounds(new Matrix(), pathPen);
    //含pen参数的外接矩形
    e.Graphics.DrawRectangle(Pens.Black,
                             bboxWithPen.X + pathPen.Width / 2, 
                             bboxWithPen.Y + pathPen.Width / 2, 
                             bboxWithPen.Width - pathPen.Width, 
                             bboxWithPen.Height - pathPen.Width);


    //绘制椭圆
    e.Graphics.DrawPath(pathPen, path);

    var bboxWitoutPen = path.GetBounds();

    //不含pen参数的外接矩形
    e.Graphics.DrawRectangles(new Pen(Color.Red, 3), new RectangleF[] { bboxWitoutPen });
}

定义一个矩形,根据这个矩形绘制一个椭圆,其中pen的宽度为50,获取含pen与不含pen时其外接矩形的大小。
GetBounds

GetLastPoint获取路径最后一个点

原型:

public System.Drawing.PointF GetLastPoint ();

作用:获取GraphicsPath中路径的最后一个点。

var pt1 = new Point(200, 200);
var pt2 = new Point(300, 300);

using (var path = new GraphicsPath())
{
    path.AddLine(pt1,pt2);

    //绘制路径
    e.Graphics.DrawPath(new Pen(Color.Red, 10), path);

    //获取路径最后一个点的坐
    var lastPoint=path.GetLastPoint();
    int offset = 20;
    //显示最后一点的坐标
    DrawString(e, $"LastPoint:({lastPoint.X},{lastPoint.Y})", ref offset);
}

定义两个点,按线段方式添加到图形路径中,再通过GetLastPoint()获取其最后一个点的坐标。

在这里插入图片描述

IsOutlineVisible

原型:

public bool IsOutlineVisible (int x, int y, System.Drawing.Pen pen, System.Drawing.Graphics? graphics);
public bool IsOutlineVisible (System.Drawing.Point pt, System.Drawing.Pen pen, System.Drawing.Graphics? graphics);
public bool IsOutlineVisible (float x, float y, System.Drawing.Pen pen, System.Drawing.Graphics? graphics);
public bool IsOutlineVisible (float x, float y, System.Drawing.Pen pen);
public bool IsOutlineVisible (System.Drawing.PointF point, System.Drawing.Pen pen);
public bool IsOutlineVisible (System.Drawing.PointF pt, System.Drawing.Pen pen, System.Drawing.Graphics? graphics);
public bool IsOutlineVisible (int x, int y, System.Drawing.Pen pen);
public bool IsOutlineVisible (System.Drawing.Point point, System.Drawing.Pen pen);

作用:使用指定的Pen绘制时,指定的点是否包含在此GraphicsPath的轮廓内。
要判断的点在边缘处时,不同的笔宽返回值略有不同,使用时需注意。

[System.ComponentModel.Description("GraphicsPath的IsOutlineVisiable方法")]
public void Demo07_04(PaintEventArgs e)
{
    var rect = new Rectangle(300, 200, 300, 200);

    using (var path = new GraphicsPath(FillMode.Winding))
    {
        path.AddRectangle(rect);

        var penWidth = 1f;
        var halfPenWidth = penWidth / 2f;

        var pathPen = new Pen(Color.Red, penWidth);

        //绘制路径
        e.Graphics.DrawPath(pathPen, path);
        int offset = 10;
        DrawString(e,$"Rect:({rect.X},{rect.Y},{rect.Width},{rect.Height}) penWidth:{pathPen.Width}",ref offset);
        var y = (rect.Top + rect.Bottom) / 2.0f;

        var pt = new PointF(rect.X - halfPenWidth - 1f, y);
        DrawString(e, $"({pt.X},{pt.Y}) IsOutlineVisiable:{path.IsOutlineVisible(pt, pathPen)})", ref offset);
        DrawCross(e, pt, Color.Black);

        pt = new PointF(rect.X - halfPenWidth-0.5f, y);
        DrawString(e, $"({pt.X},{pt.Y}) IsOutlineVisiable:{path.IsOutlineVisible(pt, pathPen)})", ref offset);
        DrawCross(e, pt, Color.Black);

        pt = new PointF(rect.X + halfPenWidth - 1f, y);
        DrawString(e, $"({pt.X},{pt.Y}) IsOutlineVisiable:{path.IsOutlineVisible(pt, pathPen)})", ref offset);
        DrawCross(e, pt, Color.Black);

        pt = new PointF(rect.X + halfPenWidth - 0.5f, y);
        DrawString(e, $"({pt.X},{pt.Y}) IsOutlineVisiable:{path.IsOutlineVisible(pt, pathPen)})", ref offset);
        DrawCross(e, pt, Color.Black);

        pt = new Point(450, 300);
        // 在轮廓包围的里面,也不算在轮廓上
        DrawString(e, $"({pt.X},{pt.Y}) IsOutlineVisiable:{path.IsOutlineVisible(pt, pathPen)})", ref offset);
        DrawCross(e, pt, Color.Black);
    }
}

/// <summary>
/// 给定中心点,画十字架
/// </summary>
/// <param name="e"></param>
/// <param name="center"></param>
/// <param name="color"></param>
/// <param name="len"></param>
/// <param name="penWidth"></param>
private void DrawCross(PaintEventArgs e,PointF center,Color color, int len=40, float penWidth=1f)
{
    var half = len / 2.0f;
    using (var pen = new Pen(color, penWidth))
    {
        e.Graphics.DrawLine(pen, center.X, center.Y - half, center.X, center.Y + half);
        e.Graphics.DrawLine(pen, center.X-half, center.Y, center.X+half, center.Y );
    }
}

笔宽为1时
在这里插入图片描述
笔宽为10时
在这里插入图片描述

IsVisiable是否在轮廓上或内部

原型:

public bool IsVisible (System.Drawing.Point point);
public bool IsVisible (System.Drawing.PointF point);
public bool IsVisible (System.Drawing.Point pt, System.Drawing.Graphics? graphics);
public bool IsVisible (System.Drawing.PointF pt, System.Drawing.Graphics? graphics);
public bool IsVisible (int x, int y);
public bool IsVisible (float x, float y);
public bool IsVisible (int x, int y, System.Drawing.Graphics? graphics);
public bool IsVisible (float x, float y, System.Drawing.Graphics? graphics);

作用:判断一个点是否在轮廓上或内部(与IsOutlineVisiable的差别时,IsOutlineVisable只判断是在轮廓上),如果路径是未封闭图形,会自动封闭?

        [System.ComponentModel.Description("GraphicsPath的IsVisiable方法")]
        public void Demo07_05(PaintEventArgs e)
        {
            var rect = new Rectangle(300, 200, 300, 200);

            using (var path = new GraphicsPath(FillMode.Winding))
            {
                path.AddRectangle(rect);

                var penWidth = 10f;
                var halfPenWidth = penWidth / 2f;

                var pathPen = new Pen(Color.Red, penWidth);

                //绘制路径
                e.Graphics.DrawPath(pathPen, path);
                int offset = 10;
                DrawString(e, $"Rect:({rect.X},{rect.Y},{rect.Width},{rect.Height}) penWidth:{pathPen.Width}", ref offset);
                var y = (rect.Top + rect.Bottom) / 2.0f;

                var pt = new PointF(rect.X - halfPenWidth - 1f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new PointF(rect.X - halfPenWidth - 0.5f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new PointF(rect.X + halfPenWidth - 1f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new PointF(rect.X + halfPenWidth - 0.5f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new Point(450, 300);
                // 在轮廓包围的里面,也不算在轮廓上
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);
            }
        }

        [System.ComponentModel.Description("GraphicsPath的IsVisiable方法")]
        public void Demo07_06(PaintEventArgs e)
        {
            var rect = new Rectangle(300, 200, 300, 200);
            var pts = new Point[]
            {
                new Point(300,400),
                new Point(400,150),
                new Point(500,420)
            };

            using (var path = new GraphicsPath(FillMode.Winding))
            {
                path.AddCurve(pts);

                var penWidth = 10f;
                var halfPenWidth = penWidth / 2f;

                var pathPen = new Pen(Color.Red, penWidth);

                //绘制路径
                e.Graphics.DrawPath(pathPen, path);
                int offset = 10;
                DrawString(e, $"Rect:({rect.X},{rect.Y},{rect.Width},{rect.Height}) penWidth:{pathPen.Width}", ref offset);
                var y = (rect.Top + rect.Bottom) / 2.0f;

                var pt = new PointF(rect.X - halfPenWidth - 1f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new PointF(rect.X - halfPenWidth - 0.5f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new PointF(rect.X + halfPenWidth - 1f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new PointF(rect.X + halfPenWidth - 0.5f, y);
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);

                pt = new Point(450, 300);
                // 在轮廓包围的里面,也不算在轮廓上
                DrawString(e, $"({pt.X},{pt.Y}) IsVisible:{path.IsVisible(pt)})", ref offset);
                DrawCross(e, pt, Color.Black);
            }
        }

创建一个矩形和一个开放的曲线,判断点。

IsVisiable
IsVisable

Reset重置

原型:

public void Reset ();

作用:清空路径并将FillMode置为Alternate。

Reverse逆转点的顺序

原型:

public void Reverse ();

作用:逆转GraphicsPath中PathPoints的点的顺序。

var rect = new Rectangle(200, 200, 400, 250);
var pts = new Point[]
{
    new Point(300,400),
    new Point(400,150),
    new Point(500,420)
};

using (var path = new GraphicsPath(FillMode.Winding))
{
    path.AddRectangle(rect);
    path.AddCurve(pts);

    var penWidth = 10f;

    var pathPen = new Pen(Color.Red, penWidth);

    //绘制路径
    e.Graphics.DrawPath(pathPen, path);

    //逆转
    path.Reverse();

    e.Graphics.DrawPath(Pens.Black, path);
}

Reverse

Transform矩阵变换

原型:

public void Transform (System.Drawing.Drawing2D.Matrix matrix);

作用:应用一个矩阵变换到GraphicsPath中

var rect = new Rectangle(200, 200, 300, 200);        

using (var path = new GraphicsPath(FillMode.Winding))
{
    path.AddRectangle(rect);
    //原始矩形
    e.Graphics.DrawPath(Pens.Red,path);

    var matrix = new Matrix();
    //向右、向下各偏移100
    matrix.Translate(100, 100, MatrixOrder.Append);
    path.Transform(matrix);
    e.Graphics.DrawPath(Pens.Black, path);

    matrix.Reset();
    //缩小0.5倍
    matrix.Scale(0.5f, 0.5f, MatrixOrder.Append);
    path.Transform(matrix);
    e.Graphics.DrawPath(Pens.LightGreen, path);
}

定义一个矩形,先向右、向左平移,再缩小0.5倍
Transform

Wrap扭曲变换

原型:

public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect);
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix);
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode);
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness);

作用:通过定义目标平行四边形的三个顶点(左上角、右上角和左下角)或四边形的四个顶点来扭曲GraphicsPath中的路径。

var srcRect = new Rectangle(200, 200, 300, 200);
Point point1 = new Point(20, 200);
Point point2 = new Point(100, 30);
Point point3 = new Point(230, 300);
Point point4 = new Point(380, 150);
Point[] points = { point1, point2, point3, point4 };

using (var path = new GraphicsPath(FillMode.Winding))
{

    path.AddCurve(points);
    path.AddRectangle(srcRect);
    //原始矩形
    e.Graphics.DrawPath(new Pen(Color.Red,3), path);

    //定义平行四边形三个顶点(左上角、右上角、左下角)
    var destPtList = new List<PointF>()
    {
        new PointF(300,300),
        new PointF(600,250),
        new PointF(200,450)
    };

    // Create a translation matrix.
    Matrix translateMatrix = new Matrix();
    // Warp the source path (rectangle).

    path.Warp(destPtList.ToArray(), srcRect, translateMatrix, WarpMode.Perspective, 0.5f);
    e.Graphics.DrawPath(new Pen(Color.LightGreen, 3), path);

    //加一个点,自定义四边形
    destPtList.Add(new PointF(550, 450));
    //需要重置,不重置的话,是在前面warp变换后,再次变换
    path.Reset();
    path.AddCurve(points);
    path.AddRectangle(srcRect);
    path.Warp(destPtList.ToArray(), srcRect, translateMatrix, WarpMode.Perspective, 0.5f);
    e.Graphics.DrawPath(new Pen(Color.LightBlue, 3), path);

    //
    path.Reset();
    path.AddCurve(points);
    path.AddRectangle(srcRect);
    translateMatrix.Translate(100, 50);
    path.Warp(destPtList.ToArray(), srcRect, translateMatrix, WarpMode.Perspective, 0.5f);
    e.Graphics.DrawPath(new Pen(Color.Pink, 3), path);

}

Wrap

Widen将路径替换为指定画笔的填充区域

原型:

public void Widen (System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix? matrix);
public void Widen (System.Drawing.Pen pen);
public void Widen (System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix? matrix, float flatness);

作用:将路径替换为指定画笔的填充区域(类似获取膨胀后的轮廓)

 // 创建两个正方形.
 GraphicsPath myPath = new GraphicsPath();
 myPath.AddRectangle(new Rectangle(300, 100, 100, 100));
 myPath.AddRectangle(new Rectangle(450, 100, 100, 100));

 // Draw the original ellipses to the screen in black.
 e.Graphics.DrawPath(Pens.Black, myPath);

 int offset = 5;
 DrawString(e, $"Src PointCount={myPath.PointCount}", ref offset);
 for(int i=0;i<myPath.PointCount;i++)
 {
     var pt = myPath.PathPoints[i];
     var type = myPath.PathTypes[i];
     DrawString(e, $"\tPoint:({pt.X},{pt.Y}),types:{type}", ref offset);
 }

 // Widen the path.
 Pen widenPen = new Pen(Color.Black, 20);
 Matrix widenMatrix = new Matrix();
 //widenMatrix.Translate(50, 50);
 myPath.Widen(widenPen, widenMatrix, 1.0f);

 //绘制Widden后的路径
 e.Graphics.DrawPath(new Pen(Color.Red,3), myPath);
 //这里用FillPath
 e.Graphics.FillPath(new SolidBrush(Color.FromArgb(127,Color.LightGreen)), myPath);
  DrawString(e, $"Widen PointCount={myPath.PointCount}", ref offset);
 for (int i = 0; i < myPath.PointCount; i++)
 {
     var pt = myPath.PathPoints[i];
     var type = myPath.PathTypes[i];
     DrawString(e, $"\tPoint:({pt.X},{pt.Y}),types:{type}", ref offset);
     e.Graphics.FillEllipse(Brushes.Gold, pt.X - 3, pt.Y - 3, 6, 6);
 }

绘制两个正方形,使用20像素宽的Pen对路径进行Widden后,填充其路径,就标记路径的各个点。

Widden

感谢您的拜读,如果对本系列文章的源码感兴趣,请在评讨区留言Email

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Leetcode42题:接雨水

1.题目描述 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图&#xff0c;计算按此排列的柱子&#xff0c;下雨之后能接多少雨水。 示例1&#xff1a; 输入&#xff1a;height [0,1,0,2,1,0,1,3,2,1,2,1] 输出&#xff1a;6 解释&#xff1a;上面是由数组 [0,1,0,2,1,0,1,…

一、Servlet和JSP技术概述

注&#xff1a;该系列笔记是用于我在 《Servlet 与 JSP 核心编程》这本书中的学习笔记&#xff0c;无其他意思&#xff0c;侵权请联系2082045221qq.com删除。 ​ 第一章内容较少&#xff0c;所以暂时有用的笔记也不多。 1.1、Servlet 的功用&#xff1a; ​ Servlet 是运行在…

小白入职 必要熟悉 Git / tortoiseGit 工具

1.安装Git 1.1 了解Git Git是分布式版本控制系统&#xff0c;没有中央服务器的每个人的电脑就是一个完整的版本库&#xff0c;工作时无需联网可多人协作&#xff0c;只需把各自的修改推送给对方&#xff0c;就可以互相看到对方的修改了 分布式版本控制工具管理方式&#xff…

【FPGA】Verilog:奇校验位生成器的实现(Odd Parity bit generator)

解释奇数奇偶校验位生成器和检查器的仿真结果及过程。 真值表和卡洛图: Odd Parity Bit Generator A B C

【LeetCode刷题】滑动窗口思想解决:最大连续1的个数 III、将x减到0的最小操作数

【LeetCode刷题】Day 8 题目1&#xff1a;1004.最大连续1的个数 III思路分析&#xff1a;思路1&#xff1a;暴力枚举zero计数器思路2&#xff1a;滑动窗口zero计数器 题目2&#xff1a;1658. 将x减到0的最小操作数思路分析&#xff1a;思路1&#xff1a;暴力枚举思路2&#xff…

链式二叉树的前,中,后序遍历 AND 结点个数及高度等 文末附带全部代码

目录 前言1. 前序遍历2. 中序遍历3. 后续遍历4. 二叉树结点的个数5. 二叉树叶子结点个数6. 二叉树的高度7. 二叉树第K层结点的个数8. 二叉树查找值为x的结点全部代码总结 正文开始 前言 本文旨在介绍二叉树的链式存储中一些函数的实现 博客主页: 酷酷学!!! 更多文章, 期待关…

​✨聚梦AI绘图插件-for photoshop(基于ComfyUI) 内测版V0.1发布

&#x1f388;背景 photoshop本身是有AI生成能力的&#xff0c;不过限于种种原因&#xff0c;国内使用很不方便。 photoshop也是有AI插件的&#xff0c;不过大多安装起来比较复杂&#xff0c;或者&#xff0c;干脆就会收费。 所以我们做了一个免费的AI插件&#xff0c;期望能…

使用逻辑回归模型进行信用卡信用分类002

代码 代码获取方式&#xff1a;链接&#xff1a;https://pan.baidu.com/s/1p4dHAyoG0nQzlRaT2VnKIA?pwdn474 提取码&#xff1a;n474 count_classes pd.value_counts(data[Class], sort True).sort_index() 直方图统计数量&#xff1a; 切分数据集&#xff1a; X_train…

设计模式在芯片验证中的应用——模板方法

一、模板方法 模板方法(Template Method)设计模式是一种行为设计模式&#xff0c; 它在父类中定义了一个功能的框架&#xff0c; 允许子类在不修改结构的情况下重写功能的特定步骤。也就是模板方法定义了一组有序执行的操作&#xff0c;将一些步骤的实现留给子类&#xff0c;同…

world machine学习笔记(4)

选择设备&#xff1a; select acpect&#xff1a; heading&#xff1a;太阳的方向 elevation&#xff1a;太阳的高度 select colour&#xff1a;选择颜色 select convexity&#xff1a;选择突起&#xff08;曲率&#xff09; select height&#xff1a;选择高度 falloff&a…

Celery的Web监控工具Flower

1 简介Flower Flower官网 Flower是一个WEB端的监控工具&#xff0c;可以监控Celery的消费者。但是WEB端的监控对于监控系统来说&#xff0c;有个屁用&#xff0c;有用的是监控告警。还好Flower不是全部是垃圾&#xff0c;它提供的Prometheus的监控端点。然而。。。。。如何保证…

【C语言】二叉树的实现

文章目录 前言⭐一、二叉树的定义&#x1f6b2;二、创建二叉树&#x1f3a1;三、二叉树的销毁&#x1f389;四、遍历二叉树1. 前序遍历2. 中序遍历3. 后序遍历4. 层序遍历 &#x1f332;五、二叉树的计算1. 计算二叉树结点个数2. 计算二叉树叶子结点的个数3. 计算二叉树的深度4…

Spring Boot Interceptor(拦截器使用及原理)

之前的博客中讲解了关于 Spring AOP的思想和原理&#xff0c;而实际开发中Spring Boot对于AOP的思想的具体实现就是Spring Boot Interceptor。在 Spring Boot 应用程序开发中&#xff0c;拦截器&#xff08;Interceptor&#xff09;是一个非常有用的工具。它允许我们在 HTTP 请…

kali基本扫描工具(自带)

免责声明:本文仅做技术交流与学习...请勿非法破坏... 详细用法: 命令 -h/百度/翻译 fping 用法 hostlist 文件里面为ip fping -a -q -f hostlist -a 只看存活的 fping -g 202.100.1.1 202.100.1.255 -a -q > Ahost 输出到Ahost文件上 nping nping -c 1 201.100.2.155-244 …

动态规划之背包问题中如何确定遍历顺序的问题-组合or排列?

关于如何确定遍历顺序 322. 零钱兑换中&#xff0c;本题求钱币最小个数&#xff0c;那么钱币有顺序和没有顺序都可以&#xff0c;都不影响钱币的最小个数。 所以本题并不强调集合是组合还是排列。 如果求组合数就是外层for循环遍历物品&#xff0c;内层for遍历背包。 如果求…

【数据结构】二叉树的认识与实现

目录 二叉树的概念&#xff1a; 二叉树的应用与实现&#xff1a; 二叉树实现接口&#xff1a; 通过前序遍历的数组"ABD##E#H##CF##G##"构建二叉树 二叉树节点个数​编辑 二叉树叶子节点个数 二叉树第k层节点个数 二叉树查找值为x的节点​编辑 二叉树前序遍…

Day 3:1738. 找出第 K 大的异或坐标值

Leetcode 1738. 找出第 K 大的异或坐标值 给你一个二维矩阵 matrix 和一个整数 k &#xff0c;矩阵大小为 m x n 由非负整数组成。 矩阵中坐标 (a, b) 的 值 可由对所有满足 0 < i < a < m 且 0 < j < b < n 的元素 matrix[i][j]&#xff08;下标从 0 开始计…

【Linux】进程通信实战 —— 进程池项目

送给大家一句话: 没有一颗星&#xff0c;会因为追求梦想而受伤&#xff0c;当你真心渴望某样东西时&#xff0c;整个宇宙都会来帮忙。 – 保罗・戈埃罗 《牧羊少年奇幻之旅》 &#x1f3d5;️&#x1f3d5;️&#x1f3d5;️&#x1f3d5;️&#x1f3d5;️&#x1f3d5;️ &a…

# linux 系统 没有 ifconfig 命令,提示: ifconfig: command not found

sudo ip route add default via 192.168.1.1 dev eth0# linux 系统 没有 ifconfig 命令&#xff0c;提示&#xff1a; ifconfig: command not found 一、问题描述&#xff1a; 有些伙伴在学习 linux 系统时&#xff0c;在 使用 ifconfig 命令 查询 系统 IP 出现 ifconfig: co…

【LakeHouse】Apache Iceberg + Amoro 助力网易构建云原生湖仓

Apache Iceberg Amoro 助力网易构建云原生湖仓 1.云原生湖仓背景与挑战2.Apache Iceberg 、Amoro 与云原生2.1 Apache Iceberg2.2 Amoro 简介 3.Apache Iceberg Amoro 云原生实践3.1 云上湖仓案例一3.2 云上湖仓案例二3.3 云上湖仓案例三 4.Amoro 未来发展规划 出品社区&…