第四章作业

这篇文章详细描述了如何在微信小程序中利用canvas组件创建并绘制五个不同颜色的圆形。代码展示了如何设置路径、样式和调用draw方法来实现实例效果。
摘要由CSDN通过智能技术生成

使用canvas组件实现五个圈的绘制

<canvas canvas-id="myCanvas" style="height: 300px;"></canvas>

Page({
  onReady:function (e){
const ctx = wx.createCanvasContext('myCanvas')
ctx.beginPath()
ctx.arc(100, 100, 50, 0, 2 * Math.PI)
ctx.setStrokeStyle('#0000FF')
ctx.stroke()

ctx.beginPath()
ctx.arc(160, 100, 50, 0, 2 * Math.PI)
ctx.setStrokeStyle('#FFFF00')
ctx.stroke()

ctx.beginPath()
ctx.arc(220, 100, 50, 0, 2 * Math.PI)
ctx.setStrokeStyle('#000000')
ctx.stroke()


ctx.beginPath()
ctx.arc(130, 150, 50, 0, 2 * Math.PI)
ctx.setStrokeStyle('#00FF00')
ctx.stroke()

ctx.beginPath()
ctx.arc(190, 150, 50, 0, 2 * Math.PI)
ctx.setStrokeStyle('#FF0000')
ctx.stroke()

ctx.draw()
  }
})

运行效果

使用相对应组件 完成书单

 
 .tou{
  float: left;
  margin-top: 8px;
  width: 450px; 
  height: 220px;
}
.tu1{
  margin: 0 auto;
  float: left;
  display: block;
  width: 180px; 
  height: 160px;
}
.yi{
  margin-top: 10px;
}
.ig1{
  margin-top: 5px;
}
.ig2 {
  position: absolute; 
 
}
.ig2 image{
  position: relative;
  top: 303px;
  left: 2px;
}
 
.ig3{
  margin-top: 30px;
  position: absolute;
}
.ig3 image{
  position: relative;
  top: 400px;
}
.yi{
  margin-top: 5px;
  float: right;
}
.er{
  margin-top: 5px;
  float: right;
}
.tu2{
  margin: 0 auto;
  float: left;
  display: block;
  width: 180px; 
  height: 160px;
  margin-top: 60px;
}
.zi1{
  margin: 0 auto;
  display: block;
  font-size: 30px;
  float: none;
  display: block;
  margin-left: 80px;
  margin-top: 310px; 
}
.ww{
  position: absolute;
  left: 195px;
  top: 500px;
  font-size: 30px;
}
.m{
  color: black;
  position: absolute;
  left: 200px;
  top:540px;
  font-size: 15px;
 
}
.j{
  position: absolute;
  left: 200px;
  top:570px;
  font-size: 12px;
color: gray;
}
.zi2{
  display: block;
  font-size: 15px;
 float: none;
  display: block;
  margin-left: 80px;
  margin-top: 10px;
}
.zi3{
  display: block;
  font-size: 10px;
  float: right;
  display: block;
  margin-left: 180px;
  margin-top: 10px;
  color: grey;
}

 

 
<view style="font-size: 30px;position: absolute;top: 100px;top: 25px;"> ⬅书单</view>
 
 <view>
 <view class="ig1">
 <image src="../images/02.jpg" mode="tu1" class="tou"style="position:absolute;top:60px"/>
 </view></view>
 <view>
   <view style="position: absolute;top:90px;color: grey;left: 40px;font-size: 33px;">培养商业意识,走出生活,职场和事业的困境。</view>
   <view style="position: absolute;top: 85px;color: grey;left: 15px;top: 170px;font-size: 18px;">创新者是如何思考问题的?本书单包括了互联网,思维方式,商业,文案,市场,营销等方方面面,是在思维方式上的创新,略去传统商学院的教条</view>
 </view>
 <view class="yi">
 <view class="zi1">小程序</view>
 <view class="zi2">XXXX</view>
 <view class="zi3">微信小程序</view>
 </view>
 <view class="ig2">
 <view class="ig2"><image src="../images/02.jpg" mode=""class="tu1"/></view></view>
 <view class="fo" style="border-bottom: 1px solid darkgrey;padding: 10px;"></view>
 <view class="ig3">
 <view><image src="../images/02.jpg" mode=""class="tu2"/></view></view>
 <view class="er">
 <view class="ww">Java</view>
 <view class="m">XXX</view>
 <view class="j">Java应用程序开发</view>
 </view>

运行效果图

使用相应组件 完成西安拼车

<!--index.wxml-->
<view style="background-color: black;height: 60px;"><view style="color: white;padding-top: 20px;">×西安找拼车</view>
</view>
<view style="color:grey;padding-top: 10px;background-color: darkgray;height: 35px;">
联系方式(手机号和微信至少填一项)</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 0px;"></view>
<view>
  <view style="font-size: 20px;position: absolute;top: 115px;">称呼*</view>
  <view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:115px">请输入称呼</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 20px;"></view>
