17.2 圖形繪制8

版權聲明:本文為博主原創文章,轉載請在顯著位置標明本文出處以及作者網名,未經作者允許不得用于商業目的。

17.2.10 重繪

先看以下例子:

【例 17.28【項目:code17-028】繪制填充矩形。

??????? private void button1_Click(object sender, EventArgs e)

??????? {

??????????? Graphics g = this.CreateGraphics();

??????????? g.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(260, 20, 100, 100));

??????? }

??????? private void Form1_Load(object sender, EventArgs e)

??????? {

??????????? Graphics g = this.CreateGraphics();

??????????? g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(20, 20, 100, 100));

??????? }

??????? private void Form1_Paint(object sender, PaintEventArgs e)

??????? {

??????????? Graphics g = this.CreateGraphics();

??????????? g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(140, 20, 100, 100));

??????? }

這個例子在窗體Load、窗體Paint、按鈕Click時分別繪制了紅色、綠色、藍色填充的矩形。

當運行時:

圖17-31 運行時只顯示綠色矩形

按下按鈕時:

圖17-32 顯示綠色和藍色矩形

最小化又恢復后:

圖17-33 顯示綠色矩形

原本的計劃是:1、在Load的時候繪制一個紅色正方形;2、在Paint的時候繪制一個綠色正方形;3、在按下按鈕的時候繪制一個藍色正方形;一共三個矩形。

運行后窗體上只顯示了綠色而沒有顯示紅色矩形,因為窗口Load事件之后是Paint事件,而Paint執行的時候將界面刷新了,對整個窗口進行了重繪:先是清除之前繪制的內容,然后按照Paint里面代碼做了繪制,所以綠色矩形正常顯示,而紅色矩形沒有顯示。同樣的,最小化后再恢復窗口,也觸發了窗體的Paint事件,進行了重繪,所以綠色矩形在而藍色矩形沒有了。

分析了造成矩形不顯示的原因,那么針對重繪的問題,也就有了以下解決方法:只需要把繪制的圖形保存下來,當重繪時在繪制出來即可。

【例 17.29【項目:code17-029】防止重繪時圖形消失。

??????? //用來保存繪制的圖形

??????? Bitmap bmp;

??????? Graphics g;

??????? private void Form1_Load(object sender, EventArgs e)

??????? {

??????????? //使圖像寬度和高度與窗體相同

??????????? bmp = new Bitmap(this.Width, this.Height);

??????????? //通過圖像創建Graphic

??????????? g = Graphics.FromImage(bmp);

??????????? g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(20, 20, 100, 100));

??????????? ShowImg();

??????? }

??????? private void button1_Click(object sender, EventArgs e)

??????? {

??????????? g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(140, 20, 100, 100));

??????????? g.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(260, 20, 100, 100));

??????????? ShowImg();

??????? }

??????? private void Form1_Paint(object sender, PaintEventArgs e)

??????? {

??????????? ShowImg();

??????? }

??????? //在窗體上顯示圖像

? ??????private void ShowImg()

??????? {

??????????? Graphics gPaint = this.CreateGraphics();

??????????? gPaint.DrawImage(bmp, new Point(0, 0));

??????? }

??????? private void Form1_FormClosing(object sender, FormClosingEventArgs e)

??????? {

??????????? g.Dispose();

??????????? bmp.Dispose();

??????? }

這下,窗體Load時的紅色正方形以及按下按鈕后的綠色和藍色矩形,即使窗體最小化也不怕消失了。

17.2.11 繪制統計圖

【例 17.30【項目:code17-030】繪制統計圖

假設知道某個公司1-4季度的經營利潤情況,完成統計圖的繪制。

新建一個窗體,主要使用到的控件如下:

添加4個Label控件,分別是“一季度”、“二季度”、“三季度”、“四季度”。

添加4個NumericUpDown控件,名稱從 nudSeason1至 nudSeason4。

添加1個ComboBox控件,名稱為cbType,代碼中為它的Items增加柱狀圖、折線圖、扇形圖、環形圖。

添加1個PictureBox控件,名稱為pbShow,將在這里面顯示統計圖。

添加2個Button控件,名稱分別為btnCreate和btnSave,Text屬性分別為“生成”和“保存”。當按下“生成”按鈕后,將在pbShow中顯示統計圖;當按下“保存”按鈕后,將彈出保存文件對話框,設置文件名后將統計圖保存下來。

具體代碼如下:

??????? Graphics g;

??????? Bitmap bmp;

