使用画布绘制一个流动管道

阅读: 评论:0

使用画布绘制一个流动管道

使用画布绘制一个流动管道

使用画布绘制一个流动管道

In recent times, we have seen that the web is no longer a page in a browser full of squares. Every day there are more designs which incorporate irregular shapes.

最近,我们已经看到网络不再是充满正方形的浏览器中的页面。 每天都有越来越多的包含不规则形状的设计。

In this tutorial we want to teach you how to create and animate shapes with a jelly effect. At the end, you will be able to create the jelly shape you want, and animate it according to your needs without too much effort.

在本教程中,我们要教您如何创建具有果冻效果的形状和动画效果。 最后,您将能够创建所需的果冻形状,并根据需要对其进行动画处理,而无需付出过多的努力。

Specifically, in this first part we will see how to achieve the following result:

具体来说,在第一部分中,我们将看到如何获得以下结果:

介绍 ( Introduction )

The maths behind an effect like this can be very difficult to achieve. That's why we have tried to group the code needed to create and animate jelly shapes in a library that is easy to use for developers.

这样的效果背后的数学很难实现。 这就是为什么我们试图将创建和动画果冻形状所需的代码分组到易于开发人员使用的库中。

At the same time, we have been inspired by this pen by Thom Chiovoloni, inspired as well in the game The Floor is Jelly. And we have started specifically from this implementation of the jelly physics.

同时,我们的灵感来自Thom Chiovoloni的这支钢笔 ,也受到《地板是果冻 》游戏的启发。 而且,我们从果冻物理学的这种实现方式特别开始。

So, we've packaged this implementation into a library we've just called jelly.js, to which we've added everything we need to get jelly shapes easily. Then let's see how to use it!

因此,我们已将该实现打包到一个名为jelly.js的库中,并在其中添加了轻松获得果冻形状所需的所有内容。 然后,让我们看看如何使用它!

使用SVG路径创建形状 ( Creating the shapes with SVG paths )

We have chosen SVG paths to create the shapes, because we believe it is the easiest and most customizable way we have to do it. In this way, we can create the shapes that we want in a vector editor (like Inkscape or Illustrator), and insert them directly into our HTML document, or even import them from JavaScript.

我们选择了SVG路径来创建形状,因为我们认为这是我们最简单,最可定制的方法。 通过这种方式,我们可以在矢量编辑器(如Inkscape或Illustrator)中创建所需的形状,并将其直接插入HTML文档中,甚至从JavaScript导入它们。

For example, we can draw a simple shape like this:

例如,我们可以绘制一个简单的形状,如下所示:

Then we can include the relevant SVG code directly in the HTML:

然后,我们可以在HTML中直接包含相关的SVG代码:

<!-- SVG with a pentagon path -->
<!-- Note the `display: none` style, because we don't want to show the SVG, but just get the path from JavaScript -->
<svg xmlns="" version="1.1" width="400" height="400" style="display: none"><path id="pentagon-path" d="m200 97.218 108.07 78.524-41.28 127.04h-133.58l-41.281-127.04z

本文发布于:2024-02-27 18:05:33,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/1709110000114106.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

上一篇:果冻豆
标签:画布   管道
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23