https://p5js.org/reference/#/p5.Font/textToPoints
此函数跟踪文本的边界并为我提供该边界中的点数组。
我们在 Processing 或 Java API 中有类似的东西吗?
最佳答案
它可以在 Processing 中以每个字符为基础完成。
获取给定字符的边顶点
ArrayList<PVector> edgeVertices = new ArrayList<>();
PFont font = createFont("Arial", 96, true);
PShape shape = font.getShape(char c);
for (int i = 0; i < shape.getVertexCount(); i++) {
edgeVertices.add(shape.getVertex(i));
}
从边缘顶点绘制轮廓
strokeWeight(2);
beginShape();
for (PVector v : edgeVertices) {
vertex(v.x + 55, v.y + 125);
}
endShape(CLOSE);
结果(字符 = 'H',字体 = Comfortaa)
关于java - 什么是 p5.js textToPoints() 字体函数的等效处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52691716/