展示HN:使用基本形状重建任何图像,通过WASM在浏览器中运行
Show HN: Reconstruct any image using primitive shapes, runs in-browser via WASM

原始链接: https://github.com/taiseiue/primitive-playground

## 原始游乐场:图像形状重建 原始游乐场是一个网页应用程序,可以将任何图像转换为完全由基本几何形状组成的艺术品。它使用 WebAssembly 构建,所有处理都在您的浏览器中直接进行——无需将数据发送到服务器。 受 fogleman 最初的“primitive”Go 工具启发,这个基于浏览器的版本使这项技术更易于访问和使用。该应用程序通过迭代添加形状(三角形、矩形、圆形等)来重建输入图像,从而最大限度地减少视觉误差。 用户可以自定义形状数量、形状*模式*、透明度和图像大小来控制生成过程,通常需要几秒钟到几分钟。您可以在 primitive-playground.taiseiue.jp 试用它。该项目是开源的,采用 MIT 许可证发布。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN:使用基本形状重建任何图像,通过 WASM 在浏览器中运行 (github.com/taiseiue) 6 分,taiseiue 发表于 1 小时前 | 隐藏 | 过去 | 收藏 | 讨论 我构建了一个基于浏览器的 fogleman/primitive 的移植版本——一个 Go 命令行工具,它使用基本形状(三角形、椭圆、贝塞尔曲线等)通过爬山算法来逼近图像。 原始工具需要从源代码构建并在终端中运行,这并不是很容易访问。我将核心逻辑编译为 WebAssembly,因此任何人都可以拖放图像并观看它逐个形状地重建,完全在客户端进行,无需服务器参与。 演示:https://primitive-playground.taiseiue.jp/ 源代码:https://github.com/taiseiue/primitive-playground 想知道大家是否有值得添加的形状或功能方面的想法。 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

A web app that reconstructs any image using primitive shapes; port of fogleman/primitive

English | Japanese

This is a web application that converts any image into one expressed solely through geometric shapes. It runs on WebAssembly, with all processing performed entirely on the device.

The algorithm attempts to reproduce the input image using only predefined shapes, minimizing the error between the input image and the image being drawn. This process is iterative, adding one shape at a time. The progress of shapes being added can be observed.

This is a WASM port and Web UI for the idea by fogleman: fogleman/primitive. The original primitive is a Go-based CLI tool and not easy to use, so I made it available from a browser. Please consider starring fogleman/primitive.

You can use it by accessing primitive-playground.taiseiue.jp. Generation usually takes tens of seconds to several minutes.

The configurable values are as follows:

Shapes The number of shapes to be generated. The default value is 100.

Mode The shape of the figures to be generated. You can choose from Combo, Triangle, Rectangle, Ellipse, Circle, Rotated Rectangle, Beziers, Rotated Ellipse, and Polygon. The default value is Triangle.

Alpha The transparency of each shape, only when Combo is used in Mode. The default value is 128.

Input size The image will be scaled down to this size for processing. This can speed up the processing. The default value is 256px.

Output size The size of the output image. The default value is 1024px.

Preview interval How many shapes to update the preview after. Setting a larger value can speed up processing, but it may appear to be frozen. The default value is 10 shapes.

This software is released under the The MIT License.

Copyright (c) 2025 Taisei Uemura
Released under the MIT license

联系我们 contact @ memedata.com