??????? //刻度線每份對應的數量

??????? float perScaleValue;

??????? //原點x軸移動

??????? int TranslateX = 40;

??????? //原點y軸移動

??????? int TranslateY = 40;

??????? //季度(x軸)之間間隔

??????? int xSpan = 60;

??????? private void Form1_Load(object sender, EventArgs e)

??????? {

??????????? bmp = new Bitmap(pbShow.Width, pbShow.Height);

??????????? g = Graphics.FromImage(bmp);

??????????? cbType.Items.Add("柱形圖");

??????????? cbType.Items.Add("折線圖");

??????????? cbType.Items.Add("扇形圖");

??????????? cbType.Items.Add("環形圖");

??????????? cbType.Text = cbType.Items[0].ToString();

??????? }

??????? private void btnCreate_Click(object sender, EventArgs e)

??????? {

??????????? g.Clear(System.Drawing.Color.White);

??????????? switch(cbType.Text)

??????????? {

??????????????? case "柱形圖":

??????????????????? DrawAxis();

??????????????????? DrawBarGraph();

??????????????????? break;

??????????????? case "折線圖":

??????????????????? DrawAxis();

??????????????????? DrawLine();

????????????????? ??break;

??????????????? case "扇形圖":

??????????????????? DrawPie();

??????????????????? break;

??????????????? case "環形圖":

??????????????????? DrawAnnular();

??????????????????? break;

??????????????? default:

??????????????????? break;

??????????? }

??????????? pbShow.Image = bmp;

??????? }

???????

??????? //繪制坐標軸

??????? private void DrawAxis()

??????? {

??????????? int[] seasonValue = new int[4];

??????????? seasonValue[0] = (int)nudSeason1.Value;

??????????? seasonValue[1] = (int)nudSeason2.Value;

??????????? seasonValue[2] = (int)nudSeason3.Value;

??????????? seasonValue[3] = (int)nudSeason4.Value;

??????????? //獲得最大值

??????????? int seasonMax = seasonValue.Max();

??????????? //獲得需要的刻度數量

??????????? int scaleCount;

??????????? scaleCount = seasonMax / 10 + 1;

??????????? //使用紅色繪制坐標軸

??????????? Pen p = new Pen(System.Drawing.Color.Red, 1);

??????????? //坐標軸末尾箭頭

??????????? p.EndCap = LineCap.ArrowAnchor;

??????????? int AxisYHeight;

??????????? AxisYHeight = pbShow.Height - TranslateY * 2;

??????????? perScaleValue = AxisYHeight / scaleCount;

??????????? //坐標原點

??????????? int originX = TranslateX;

??????????? int originY = pbShow.Height - TranslateY;

??????????? Point originPoint = new Point(originX, originY);

??????????? //繪制橫坐標

??????????? g.DrawLine(p, originPoint, new Point(pbShow.Width - TranslateX, originY));

??????????? //繪制縱坐標

??????????? g.DrawLine(p, originPoint, new Point(originX, TranslateY));

??????????? //紅色繪制坐標軸刻度

??????????? Pen pAxisY = new Pen(System.Drawing.Color.Red, 1);

??????????? Point AxisYPos;

??????????? string AxisYValue;

??????????? //在縱軸上標明刻度線,每10個刻度標注一下

??????????? for(int i = 0;i< scaleCount;i++)

??????????? {

??????????????? //刻度值

??????????????? AxisYValue = (i * 10).ToString();

??????????????? //刻度位置

??????????????? AxisYPos = new Point(20, originY - i * (int)perScaleValue - 5);

??????????????? //標明刻度值

??????????????? g.DrawString(AxisYValue, new Font("宋體", 10), new SolidBrush(System.Drawing.Color.Blue), AxisYPos);

??????????????? //畫刻度,實際0刻度線是和橫坐標軸重合

??????????????? g.DrawLine(pAxisY, new Point(TranslateX, originY - i * (int)perScaleValue), new Point(TranslateX + 10, originY - i * (int)perScaleValue));

??????????? }

??????? }

???????

??????? //繪制柱狀圖

??????? private void DrawBarGraph()