<view>
  <view style="font-size: 20px;position: absolute;top:150px">手机号</view>
  <view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:150px">请输入手机号</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 20px;"></view>
<view>
  <view style="font-size: 20px;position: absolute;top: 195px;">微信号</view>
  <view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:195px">请输入微信号</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 23px;"></view>
<view style="color:grey;padding-top: 10px;background-color: darkgray;height: 35px;">
拼车信息</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 0px;">
</view>
<view>
  <view style="font-size: 20px;position: absolute;top: 290px;">出发地点*</view>
  <view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:290px">限7个字</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 25px;"></view>
<view>
  <view style="font-size: 20px;position: absolute;top: 340px;">目的地*</view>
  <view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:340px">限7个字</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 25px;"></view>
<view>
  <view style="font-size: 20px;position: absolute;top: 390px;">空座位*</view>
  <view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:390px">请输入空座位</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 25px;"></view>

运行效果图

 

人生进程

{
  "pages": [
    "pages/index/index",
    "pages/ee/ee",
    "pages/qq/qq",
    "pages/ww/ww",
    "pages/logs/logs"
  ],
  "window": {
    "backgroundColor": "#F6F6F6",
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#F6F6F6",
    "navigationBarTitleText": "云开发 QuickStart",
    "navigationBarTextStyle": "black"
  },
  "tabBar": {
    "color": "#666666",
    "selectedColor": "#ff0000",
    "borderStyle":"black",
    "backgroundColor": "#ffffff",
    "list": [{
      "pagePath": "pages/index/index",
      "iconPath": "./pages/images/pic03.png",
      "selectedIconPath": "./pages/images/pic03.png",
      "text": "首页"
    },
    {
      "pagePath": "pages/ee/ee",
      "iconPath": "./pages/images/pic03.png",
      "selectedIconPath": "./pages/images/pic03.png",
      "text": "年月日"
    },
    {
      "pagePath": "pages/ww/ww",
      "iconPath": "./pages/images/pic03.png",
      "selectedIconPath": "./pages/images/pic03.png",
      "text": "静思"
    },
    {
      "pagePath": "pages/qq/qq",
      "iconPath": "./pages/images/pic03.png",
      "selectedIconPath": "./pages/images/pic03.png",
      "text": "关于"
    }]
  },
  "style": "v2",
  "componentFramework": "glass-easel",
  "lazyCodeLoading": "requiredComponents"
}
.mm{
  width: 110px;
  padding-top: 18px;
  padding-left: 30px;
}
.bt{
  padding-right: 20px;
  width: 175px;
  font-size: 13px;
  font-weight: bold;
}
.r{
  width: 190px;
  height: 350px;
  margin-left: 80px;
 
}
<view style="text-align: center;">中国现阶段人均寿命900个月</view>
<form bindsubmit="bind" style="line-height: 60px;">
<view style="display: flex; font-size: 20px;">
<input type="text" name="time" placeholder="请输入时间" class="mm"/>至今:{{people}}个月</view>
<view style="display: flex;">
<button formType="submit" class="bt">请输入后再点击此按钮</button>
<button formType="reset" style="width: 150px;font-size: 13px;">清除记录</button>
</view>
</form>
<view style="margin-top:50px;">
<image src="../images/pic03.png" class="r" style="width: 250px;" />
</view>
<view style="width: 350px;">
  <text bindtap="changeText1">{{ text1 }}</text>
</view>
 
 .tou{
  float: left;
  margin-top: 8px;
  width: 450px; 
  height: 220px;
}
.tu1{
  margin: 0 auto;
  float: left;
  display: block;
  width: 180px; 
  height: 160px;
}
.yi{
  margin-top: 10px;
}
.ig1{
  margin-top: 5px;
}
.ig2 {
  position: absolute; 
 
}
.ig2 image{
  position: relative;
  top: 274px;
  left: 2px;
}
 
.ig3{
  margin-top: 5px;
  position: absolute;
}
.ig3 image{
  position: relative;
  top: 390px;
}
.yi{
  margin-top: 5px;
  float: right;
}
.er{
  margin-top: 5px;
  float: right;
}
.tu2{
  margin: 0 auto;
  float: left;
  display: block;
  width: 180px; 
  height: 160px;
  margin-top: 60px;
}
.zi1{
  margin: 0 auto;
  display: block;
  font-size: 30px;
  float: none;
  display: block;
  margin-left: 200px;
  margin-top: 10px; 
}
.zi2{
  display: block;
  font-size: 15px;
 float: none;
  display: block;
  margin-left: 200px;
  margin-top: 10px;
}
.zi3{
  display: block;
  font-size: 10px;
  float: right;
  display: block;
  margin-left: 200px;
  margin-top: 10px;
}

运行效果图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值