Android 倒车影像车道线
![先看一下效果图](https://i-blog.csdnimg.cn/blog_migrate/4cc5e608c3394482bc7047c785411afe.jpeg)
1、直接上代码
public class LaneLineView extends View {
private Paint paint;
private Camera camera;
private Matrix matrix;
private int tran = 200;
private int strokeWidth = 70;
public LaneLineView(Context context) {
super(context);
init();
}
public LaneLineView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();
}
private void init(){
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setStrokeWidth(strokeWidth);
camera = new Camera();
matrix = new Matrix();
}
}
2、然后开始画线,重写onDraw
方法
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
nt height = getHeight();
int width = getWidth();
int h_coefficient = 1000;
int w_coefficient = width / 6;
int skewing = 300;
double v = Math.sqrt(Math.pow(h_coefficient, 2) - Math.pow(skewing, 2));
double angle