女神节 | 程序员如何低调而又不失逼格

移动开发 作者: 2024-08-25 12:15:01
今天。。。是一个非常重要的日子 女神节。作为一名程序员,如何向心仪的人低调而又不失逼格的表达祝福,关系到我们后半生的幸福,祝福的到位,普通朋友加个字变成女朋友,女朋友变成老婆,如果已经是老婆了,那么这
Container(
  width: 400,height: 700,child: GestureDetector(
    onLongPressStart: (LongPressStartDetails details) {
      print('${details.localPosition},');
    },onLongPressMoveUpdate: (LongPressMoveUpdateDetails details) {
      print('${details.localPosition},onLongPressEnd: (LongPressEndDetails details) {
      print('${details.localPosition},child: Image.asset(
      'images/123.png',fit: BoxFit.fill,),)
  • 图片显示的大小最好和最终的画布一样大小,这样得到的坐标不需要在转换。
  • 图片的宽高比和画布的宽高比要一样。
static final List<Offset> flowerPoints = [
  Offset(182.0,136.3),Offset(182.7,135.3),Offset(183.0,Offset(183.3,...
)
@override
void paint(Canvas canvas,Size size) {
  //将花变为红色
    if (flowerPaths.length >= RoseData.flowerPoints.length) {
      var path = Path();
      for (int i = 0; i < flowerPaths.length; i++) {
        if (i == 0) {
          path.moveTo(flowerPaths[i].dx,flowerPaths[i].dy);
        } else {
          path.lineTo(flowerPaths[i].dx,flowerPaths[i].dy);
        }
      }
      _paint.style = PaintingStyle.fill;
      _paint.color = _flowerColor;
      canvas.drawPath(path,_paint);
    }
    //绘制线
    _paint.style = PaintingStyle.stroke;
    _paint.color = _strokeColor;
	 canvas.drawPoints(PointMode.polygon,flowerPaths,_paint);
}
AnimationController _controller;
Animation<num> _animation;

@override
void initState() {
  _controller = AnimationController(
      duration: Duration(seconds: 10),vsync: this)
    ..addListener(() {
      setState(() {
        _flowerPaths = RoseData.flowerPoints.sublist(0,_animation.value.floor());
      });
      });

    _animation = Tween(
            begin: 0.0,end: RoseData.flowerPoints.length)
        .animate(_controller);
}
@override
  Widget build(BuildContext context) {
		Container(
          width: 400,child: CustomPaint(
            painter: RosePaint(_flowerPaths),)
  }
static final List<Offset> flowerPoints = [
    Offset(182.0,...
	Offset(179.3,301.7),Offset(237.7,144.7),];
if (flowerPaths.length >= RoseData.flowerPoints.length) {
  var path = Path();
  for (int i = 0; i < flowerPaths.length; i++) {
    if (i == 0) {
      path.moveTo(flowerPaths[i].dx,flowerPaths[i].dy);
    } else {
      path.lineTo(flowerPaths[i].dx,flowerPaths[i].dy);
    }
  }
  _paint.style = PaintingStyle.fill;
  _paint.color = _flowerColor;
  canvas.drawPath(path,_paint);
}
//绘制线
_paint.style = PaintingStyle.stroke;
_paint.color = _strokeColor;
//去掉最后2个点,最后2个点为了绘制红色
var points = flowerPaths.sublist(0,max(0,flowerPaths.length - 2));
canvas.drawPoints(PointMode.polygon,points,_paint);
原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_68388.html