[英]how do i get a bunch of squares to look like the border of Croatia?
I decided to use SVGs to generate squares and images I need.我决定使用 SVG 来生成我需要的方块和图像。 SVGs are flexible and that should work with me.
SVG 很灵活,应该对我有用。
I can't figure out how can I generate squares to fit inside the border of Croatia.我不知道如何生成适合克罗地亚边界的正方形。 End result I'd like to have can be seen in (see image below).
我想要的最终结果可以在(见下图)中看到。
IMAGE :图片 :
It's pretty easy to generate squares in some rectangular shape.在某些矩形中生成正方形非常容易。 Since border of Croatia is not rectangular the only thing I have in mind is to do it manually, but this is not flexible.
由于克罗地亚的边界不是矩形,我唯一想到的是手动进行,但这并不灵活。 What if I want to create bigger or smaller squares just to test it out and fit them within borders.
如果我想创建更大或更小的正方形只是为了测试它并将它们放入边界内怎么办。
It's usually a mistake to hand-implement low-level graphics primitives like this.像这样手动实现低级图形基元通常是错误的。 Dealing with wavy or nested borders and edge conditions is bug-attracting code.
处理波浪形或嵌套边界和边缘条件是吸引错误的代码。
I'd suggest creating a small HTML canvas
, drawing Croatia on it with path
primitives and fill
, then reading back its content with getImageData
.我建议创建一个小的 HTML
canvas
,用path
基元和fill
在其上绘制克罗地亚,然后用getImageData
读回其内容。 Each fully black pixel corresponds to a square you want to draw.每个全黑像素对应于您要绘制的正方形。 (Size the canvas to ensure this.)
(调整画布大小以确保这一点。)
(Or, if you just want the aesthetic, use an SVG pattern fill. That'd be less work.) (或者,如果您只是想要美感,请使用 SVG 图案填充。这样工作量会减少。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.