??????? {

??????????? //標注每個季度

??????????? int[] seasonValue = new int[4];

??????????? seasonValue[0] = (int)nudSeason1.Value;

??????????? seasonValue[1] = (int)nudSeason2.Value;

??????????? seasonValue[2] = (int)nudSeason3.Value;

??????????? seasonValue[3] = (int)nudSeason4.Value;

??????????? string[] seasonName = { "一季度", "二季度", "三季度", "四季度" };

??????????? //立柱(矩形)的左上角坐標點

??????????? int recX, recY;

??????????? //循環畫四個矩形

??????????? for(int i = 0;i<4;i++)

??????????? {

??????????????? recX = (i + 1) * xSpan;

??????????????? recY = pbShow.Height - TranslateY - (int)(seasonValue[i] / 10 * perScaleValue);

??????????????? g.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(recX, recY, 40, (int)(seasonValue[i] / 10 * perScaleValue)));

??????????? }

??????????? //標出每個季度

??????????? int strX, strY;

??????????? for(int i =0;i<4;i++)

??????????? {

??????????????? strX = (i + 1) * xSpan - 5;

??????????????? strY = pbShow.Height - TranslateY + 10;

??????????????? g.DrawString(seasonName[i], new Font("黑體", 10), new SolidBrush(Color.Blue), new Point(strX, strY));

??????????? }

??????? }

???????

??????? //繪制折線圖

??????? private void DrawLine()

??????? {

??????????? //標注每個季度

??????????? int[] seasonValue = new int[4];

??????????? seasonValue[0] = (int)nudSeason1.Value;

??????????? seasonValue[1] = (int)nudSeason2.Value;

??????????? seasonValue[2] = (int)nudSeason3.Value;

??????????? seasonValue[3] = (int)nudSeason4.Value;

??????????? string[] seasonName = { "一季度", "二季度", "三季度", "四季度" };

??????????? //先要獲得每個值所在的坐標點

??????????? //為了顯眼,繪制點的顯示為一個直徑為8的藍色圓形

??????????? int signX, signY;

??????????? //將每個坐標點存入數組,畫折線時候需要

??????????? Point[] pointSign = new Point[4];

??????????? for(int i =0; i<4; i++)

??????????? {

??????????????? signX = (i + 1) * xSpan + 10;

??????????????? signY = pbShow.Height - TranslateY - (int)(seasonValue[i] / 10 * perScaleValue);

??????????????? pointSign[i] = new Point(signX, signY);

??????????????? //請注意畫園時候的Rectangle位置

??????????????? g.FillEllipse(new SolidBrush(Color.Blue), new Rectangle(signX - 4, signY - 4, 8, 8));

??????????? }

??????????? //使用紅色畫折線

??????????? Pen penSign = new Pen(Color.Red, 2);

??????????? //將四個坐標點連接起來,注意畫的是三條線

??????????? for (int i = 0; i < 3; i++)

??????????????? g.DrawLine(penSign, pointSign[i], pointSign[i + 1]);

??????????? //標出每個季度

??????????? int strX, strY;

??????????? for(int i = 0;i<4;i++)

??????????? {

??????????????? strX = (i + 1) * xSpan - 5;

??????????????? strY = pbShow.Height - TranslateY + 10;

??????????????? g.DrawString(seasonName[i], new Font("黑體", 10), new SolidBrush(Color.Blue), new Point(strX, strY));

??????????? }

??????? }

???????

??????? //繪制扇形圖

??????? private void DrawPie()

??????? {

??????????? //標注每個季度

??????????? int[] seasonValue = new int[4];

??????????? seasonValue[0] = (int)nudSeason1.Value;

??????????? seasonValue[1] = (int)nudSeason2.Value;

??????????? seasonValue[2] = (int)nudSeason3.Value;

??????????? seasonValue[3] = (int)nudSeason4.Value;

??? ????????string[] seasonName = { "一季度", "二季度", "三季度", "四季度" };

??????????? //我們要獲得4個季度總的盈利

??????????? int seasonSum = 0;

??????????? for (int i = 0; i < 4; i++)

??????????????? seasonSum += seasonValue[i];

??????????? //根據總贏利情況,來獲得每個季度在餅圖中所占的份額(角度)

??????????? //為了簡化起見,這里直接取整數

??????????? int[] seasonAngle = new int[5];

??????????? seasonAngle[0] = 0;

??????????? seasonAngle[1] = seasonValue[0] * 360 / seasonSum;

??????????? seasonAngle[2] = seasonValue[1] * 360 / seasonSum + seasonAngle[1];

??????? ????seasonAngle[3] = seasonValue[2] * 360 / seasonSum + seasonAngle[2];

??????????? seasonAngle[4] = 360;

??????????? //分別用4種顏色表示不同季度的盈利

??????????? System.Drawing.Color[] seasonColor = { Color.Red, Color.Blue, Color.Green, Color.GreenYellow };

??????????? for(int i = 0;i<4;i++)

??????????? {

??????????????? g.FillPie(new SolidBrush(seasonColor[i]), new Rectangle(50, 80, 200, 200), seasonAngle[i], seasonAngle[i + 1] - seasonAngle[i]);

??????????????? //餅圖中特別需要說明每個季度對應的顏色

??????????????? g.FillRectangle(new SolidBrush(seasonColor[i]), new Rectangle(260, i * 30 + 20, 30, 20));

??????????????? //標出每個季度

??????????????? g.DrawString(seasonName[i], new Font("宋體", 12), new SolidBrush(Color.Black), new Point(300, i * 30 + 20));

??????????? }

??????? }

