简体   繁体   English

我如何让一堆方块看起来像克罗地亚的边界?

[英]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.

相关问题 如何在棋盘的方格上画圆圈以使其看起来像真正的棋盘? - How do I draw circles on a checker-board's squares to make it look like a real checker-board? 如何将这个对象转换成这样? - how do I transform this object to look like this? 如何在调整大小时添加边框以使元素看起来像一棵树并保持其正确定位? - How could I add a border to make element look like a tree and keep it positioned correctly when resizing? 单击后如何使内容看起来像标签 - How do I make something look like a tab after it is clicked 如何显示用户矩形的外观? - How do I show what the user's rectangle will look like? 如何开发看起来像本机应用程序的iphone的网页? - How do I develope webpages for the iphone that look like native apps? 如何设置复选框按钮的样式使其看起来像线段 - How do I style checkbox buttons to look like line segment 如何使 ReactJS 按钮看起来像在 keyPress 上按下? - How do I make ReactJS button look like pressed on keyPress? 如何从具有相同属性的一堆元素中获得具有“ aria-hidden”真值的元素? - How do I get an element with `aria-hidden` true out of a bunch of elements that have the same attribute? 如果我的IF语句为假,如何让我的if / else语句运行一堆函数? - How do I get my if/else statement to run a bunch of functions if my IF statement is false?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM