当前位置:网站首页>Wechat applet project example - I have a paintbrush (painting)
Wechat applet project example - I have a paintbrush (painting)
2022-06-12 02:48:00 【Long lost brother】
Wechat applet project example —— I have a paintbrush ( Drawing a picture )
List of articles
See the bottom of the text for the project code , Praise, focus and surprise
One 、 Project presentation
I have a brush is a small drawing program
Users can draw freely on the whiteboard , You can also choose a local photo , Draw on the picture
Users can freely modify the brush width 、 Color , At the same time, the painting can be saved locally


Two 、 home page
The front page consists of two pictures
It represents two functions: free drawing and photo drawing
Users click to select different functions
<!--index.wxml-->
<view class="painting" bindtap="toPainting">
<image src="../../images/paint3.png" mode="aspectFit"/>
</view>
<view class="painting2" bindtap="toPainting2">
<image src="../../images/paint2.png" mode="aspectFit"/>
</view>
/**index.wxss**/
page{
width: 100%;
height: auto;
display: flex;
flex-direction: column;
align-items: center;
}
.painting{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 100px;
width: 260rpx;
height: 260rpx;
/* background-color: red; */
}
.painting2{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 100px;
width: 260rpx;
height: 260rpx;
/* background-color: red; */
}
The effect of the home page is as follows :

3、 ... and 、 Free drawing
Users can draw on a blank page
Users can adjust the brush thickness , Brush color
You can also use an eraser to erase
Finally, you can save the drawing to the local
Here's just UI Interface code
<!--painting.wxml-->
<canvas canvas-id="myCanvas" style="height: calc(100vh - {
{canvasHeight}}px)" disable-scroll="true" bindtouchend="toucheEnd" bindtouchstart="touchStart" bindtouchmove="touchMove"/>
<view class="bottom">
<block wx:for="{
{btnInfo}}" wx:key="{
{index}}">
<view class="list-item" data-type="{
{item.type}}" style="background: {
{item.background}}" bindtap="tapBtn"></view>
</block>
</view>
<view class="choose-box" wx:if="{
{width}}">
<view class="color-box" style="background: {
{'rgb(' + r + ', ' + g + ', ' + b + ')'}}; height: {
{w}}px; border-radius: {
{w/2}}px"></view>
<slider min="1" max="50" step="1" show-value="true" value="{
{w}}" bindchange="changeWidth"/>
</view>
<view class="choose-box" wx:if="{
{color}}">
<view class="color-box" style="background: {
{'rgb(' + r + ', ' + g + ', ' + b + ')'}}; height: {
{w}}px; border-radius: {
{w/2}}px"></view>
<slider min="0" max="255" step="1" show-value="true" activeColor="red" value="{
{r}}" data-color="r" bindchange="changeColor"/>
<slider min="0" max="255" step="1" show-value="true" activeColor="green" value="{
{g}}" data-color="g" bindchange="changeColor"/>
<slider min="0" max="255" step="1" show-value="true" activeColor="blue" value="{
{b}}" data-color="b" bindchange="changeColor"/>
</view>
<view class="choose-box-flex" wx:if="{
{clear}}">
<view class="choose-item" bindtap="chooseEraser">
<view class="choose-img" style='background: url("https://s1.ax1x.com/2022/05/25/XkppBF.png") white no-repeat; background-size: 26px 26px;background-position: 2px 2px; border: {
{eraser ? "2px solid red" : "2px solid transparent"}}'></view>
<view> Eraser </view>
</view>
<view class="choose-item" bindtap="clearCanvas">
<view class="choose-img" style='background: url("https://s1.ax1x.com/2022/05/25/XkpDCn.png") white no-repeat; background-size: 26px 26px;background-position: 2px 2px;'></view>
<view> Empty </view>
</view>
</view>
/* painting.wxss */
page {
background: rgba(153, 204, 255, 0.1);
}
canvas {
width: 100vw;
}
.bottom {
width: 100vw;
height: 50px;
position: absolute;
bottom: 0;
display: flex;
justify-content: space-around;
}
.list-item {
width: 30px;
height: 30px;
margin: 10px 0;
border-radius: 50%;
}
.choose-box {
width: 100vw;
position: absolute;
bottom: 50px;
}
.color-box {
width: 50vw;
margin: 20px auto;
}
slider {
margin: 20px 30px;
}
.choose-box-flex {
display: flex;
justify-content: space-around;
width: 100vw;
position: absolute;
bottom: 50px;
font-size: 16px;
color: #666;
text-align: center;
}
.choose-img {
width: 30px;
height: 30px;
margin: 10px;
border-radius: 50%;
background: white;
}
Now I will show you my roommate !!!
( Those who like my roommate can confide in me , Send micro signal !!!)
Four 、 Photo drawing
The user can select a photo
Painting on the basis of photos
Other functions are consistent with free painting
Here's just UI Interface code
<!--painting-2.wxml-->
<canvas canvas-id="myCanvas" disable-scroll="true" bindtouchstart="touchStart"
bindtouchmove="touchMove" bindtouchend="touchEnd" wx:if="{
{hasChoosedImg}}"
style="height: {
{(canvasHeightLen == 0) ? canvasHeight : canvasHeightLen}}px; width: {
{canvasWidth}}px;"
/>
<view class="failText" wx:if="{
{!hasChoosedImg}}" click=""> No photos selected , Click to reselect </view>
<view class="bottom">
<block wx:for="{
{btnInfo}}" wx:key="{
{index}}">
<view class="list-item" data-type="{
{item.type}}" style="background: {
{item.background}}" bindtap="tapBtn"></view>
</block>
</view>
<view class="choose-box" wx:if="{
{width}}">
<view class="color-box" style="background: {
{'rgb(' + r + ', ' + g + ', ' + b + ')'}}; height: {
{w}}px; border-radius: {
{w/2}}px"></view>
<slider min="1" max="50" step="1" show-value="true" value="{
{w}}" bindchange="changeWidth"/>
</view>
<view class="choose-box" wx:if="{
{color}}">
<view class="color-box" style="background: {
{'rgb(' + r + ', ' + g + ', ' + b + ')'}}; height: {
{w}}px; border-radius: {
{w/2}}px"></view>
<slider min="0" max="255" step="1" show-value="true" activeColor="red" value="{
{r}}" data-color="r" bindchange="changeColor"/>
<slider min="0" max="255" step="1" show-value="true" activeColor="green" value="{
{g}}" data-color="g" bindchange="changeColor"/>
<slider min="0" max="255" step="1" show-value="true" activeColor="blue" value="{
{b}}" data-color="b" bindchange="changeColor"/>
</view>
/* painting-2.wxss */
page {
background: rgba(153, 204, 255, 0.1);
}
.failText {
margin-top: 100px;
text-align: center;
color: #888;
}
.bottom {
width: 100vw;
height: 50px;
position: absolute;
bottom: 0;
display: flex;
justify-content: space-around;
}
.list-item {
width: 30px;
height: 30px;
margin: 10px 0;
border-radius: 50%;
}
.choose-box {
width: 100vw;
position: absolute;
bottom: 50px;
}
.color-box {
width: 50vw;
margin: 20px auto;
}
slider {
margin: 20px 30px;
}
.choose-box-flex {
display: flex;
justify-content: space-around;
width: 100vw;
position: absolute;
bottom: 50px;
font-size: 16px;
color: #666;
text-align: center;
}
.choose-img {
width: 30px;
height: 30px;
margin: 10px;
border-radius: 50%;
background: white;
}
Next I will draw my roommate 2 Number !!
My roommate 2 No. 1 is the school grass !!!
If you like it, please send me a wechat message !

At the end of the article
That's all for the specific introduction
Small programs sometimes get stuck, but not much
Interested students can continue to study
The code is in the link below

边栏推荐
- Summary of force deduction solution 436- finding the right interval
- Interpreting Julia's 2021: step by step towards the mainstream programming language
- [digital signal processing] correlation function (finite signal | autocorrelation function of finite signal)
- Ue4\ue5 touch screen touch event: single finger and double finger
- Graduation design of fire hydrant monitoring system --- thesis (add the most comprehensive hardware circuit design - > driver design - > Alibaba cloud Internet of things construction - > Android App D
- errno: -4078, code: ‘ECONNREFUSED‘, syscall: ‘connect‘, address: ‘127.0.0.1‘, port: 3306; Postman error
- 博创智能冲刺科创板:年营收11亿 应收账款账面价值3亿
- 微信小程序项目实例——双人五子棋
- $. map(data,function(item,index){return XXX})
- Computer common sense
猜你喜欢

Layered architecture of DDD

Getting started with RPC

Maya Front Office Rendering plug - in Mel script Tool

Application of ard3m motor protector in coal industry

微信小程序项目实例——我有一支画笔(画画)

DbNull if statement - DbNull if statement

一起教育科技单季营收2.3亿:同比降51% 净亏大幅收窄

Abaqus中批量对节点施加集中力荷载

Introduction to program environment and preprocessing C language (advanced level)

Cupp dictionary generation tool (similar tools include crunch)
随机推荐
Proxy and reflection (II)
Force deduction solution summary 668- the smallest number k in the multiplication table
2022福建省安全员C证(专职安全员)考试模拟100题及答案
Transformation of geographical coordinates of wechat official account development
How to use DAO to build a knowledge database with collective wisdom and sustainable incentive mechanism
小红的删数字
maya前台渲染插件mel脚本工具
DbNull if statement - DbNull if statement
[no title] 2022 coal mine safety inspection test questions and online simulation test
[high code file format API] downing provides you with the file format API set Aspose, which can create, convert and operate more than 100 file formats in just a few lines of code
ADB command uses JKS file to sign apk
余压监控系统在高层民用建筑的应用
RPC 入门
2022 Fujian Provincial Safety Officer C certificate (full-time safety officer) examination simulation 100 questions and answers
(9) Serial port interrupt
Application of residual pressure monitoring system in high-rise civil buildings
Force deduction solution summary 497 random points in non overlapping rectangles
GeForce GTX 2050/2080/3090/A6000自动安装nvidia显卡驱动
Wave view audio information
Ue4\ue5 touch screen touch event: single finger and double finger