antvis / coord Goto Github PK
View Code? Open in Web Editor NEWToolkit for apply point transformations for vector.
Home Page: https://observablehq.com/@antv/wow-antv-coord
License: MIT License
Toolkit for apply point transformations for vector.
Home Page: https://observablehq.com/@antv/wow-antv-coord
License: MIT License
The type of return value of coordinate.getCenter()
should be [number, number]
, not number[]
.
现在将连续的矩阵运算的逆运算合并成一个函数存在问题,导致在有连续的仿射变换的时候不能 invert 到原始值。
因为 polar.rho 和 polar.theta 存在一些问题,同时他们的效果可以由 polar 所代替,所以把这部分删除。
Currently fisheye accepts visual focus point, which means it must be specified after cartesian coordinate.
const coord = new Coordinate({
width: 300,
height: 150,
});
coord.transform('cartesian');
coord.transform('fisheye', 150, 75, 2, 2);
coord.map([0.4, 0.2]); // [85.71428571428571, 13.63636363636364]
This is inconsistent with other coordinate transformations, such as polar.
const coord = new Coordinate();
coord.transform('polar', -Math.PI / 2, (Math.PI * 3) / 2, 0, 1);
coord.transform('cartesian');
A better implementation is enabling fisheye to accept abstract focus point(normalized point).
const coord = new Coordinate({
width: 300,
height: 150,
});
// The first way to declare.
coord.transform('fisheye', 0.5, 0.5, 2, 2); // Abstract value by default.
coord.transform('cartesian');
// The second way to declare.
coord.transform('fisheye', 300, 150, 2, 2, true); // Flag to treat it as visual value.
coord.transform('cartesian');
// Result the same.
coord.map([0.4, 0.2]); // [85.71428571428571, 13.63636363636364]
The key to achieving this goal is to pass [0, 1] for the range of fisheyeTransform, and normalize focusX before point transformations. - source
// Before
const fx = fisheyeTransform(vx, focusX, distortionX, x, x + width); // focusX is visual value.
// After
const normalizedFocusX = normlize(focusX, isVisual);
const fx = fisheyeTransform(vx, normalizedFocusX, distortionX, 0, 1);
Todo List
在 map 的时候 r = a + b * theta
中 b 的计算存在问题,同时在 invert 的时候不能计算出准确的 theta,到处并不能 invert 回去。
return [(x + width ) / 2, (y + height) / 2] // error
return [(x * 2 + width ) / 2, (y * 2 + height) / 2] // correct
@hustcc 使用方式如下:
案例1
const coord = new Coordinate();
coord.$unshift('scale');
和下面一样
const coord = new Coordinate();
const { transformations } = coord.getOptions();
transformations.unshift('scale');
coord.update({
transformations
})
案例2
const len = new Coordinate().$length;
和下面一样
const len = new Coordinate().getOptions().transformations.length;
现在 Coordinate 设置默认 options 的方式是 constructor 里面赋值,更简洁的做法是在前面声明。
class A {
a = 1;
constructor() {
console.log('a');
}
}
@hustcc 上面的 ts 代码编译成 js 如下:
"use strict";
class A {
constructor() {
this.a = 1;
console.log('a');
}
}
请给这个 repo 一个稍微详细一点的 Description。
稍微细化一下 README,说一下这个 repo 是干什么的、大概被哪里依赖。
(如果是已经废弃的项目需要清理)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.