??????? //繪制環形圖

??????? private void DrawAnnular()

??????? {

??????????? //標注每個季度

??????????? int[] seasonValue = new int[4];

??????????? seasonValue[0] = (int)nudSeason1.Value;

??????????? seasonValue[1] = (int)nudSeason2.Value;

??????????? seasonValue[2] = (int)nudSeason3.Value;

??????????? seasonValue[3] = (int)nudSeason4.Value;

??????????? string[] seasonName = { "一季度", "二季度", "三季度", "四季度" };

??????????? //我們要獲得4個季度總的盈利

??????????? int seasonSum = 0;

??????????? for (int i = 0; i < 4; i++)

??????????????? seasonSum += seasonValue[i];

??????????? //根據總贏利情況,來獲得每個季度在餅圖中所占的份額(角度)

??????????? //為了簡化起見,這里直接取整數

??????????? int[] seasonAngle = new int[5];

??????????? seasonAngle[0] = 0;

??????????? seasonAngle[1] = seasonValue[0] * 360 / seasonSum;

??????????? seasonAngle[2] = seasonValue[1] * 360 / seasonSum + seasonAngle[1];

??????????? seasonAngle[3] = seasonValue[2] * 360 / seasonSum + seasonAngle[2];

??????????? seasonAngle[4] = 360;

??????????? //圓環內弧與外弧之間的距離

??????????? int xSpace = 50;

??????????? //分別用4種顏色表示不同季度的盈利

??????????? Color[] seasonColor = { Color.Red, Color.Blue, Color.Green, Color.GreenYellow };

??????????? //這里使用GraphicsPath和Region

??????????? for(int i=0; i<4;i++)

??????????? {

??????????????? //大的扇形

??????????????? GraphicsPath pathPieMax = new GraphicsPath();

??????????????? pathPieMax.AddPie(new Rectangle(50, 80, 200, 200), seasonAngle[i], seasonAngle[i + 1] - seasonAngle[i]);

??????????????? //小的扇形

??????????????? GraphicsPath pathPieMin = new GraphicsPath();

??? ????????????pathPieMin.AddPie(new Rectangle(50 + xSpace, 80 + xSpace, 200 - xSpace * 2, 200 - xSpace * 2), seasonAngle[i], seasonAngle[i + 1] - seasonAngle[i]);

??????????????? //圓環=大的扇形-小的扇形

??????????????? Region regoinAnnular = new Region(pathPieMax);

??????????????? regoinAnnular.Exclude(pathPieMin);

??????????????? //填充區域

??????????????? g.FillRegion(new SolidBrush(seasonColor[i]), regoinAnnular);

??????????????? //餅圖中特別需要說明每個季度對應的顏色

??????????????? g.FillRectangle(new SolidBrush(seasonColor[i]), new Rectangle(260, i * 30 + 20, 30, 20));

??????????????? //標出每個季度

??????????????? g.DrawString(seasonName[i], new Font("宋體", 12), new SolidBrush(Color.Black), new Point(300, i * 30 + 20));

??????????? }

??????? }

??????? //保存圖片

??????? private void btnSave_Click(object sender, EventArgs e)

??????? {

??????????? SaveFileDialog sfd = new SaveFileDialog();

??????????? sfd.Filter = "JPG文件|*.jpg";

??????????? if (sfd.ShowDialog() != DialogResult.OK)

??????????????? return;

??????????? string filename = sfd.FileName;

??????????? bmp.Save(filename);

??????? }

運行結果如下圖所示:

圖17-34 生成環狀圖

學習更多vb.net知識,請參看vb.net 教程 目錄

