Giter Site home page Giter Site logo

Comments (4)

kener avatar kener commented on May 21, 2024

ellipseo?

from zrender.

First-blood avatar First-blood commented on May 21, 2024

就是我自己写的那个 画椭圆的方法。
/代码在这里***********/
// JavaScript Document
define(
function(require) {
function EllipseO() {
this.type = 'ellipseo';
}

    EllipseO.prototype =  {
        /**
         * 创建圆形路径
         * @param {Context2D} ctx Canvas 2D上下文
         * @param {Object} style 样式
         */
        buildPath : function(ctx, style) {

            ctx.font = '14px sans-serif'; 

            //BezierEllipse2(ctx, 33,21,30,18);
            BezierEllipse2(ctx, style.x, style.y, style.a, style.b);
            function BezierEllipse2(ctx, x, y, a, b)
            {
               var k = .5522848,
               ox = a * k, // 水平控制点偏移量
               oy = b * k; // 垂直控制点偏移量
               ctx.lineWidth = 3;
               //从椭圆的左端点开始顺时针绘制四条三次贝塞尔曲线
               ctx.moveTo(x - a, y);
               ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b);
               ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y);
               ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b);
               ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y);
            }
            return;
        },
        drift : function(e, dx, dy) {
            e.style.x += dx;
            e.style.y += dy;
        },
        isCover : function(e, x, y) {
            if (x >= (e.style.x - e.style.a / 2 - 10)&& x <= (e.style.x + e.style.a / 2 + 10)&& (y >= e.style.y - e.style.b / 2 - 10)&& (y <= (e.style.y + e.style.b / 2 + 10))) {
                return true;
            }
            return false;
        }
    };

    var base = require('./base');
    base.derive(EllipseO);

    var shape = require('../shape');
    shape.define('ellipseo', new EllipseO());
    return EllipseO;
}

);

from zrender.

kener avatar kener commented on May 21, 2024

要把getRect方法实现,否则文字不知道定位在什么地方

from zrender.

First-blood avatar First-blood commented on May 21, 2024

噢 3Q.....

from zrender.

Related Issues (20)

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.