机械制图国家标准的绘图模板_如何使用p5js构建绘图应用

本文介绍了如何利用p5js库创建一个绘图应用程序,详细阐述了从HTML布局、CSS样式到JS代码实现的过程。通过设置事件监听,实现在画布上绘制形状,同时探讨了如何避免错误连接导致的问题,鼓励读者尝试扩展功能,如保存为图像或适配移动设备。
摘要由CSDN通过智能技术生成

机械制图国家标准的绘图模板

The theme for week #5 of the Weekly Coding Challenge is:

每周编码挑战第5周的主题是:

创建绘图应用程序 (Creating a Drawing Application)

This is the first application that we are building in the #weeklyCodingChallenge program. So far we have built smaller projects, so this is pretty exciting if you ask me! ?

这是我们在#weeklyCodingChallenge程序中构建的第一个应用程序。 到目前为止,我们已经建立了较小的项目,因此如果您问我,这将非常令人兴奋! ?

In this article we’ll use p5js, a drawing library, to build a Drawing Application:

在本文中,我们将使用绘图库p5js来构建绘图应用程序

Check out the CodePen here:

在此处查看CodePen:

If you want to learn more about p5js and what it does, you can visit their official website. Basically, I am using it because it works very well on top of the browser’s canvas element by providing a clear API.

如果您想了解更多有关p5js及其功能的信息,可以访问其官方网站 。 基本上,我使用它是因为它通过提供一个清晰的API在浏览器的canvas元素上很好地工作。

HTML (The HTML)

As you can notice in the example above, on the left side of the screen we have a .sidebar. We'll put inside it our 'tools' - a color picker, a weight selector and the clear button (trashcan icon):

您可以在上面的示例中注意到,在屏幕的左侧,我们有一个.sidebar 。 我们将在其中放入“工具”-一个color选择器,一个weight选择器和一个clear按钮(垃圾桶图标):

<div class="sidebar">
    <ul>
        <li>
            <label for="color">Color:</label>
            <input type="color" id="color" />
        </li>
        <li>
            <label for="weight">Stroke:</label>
            <input type="number" id="weight" min="2" max="200" value="3" />
        </li>
        <li>
            <button id="clear"><i class="fa fa-trash"></i></button>
        </li>
    </ul>
</div>

CSS (The CSS)

Using CSS we’ll move the .sidebar and everything

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值