學習更多C#知識,請參看C#教程 目錄

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/67691.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/67691.shtml
英文地址,請注明出處:http://en.pswp.cn/web/67691.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

自定義數據集 使用pytorch框架實現邏輯回歸并保存模型,然后保存模型后再加載模型進行預測,對預測結果計算精確度和召回率及F1分數

import numpy as np import torch import torch.nn as nn import torch.optim as optim from sklearn.metrics import precision_score, recall_score, f1_score# 數據準備 class1_points np.array([[1.9, 1.2],[1.5, 2.1],[1.9, 0.5],[1.5, 0.9],[0.9, 1.2],[1.1, 1.7],[1.4,…

neo4j入門

文章目錄 neo4j版本說明部署安裝Mac部署docker部署 neo4j web工具使用數據結構圖數據庫VS關系數據庫 neo4j neo4j官網Neo4j是用ava實現的開源NoSQL圖數據庫。Neo4作為圖數據庫中的代表產品&#xff0c;已經在眾多的行業項目中進行了應用&#xff0c;如&#xff1a;網絡管理&am…

腳本運行禁止:npm 無法加載文件,因為在此系統上禁止運行腳本

問題與處理策略 1、問題描述 npm install -D tailwindcss執行上述指令&#xff0c;報如下錯誤 npm : 無法加載文件 D:\nodejs\npm.ps1&#xff0c;因為在此系統上禁止運行腳本。 有關詳細信息&#xff0c;請參閱 https:/go.microsoft.com/fwlink/?LinkID135170 中的 about_…

Java基礎——分層解耦——IOC和DI入門

目錄 三層架構 Controller Service Dao ?編輯 調用過程 面向接口編程 分層解耦 耦合 內聚 軟件設計原則 控制反轉 依賴注入 Bean對象 如何將類產生的對象交給IOC容器管理&#xff1f; 容器怎樣才能提供依賴的bean對象呢&#xff1f; 三層架構 Controller 控制…

智慧園區系統集成解決方案引領未來城市管理的智能化轉型

內容概要 在現代城市管理的背景下&#xff0c;“智慧園區系統集成解決方案”正扮演著越來越重要的角色。這種解決方案不僅僅是技術上的創新&#xff0c;更是一種全新的管理理念&#xff0c;它旨在通過高效的數據整合與分析&#xff0c;優化資源配置&#xff0c;提升運營效率。…

99.24 金融難點通俗解釋:MLF(中期借貸便利)vs LPR(貸款市場報價利率)

目錄 0. 承前1. 什么是MLF&#xff1f;1.1 專業解釋1.2 通俗解釋1.3 MLF的三個關鍵點&#xff1a; 2. 什么是LPR&#xff1f;2.1 專業解釋2.2 通俗解釋2.3 LPR的三個關鍵點&#xff1a; 3. MLF和LPR的關系4. 傳導機制4.1 第一步&#xff1a;央行調整MLF4.2 第二步&#xff1a;銀…

【VM】VirtualBox安裝CentOS8虛擬機

閱讀本文前&#xff0c;請先根據 VirtualBox軟件安裝教程 安裝VirtualBox虛擬機軟件。 1. 下載centos8系統iso鏡像 可以去兩個地方下載&#xff0c;推薦跟隨本文的操作用阿里云的鏡像 centos官網&#xff1a;https://www.centos.org/download/阿里云鏡像&#xff1a;http://…

Elasticsearch中的度量聚合:深度解析與實戰應用

在大數據和實時分析日益重要的今天&#xff0c;Elasticsearch以其強大的搜索和聚合能力&#xff0c;成為了眾多企業和開發者進行數據分析和處理的首選工具。本文將深入探討Elasticsearch中的度量聚合&#xff08;Metric Aggregations&#xff09;&#xff0c;展示其如何在數據分…

C_C++輸入輸出(下)

C_C輸入輸出&#xff08;下&#xff09; 用兩次循環的問題&#xff1a; 1.一次循環決定打印幾行&#xff0c;一次循環決定打印幾項 cin是>> cout是<< 字典序是根據字符在字母表中的順序來比較和排列字符串的&#xff08;字典序的大小就是字符串的大小&#xff09;…

電腦要使用cuda需要進行什么配置

在電腦上使用CUDA&#xff08;NVIDIA的并行計算平臺和API&#xff09;&#xff0c;需要進行以下配置和準備&#xff1a; 1. 檢查NVIDIA顯卡支持 確保你的電腦擁有支持CUDA的NVIDIA顯卡。 可以在NVIDIA官方CUDA支持顯卡列表中查看顯卡型號是否支持CUDA。 2. 安裝NVIDIA顯卡驅動…

