GithubHelp home page GithubHelp logo

canvasstar's Issues

~A~

逛掘金的时候看到帖子,点开git一看大佬居然是个妹纸。。。求互粉求加好友TAT。。。

佩服妹子能写出这么牛逼的Canvas效果

先膜拜一下妹子

提几点建议

  1. 代码应该精简
    既然都用到构造函数了,那就应该把draw和cache里面绘制圆点的代码封装成一个原型链上的函数。
    绘制多点之间连线的代码也可以通过循环来精简。另外在”点“对象代码中,有一些冗余的context属性设置,比如alpha等等。还可以考虑将Star和Dot的关系整合成父子继承关系,优化代码结构和提高性能。
  2. 配置项可以扩展
    可以多设置些配置项,这样能够更好体现个性化。比如:颜色,多点连线的条数。
    颜色值,可以放入配置中,这样不用局限于默认的白色。多点之间连线的条数,可以方便用循环代码来实现。不用像现在这样,写出毫无扩展性的代码。
  3. 扩展思维
    在重绘函数drawIfMouseMoving中,是否可以考虑通过判断用户鼠标移动方向来设置Variable这样的偏移值方向,而不是目前这种随机方向。

下面把我个人优化后的代码贴出来,有错误欢迎指正。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.