Compare commits

..

2 Commits

4 changed files with 278 additions and 35 deletions
+1 -1
View File
@@ -212,7 +212,7 @@ aisummary:
# 内容清洗设置 # 内容清洗设置
ignoreRules: # 可选:自定义内容清洗的正则规则 ignoreRules: # 可选:自定义内容清洗的正则规则
max_token: 5000 # 输入内容最大 token 长度(非输出限制) max_input_token: 5000 # 输入内容最大 token 长度(非输出限制)
concurrency: 2 # 并发处理数,建议不高于 5hexo s concurrency: 2 # 并发处理数,建议不高于 5hexo s
+49 -34
View File
@@ -8,11 +8,11 @@
"name": "hexo-site", "name": "hexo-site",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"axios": "^1.14.0", "axios": "^1.15.0",
"cheerio": "^1.2.0", "cheerio": "^1.2.0",
"hexo": "^8.1.1", "hexo": "^8.1.1",
"hexo-abbrlink": "^2.2.1", "hexo-abbrlink": "^2.2.1",
"hexo-ai-summary-liushen": "^1.4.0", "hexo-ai-summary-liushen": "^2.0.0",
"hexo-butterfly-swiper-lyx": "^1.0.2", "hexo-butterfly-swiper-lyx": "^1.0.2",
"hexo-deployer-git": "^4.0.0", "hexo-deployer-git": "^4.0.0",
"hexo-douban": "^2.3.6", "hexo-douban": "^2.3.6",
@@ -355,6 +355,18 @@
"@jridgewell/sourcemap-codec": "^1.4.14" "@jridgewell/sourcemap-codec": "^1.4.14"
} }
}, },
"node_modules/@nodable/entities": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-2.1.0.tgz",
"integrity": "sha512-nyT7T3nbMyBI/lvr6L5TyWbFJAI9FTgVRakNoBqCD+PmID8DzFrrNdLLtHMwMszOtqZa8PAOV24ZqDnQrhQINA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/nodable"
}
],
"license": "MIT"
},
"node_modules/@types/trusted-types": { "node_modules/@types/trusted-types": {
"version": "2.0.7", "version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
@@ -366,6 +378,7 @@
"version": "0.9.9", "version": "0.9.9",
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.9.tgz", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.9.tgz",
"integrity": "sha512-qycIHAucxy/LXAYIjmLmtQ8q9GPnMbnjG1KXhWm9o5sCr6pOYDATkMPiTNa6/v8eELyqOQ2FsEqeoFYmgv/gJg==", "integrity": "sha512-qycIHAucxy/LXAYIjmLmtQ8q9GPnMbnjG1KXhWm9o5sCr6pOYDATkMPiTNa6/v8eELyqOQ2FsEqeoFYmgv/gJg==",
"deprecated": "this version has critical issues, please update to the latest version",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=14.6" "node": ">=14.6"
@@ -534,9 +547,9 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "2.0.3", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz",
"integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==", "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"balanced-match": "^1.0.0" "balanced-match": "^1.0.0"
@@ -948,9 +961,9 @@
} }
}, },
"node_modules/dompurify": { "node_modules/dompurify": {
"version": "3.3.3", "version": "3.4.0",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.3.tgz", "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.0.tgz",
"integrity": "sha512-Oj6pzI2+RqBfFG+qOaOLbFXLQ90ARpcGG6UePL82bJLtdsa6CYJD7nmiU8MW9nQNOtCHV3lZ/Bzq1X0QYbBZCA==", "integrity": "sha512-nolgK9JcaUXMSmW+j1yaSvaEaoXYHwWyGJlkoCTghc97KgGDDSnpoU/PlEnw63Ah+TGKFOyY+X5LnxaWbCSfXg==",
"license": "(MPL-2.0 OR Apache-2.0)", "license": "(MPL-2.0 OR Apache-2.0)",
"optionalDependencies": { "optionalDependencies": {
"@types/trusted-types": "^2.0.7" "@types/trusted-types": "^2.0.7"
@@ -1149,9 +1162,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/fast-xml-builder": { "node_modules/fast-xml-builder": {
"version": "1.1.4", "version": "1.1.5",
"resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.4.tgz", "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.5.tgz",
"integrity": "sha512-f2jhpN4Eccy0/Uz9csxh3Nu6q4ErKxf0XIsasomfOihuSUa3/xw6w8dnOtCDgEItQFJG8KyXPzQXzcODDrrbOg==", "integrity": "sha512-4TJn/8FKLeslLAH3dnohXqE3QSoxkhvaMzepOIZytwJXZO69Bfz0HBdDHzOTOon6G59Zrk6VQ2bEiv1t61rfkA==",
"funding": [ "funding": [
{ {
"type": "github", "type": "github",
@@ -1164,9 +1177,9 @@
} }
}, },
"node_modules/fast-xml-parser": { "node_modules/fast-xml-parser": {
"version": "5.5.11", "version": "5.7.1",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.11.tgz", "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.7.1.tgz",
"integrity": "sha512-QL0eb0YbSTVWF6tTf1+LEMSgtCEjBYPpnAjoLC8SscESlAjXEIRJ7cHtLG0pLeDFaZLa4VKZLArtA/60ZS7vyA==", "integrity": "sha512-8Cc3f8GUGUULg34pBch/KGyPLglS+OFs05deyOlY7fL2MTagYPKrVQNmR1fLF/yJ9PH5ZSTd3YDF6pnmeZU+zA==",
"funding": [ "funding": [
{ {
"type": "github", "type": "github",
@@ -1175,8 +1188,9 @@
], ],
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"fast-xml-builder": "^1.1.4", "@nodable/entities": "^2.1.0",
"path-expression-matcher": "^1.4.0", "fast-xml-builder": "^1.1.5",
"path-expression-matcher": "^1.5.0",
"strnum": "^2.2.3" "strnum": "^2.2.3"
}, },
"bin": { "bin": {
@@ -1268,9 +1282,9 @@
} }
}, },
"node_modules/follow-redirects": { "node_modules/follow-redirects": {
"version": "1.15.11", "version": "1.16.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==",
"funding": [ "funding": [
{ {
"type": "individual", "type": "individual",
@@ -1424,9 +1438,9 @@
} }
}, },
"node_modules/glob/node_modules/brace-expansion": { "node_modules/glob/node_modules/brace-expansion": {
"version": "1.1.13", "version": "1.1.14",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz",
"integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==", "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
@@ -1491,9 +1505,9 @@
} }
}, },
"node_modules/hasown": { "node_modules/hasown": {
"version": "2.0.2", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"function-bind": "^1.1.2" "function-bind": "^1.1.2"
@@ -1747,9 +1761,9 @@
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/hexo-ai-summary-liushen": { "node_modules/hexo-ai-summary-liushen": {
"version": "1.4.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/hexo-ai-summary-liushen/-/hexo-ai-summary-liushen-1.4.0.tgz", "resolved": "https://registry.npmjs.org/hexo-ai-summary-liushen/-/hexo-ai-summary-liushen-2.0.0.tgz",
"integrity": "sha512-pLABdfoiql99KgtYibnqMppdEM48+RjclmawQ6D3dP9q5we61DtPvc/qnLf6l7rAbnbKkgpJ2TmVtNBTFnv9uw==", "integrity": "sha512-ukd6QHwBO9uGX5tiQ63Nn1pjqSmxfNNzmk4qbfpVXS2mGjiaKCIUmtEK5oG/3TxIAnF3g5BzPYuBIo3yU7cPJg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.19.2",
@@ -4154,11 +4168,12 @@
} }
}, },
"node_modules/resolve": { "node_modules/resolve": {
"version": "1.22.11", "version": "1.22.12",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz",
"integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", "integrity": "sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"es-errors": "^1.3.0",
"is-core-module": "^2.16.1", "is-core-module": "^2.16.1",
"path-parse": "^1.0.7", "path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0" "supports-preserve-symlinks-flag": "^1.0.0"
@@ -4656,9 +4671,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/undici": { "node_modules/undici": {
"version": "7.24.7", "version": "7.25.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.24.7.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-7.25.0.tgz",
"integrity": "sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==", "integrity": "sha512-xXnp4kTyor2Zq+J1FfPI6Eq3ew5h6Vl0F/8d9XU5zZQf1tX9s2Su1/3PiMmUANFULpmksxkClamIZcaUqryHsQ==",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=20.18.1" "node": ">=20.18.1"
+23
View File
@@ -0,0 +1,23 @@
---
title: 电子价签玩法
categories: 技术
abbrlink: 8712baaa
summary: >-
这篇文章介绍了作者在逛咸鱼时发现并购买了两个改造二手电子价签的过程,这些电子价签由tsl0922开发的开源固件提供支持,具备日历、传图、文字功能,并且可以在网页端进行便捷的配置。尽管开源版固件功能有限,作者选择自行编写所需功能,目前已经实现了待办事项和倒计时功能,并能生成图片后上传至网络。
date: 2026-04-19 13:46:25
series:
tags:
---
最近在逛咸鱼时发现了改造二手电子价签,实现了一点有意思的功能,于是买了两个玩玩。
他们用的是tsl0922开发的开源固件,具有日历、传图、文字功能,在网页端可以很方便地配置。
{% link 上位机,tsl0922,https://tsl0922.github.io/EPD-nRF5/ %}
![6f03fcce-1dc8-471c-add7-2620a1cd88c3](https://pic.biss.click/image/6f03fcce-1dc8-471c-add7-2620a1cd88c3.webp)
![日历](https://pic.biss.click/image/124f7862-e8dc-45e8-b9fa-73de58381234.jpg)
当然开源版固件功能有点少,又不想买烧录器自己折腾,所以把自己想要的功能写成网页:
目前写了待办事项和倒计时,生成图片后上传
{% link 生成图,tu,https://letters.biss.click/gen/ %}
![待办事项](https://pic.biss.click/image/1b1c3f2c-fe42-4844-b681-f4b463900c1a.jpg)
![倒计时](https://pic.biss.click/image/66ea88ef-15c0-40bd-9f2d-6973266e3a01.webp)
+205
View File
@@ -0,0 +1,205 @@
---
title: OpenGL- Cohen-Sutherland 编码裁剪算法
cover: https://pic.biss.click/image/d1705811-324e-4378-a512-74d4baa651b7.png
categories:
- 技术
- 学习
series: OpenGL
tags: OpenGL
abbrlink: 9b2ef00a
summary: >-
这篇文章介绍了Cohen-Sutherland编码裁剪算法,这是一种在计算机图形学中常用的图像裁剪方法。裁剪的目的是从一个大场景中提取所需信息,例如在浏览地图时放大显示特定区域。Cohen-Sutherland算法通过空间划分和编码方案来判断线段与矩形窗口的位置关系,从而决定线段的哪部分在窗口内、哪部分在窗口外。算法的核心在于计算线段端点的区域编码,并根据编码值来确定线段的裁剪结果。文章还提供了具体的代码实现,包括初始化设置、窗口大小调整和主函数等,展示了如何在实际应用中使用该算法进行图像裁剪。
date: 2026-04-15 19:34:23
---
裁剪是从数据集合提取信息的过程,它是计算机图形学许多重要问题的基础。裁剪典型的用途就是从一个大的场景中提取所需的信息,以显示某一局部场景或视图。比如浏览地图时,对感兴趣的区域放大显示,此时窗口内显示的内容会相应减少。确定图形的哪些部分在窗口内,哪些部分在窗口外(不可见区域),只显示窗口内的那部分图形,这个选择处理过程就是裁剪。
Cohen-Sutherland编码裁剪算法
算法思想
1)若线段完全在窗口之内则显示该线段称为“取”,
2)若线段明显在窗口之外则丢弃该线段称为“弃”
3)若线段既不满足“取”的条件也不满足“弃”的条件则把线段分割为两段,对于完全在窗口之外的部分可弃之。
具体实现
为快速判断一条直线段与矩形窗口的位置关系采用如图所示的空间划分和编码方案(四位二进制编码上下右左)
![示意图](https://pic.biss.click/image/e789d12a-762e-48e5-9afd-a8dd0f54a536.png)
接下来是具体代码
```cpp
#include <GL/glut.h>
#include <iostream>
// --- 定义区域编码 ---
#define INSIDE 0 // 0000
#define LEFT 1 // 0001
#define RIGHT 2 // 0010
#define BOTTOM 4 // 0100
#define TOP 8 // 1000
// --- 定义裁剪窗口结构 ---
struct ClipWindow {
float xmin, xmax, ymin, ymax;
};
// --- 全局变量设置 ---
ClipWindow rect;
int x_0, y_0, x_1, y_1; // 线段端点
/**
* 计算点 (x, y) 的区域编码
*/
int computeCode(float x, float y, ClipWindow rect) {
int code = INSIDE;
if (x < rect.xmin) code |= LEFT;
else if (x > rect.xmax) code |= RIGHT;
if (y < rect.ymin) code |= BOTTOM;
else if (y > rect.ymax) code |= TOP;
return code;
}
/**
* Cohen-Sutherland 算法核心
* 注意:这里传入坐标的引用,直接修改坐标值以得到裁剪后的结果
*/
void cohenSutherlandClip(float& x_0, float& y_0, float& x_1, float& y_1, ClipWindow rect) {
int code1 = computeCode(x_0, y_0, rect);
int code2 = computeCode(x_1, y_1, rect);
bool accept = false;
while (true) {
// 如果两端点都在窗口内 (0000 | 0000 == 0)
if (!(code1 | code2)) {
accept = true;
break;
}
// 如果两端点都在窗口的同一侧外部 (例如都在左边:0001 & 0001 != 0) 按位与运算
else if (code1 & code2) {
break; // 直接舍弃
}
// 3. 线段部分在窗口内,需要求交点
else {
int code_out;
float x, y;
// 选择窗口外的一个端点
if (code1 != 0)
code_out = code1;
else
code_out = code2;
// 计算交点
if (code_out & TOP) {
x = x_0 + (x_1 - x_0) * (rect.ymax - y_0) / (y_1 - y_0);
y = rect.ymax;
}
else if (code_out & BOTTOM) {
x = x_0 + (x_1 - x_0) * (rect.ymin - y_0) / (y_1 - y_0);
y = rect.ymin;
}
else if (code_out & RIGHT) {
y = y_0 + (y_1 - y_0) * (rect.xmax - x_0) / (x_1 - x_0);
x = rect.xmax;
}
else if (code_out & LEFT) {
y = y_0 + (y_1 - y_0) * (rect.xmin - x_0) / (x_1 - x_0);
x = rect.xmin;
}
// 用交点替换原来的外部端点
if (code_out == code1) {
x_0 = x; y_0 = y;
code1 = computeCode(x_0, y_0, rect);
}
else {
x_1 = x; y_1 = y;
code2 = computeCode(x_1, y_1, rect);
}
}
}
// 如果接受,则绘制裁剪后的线段(蓝色)
if (accept) {
glBegin(GL_LINES);
glColor3f(0.0f, 0.0f, 1.0f); // 蓝色
glVertex2f(x_0, y_0);
glVertex2f(x_1, y_1);
glEnd();
}
}
// --- 显示回调函数 ---
void myDisplay() {
glClear(GL_COLOR_BUFFER_BIT);
// 1. 绘制裁剪窗口 (红色线框)
glColor3f(1.0f, 0.0f, 0.0f); // 红色
glBegin(GL_LINE_LOOP);
glVertex2f(rect.xmin, rect.ymin);
glVertex2f(rect.xmax, rect.ymin);
glVertex2f(rect.xmax, rect.ymax);
glVertex2f(rect.xmin, rect.ymax);
glEnd();
// 2. 绘制原始线段 (绿色)
// 注意:为了演示效果,我们在调用裁剪函数前,先保存原始坐标,
// 或者在这里直接用初始值绘制。这里我们使用初始值绘制。
int orig_x_0 = 50, orig_y_0 = 350;
int orig_x_1 = 550, orig_y_1 = 50;
glBegin(GL_LINES);
glColor3f(0.0f, 1.0f, 0.0f); // 绿色
glVertex2f(orig_x_0, orig_y_0);
glVertex2f(orig_x_1, orig_y_1);
glEnd();
// 3. 执行裁剪并绘制结果 (蓝色)
// 使用 float 变量传入,因为算法内部会修改它们
float cx_0 = orig_x_0, cy_0 = orig_y_0;
float cx_1 = orig_x_1, cy_1 = orig_y_1;
// 加粗蓝色线条以便区分
glLineWidth(3.0);
cohenSutherlandClip(cx_0, cy_0, cx_1, cy_1, rect);
glLineWidth(1.0); // 恢复线宽
glFlush();
}
// --- 初始化设置 ---
void Init() {
glShadeModel(GL_FLAT);
rect.xmin = 100;
rect.xmax = 400;
rect.ymin = 100;
rect.ymax = 300;
}
// --- 窗口大小调整 ---
void myReshape(int w, int h) {
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// 设置二维投影范围,与坐标数值对应
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
glMatrixMode(GL_MODELVIEW);
}
// --- 主函数 ---
int main(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(600, 400);
glutCreateWindow("实验2_03毕爽爽 Cohen-Sutherland 算法");
Init();
glutDisplayFunc(myDisplay);
glutReshapeFunc(myReshape);
glutMainLoop();
return 0;
}
```