深入解析:一個簡單的浮動布局 HTML 示例

深入解析&#xff1a;一個簡單的浮動布局 HTML 示例 示例代碼解析代碼結構分析1. HTML 結構2. CSS 樣式 核心功能解析1. 浮動布局&#xff08;Float&#xff09;2. 清除浮動&#xff08;Clear&#xff09;3. 其他樣式 效果展示代碼優化與擴展總結 在網頁設計中&#xff0c;浮動…

家居EDI:Hom Furniture EDI需求分析

HOM Furniture 是一家成立于1977年的美國家具零售商&#xff0c;總部位于明尼蘇達州。公司致力于提供高品質、時尚的家具和家居用品&#xff0c;滿足各種家庭和辦公需求。HOM Furniture 以廣泛的產品線和優質的客戶服務在市場上贏得了良好的口碑。公司經營的產品包括臥室、客廳…

【VUE案例練習】前端vue2+element-ui,后端nodo+express實現‘‘文件上傳/刪除‘‘功能

近期在做跟畢業設計相關的數據后臺管理系統&#xff0c;其中的列表項展示有圖片展示&#xff0c;添加/編輯功能有文件上傳。 “文件上傳/刪除”也是我們平時開發會遇到的一個功能&#xff0c;這里分享個人的實現過程&#xff0c;與大家交流談論~ 一、準備工作 本次案例使用的…

C++中的析構器(Destructor)(也稱為析構函數)

在C中&#xff0c;析構器&#xff08;Destructor&#xff09;也稱為析構函數&#xff0c;它是一種特殊的成員函數&#xff0c;用于在對象銷毀時進行資源清理工作。以下是關于C析構器的詳細介紹&#xff1a; 析構函數的特點 名稱與類名相同&#xff0c;但前面有一個波浪號 ~&a…

VLN視覺語言導航基礎

0 概述 視覺語言導航模型旨在構建導航決策模型 π π π&#xff0c;在 t t t時刻&#xff0c;模型能夠根據指令 W W W、歷史軌跡 τ { V 1 , V 2 , . . . , V t ? 1 } \tau\{V_1,V_2,...,V_{t-1}\} τ{V1?,V2?,...,Vt?1?}和當前觀察 V t { P t , R t , N ( V t ) } V_…

AI協助探索AI新構型的自動化創新概念

訓練AI自生成輸出模塊化代碼&#xff0c;生成元代碼級別的AI功能單元代碼&#xff0c;然后再由AI組織為另一個AI&#xff0c;實現AI開發AI的能力&#xff1b;用AI協助探索迭代新構型AI將會出現&#xff0c;并成為一種新的技術路線潮流。 有限結點&#xff0c;無限的連接形式&a…

Flux的三步煉丹爐——fluxgym(三):矩陣測試

前面兩篇文章給大家介紹了如何準備素材和怎么煉丹&#xff0c;現在我們拿到訓練完成后的多個Lora怎么才能確定哪個才是我們需要的、效果最好的呢&#xff1f;答案就是使用xyz圖表測試&#xff0c;也稱為矩陣測試&#xff0c;通過控制控制變量的方法對Lora模型批量生圖&#xff…

利用Muduo庫實現簡單且健壯的Echo服務器

一、muduo網絡庫主要提供了兩個類&#xff1a; TcpServer&#xff1a;用于編寫服務器程序 TcpClient&#xff1a;用于編寫客戶端程序 二、三個重要的鏈接庫&#xff1a; libmuduo_net、libmuduo_base、libpthread 三、muduo庫底層就是epoll線程池&#xff0c;其好處是…

文件讀寫操作

寫入文本文件 #include <iostream> #include <fstream>//ofstream類需要包含的頭文件 using namespace std;void test01() {//1、包含頭文件 fstream//2、創建流對象ofstream fout;/*3、指定打開方式&#xff1a;1.ios::out、ios::trunc 清除文件內容后打開2.ios:…

C++編程語言:抽象機制:模板(Bjarne Stroustrup)

目錄 23.1 引言和概觀(Introduction and Overview) 23.2 一個簡單的字符串模板(A Simple String Template) 23.2.1 模板的定義(Defining a Template) 23.2.2 模板實例化(Template Instantiation) 23.3 類型檢查(Type Checking) 23.3.1 類型等價(Type Equivalence) …