日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android 室内定位系列:1地图构建

發布時間:2025/1/21 Android 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android 室内定位系列:1地图构建 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Path類可以預先在View上將N個點連成一條"路徑",然后調用Canvas的drawPath(path,paint)即可沿著路徑繪制圖形

Android還為路徑繪制提供了PathEffect來定義繪制效果,PathEffect包含如下子類

ComposePathEffect

CornerPathEffect

DashPathEffect

DiscretePathEffect

PathDashPathEffect

SumPathEffect

下面的示例將會逐一使用上面的繪制效果

[java]?view plaincopyprint?
  • package?WangLi.Graphics.PathTest;??
  • ??
  • import?android.app.Activity;??
  • import?android.content.Context;??
  • import?android.graphics.Canvas;??
  • import?android.graphics.Color;??
  • import?android.graphics.ComposePathEffect;??
  • import?android.graphics.CornerPathEffect;??
  • import?android.graphics.DashPathEffect;??
  • import?android.graphics.DiscretePathEffect;??
  • import?android.graphics.Paint;??
  • import?android.graphics.Path;??
  • import?android.graphics.PathDashPathEffect;??
  • import?android.graphics.PathEffect;??
  • import?android.graphics.SumPathEffect;??
  • import?android.os.Bundle;??
  • import?android.view.View;??
  • ??
  • public?class?PathTest?extends?Activity?{??
  • ????/**?Called?when?the?activity?is?first?created.?*/??
  • ????@Override??
  • ????public?void?onCreate(Bundle?savedInstanceState)?{??
  • ????????super.onCreate(savedInstanceState);??
  • ????????setContentView(new?MyView(this));??
  • ????}??
  • ????class?MyView?extends?View??
  • ????{??
  • ????????float?phase;??
  • ????????PathEffect[]?effects?=?new?PathEffect[7];??
  • ????????int[]?colors;??
  • ????????private?Paint?paint;??
  • ????????Path?path;??
  • ????????public?MyView(Context?context)?{??
  • ????????????super(context);??
  • ????????????paint?=?new?Paint();??
  • ????????????paint.setStyle(Paint.Style.STROKE);??
  • ????????????paint.setStrokeWidth(4);??
  • ????????????//創建,并初始化Path??
  • ????????????path?=?new?Path();??
  • ????????????path.moveTo(0,?0);??
  • ????????????for(int?i?=?1;?i<=?15;?i++)??
  • ????????????{??
  • ????????????????//生成15個點,隨機生成它們的坐標,并將它們連成一條Path??
  • ????????????????path.lineTo(i*20,?(float)Math.random()*60);??
  • ????????????}??
  • ????????????//初始化七個顏色??
  • ????????????colors?=?new?int[]?{??
  • ????????????????????Color.BLACK,Color.BLUE,Color.CYAN,??
  • ????????????????????Color.GREEN,Color.MAGENTA,Color.RED,Color.YELLOW??
  • ????????????};??
  • ????????}??
  • ????????protected?void?onDraw(Canvas?canvas)??
  • ????????{??
  • ????????????//將背景填充成白色??
  • ????????????canvas.drawColor(Color.WHITE);??
  • ????????????//-------下面開始初始化7中路徑的效果??
  • ????????????//使用路徑效果??
  • ????????????effects[0]?=?null;??
  • ????????????//使用CornerPathEffect路徑效果??
  • ????????????effects[1]?=?new?CornerPathEffect(10);??
  • ????????????//初始化DiscretePathEffect??
  • ????????????effects[2]?=?new?DiscretePathEffect(3.0f,5.0f);??
  • ????????????//初始化DashPathEffect??
  • ????????????effects[3]?=?new?DashPathEffect(new?float[]{20,10,5,10},phase);??
  • ????????????//初始化PathDashPathEffect??
  • ????????????Path?p?=?new?Path();??
  • ????????????p.addRect(0,?0,?8,?8,?Path.Direction.CCW);??
  • ????????????effects[4]?=?new?PathDashPathEffect(p,12,phase,PathDashPathEffect.Style.ROTATE);??
  • ????????????//初始化PathDashPathEffect??
  • ????????????effects[5]?=?new?ComposePathEffect(effects[2],effects[4]);??
  • ????????????effects[6]?=?new?SumPathEffect(effects[4],effects[3]);??
  • ????????????//將畫布移到8,8處開始繪制??
  • ????????????canvas.translate(8,?8);??
  • ????????????//依次使用7中不同路徑效果,7種不同的顏色來繪制路徑??
  • ????????????for(int?i?=?0;?i?<?effects.length;?i++)??
  • ????????????{??
  • ????????????????paint.setPathEffect(effects[i]);??
  • ????????????????paint.setColor(colors[i]);??
  • ????????????????canvas.drawPath(path,?paint);??
  • ????????????????canvas.translate(0,?60);??
  • ????????????}??
  • ????????????//改變phase值,形成動畫效果??
  • ????????????phase?+=?1;??
  • ????????????invalidate();??
  • ????????}??
  • ????}??
  • }??
  • 效果如下

    總結

    以上是生活随笔為你收集整理的Android 室内定位系列:1地图构建的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。