Glyph code cleanup
This commit is contained in:
parent
730472f419
commit
924616430e
3 changed files with 3 additions and 18 deletions
|
@ -106,7 +106,7 @@ function extPrior(a, b) {
|
|||
function canonicalStart(_points) {
|
||||
const points = _points.reverse();
|
||||
let jm = 0;
|
||||
for (var j = 0; j < points.length * 2; j++) {
|
||||
for (let j = 0; j < points.length * 2; j++) {
|
||||
if (extPrior(points[j % points.length], points[jm])) {
|
||||
jm = j % points.length;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ extern isFinite
|
|||
import './point' as Point
|
||||
import './transform' as : Transform && [object [transformPoint tp] [untransform utp] inverse]
|
||||
import './anchor' as Anchor
|
||||
import "./utils" as [object fallback mix ratio]
|
||||
|
||||
define-macro xytransform : syntax-rules
|
||||
`[xytransform @tfm @x @y] : begin
|
||||
|
@ -13,23 +14,6 @@ define-macro xytransform : syntax-rules
|
|||
set @y : @t * @tfm.xy + @y * @tfm.yy + @tfm.y
|
||||
]
|
||||
|
||||
define [mix a b p] : a + (b - a) * p
|
||||
define [ratio l r m] : if [l === r] 0 ((m - l) / (r - l))
|
||||
define [byx a b] : a - b
|
||||
define [fallback] : for [local j 0] (j < arguments.length) [inc j] : if (arguments.(j) !== nothing) : return arguments.(j)
|
||||
|
||||
define [closepoint p q t] : begin
|
||||
return : [Math.abs (p.x - q.x)] <= t && [Math.abs (p.y - q.y)] <= t
|
||||
define [oncurveRemovable a b c t] : begin
|
||||
local xm : (a.x + c.x) / 2
|
||||
local ym : (a.y + c.y) / 2
|
||||
return : [not a.on] && b.on && [not c.on] && [not a.cubic] && [not c.cubic] && (a.x <= b.x && b.x <= c.x || a.x >= b.x && b.x >= c.x) && (a.y <= b.y && b.y <= c.y || a.y >= b.y && b.y >= c.y) && [Math.abs (b.x - xm)] <= (t / 2) && [Math.abs (b.y - ym)] <= (t / 2)
|
||||
|
||||
define PRECISION 1000
|
||||
define [cov x] : piecewise
|
||||
[isFinite x] : return : [Math.round : x * PRECISION] / PRECISION
|
||||
true : return 0
|
||||
|
||||
export all : class Glyph
|
||||
public [new name] : begin
|
||||
set this.name name
|
||||
|
|
|
@ -2,6 +2,7 @@ import './anchor' as Anchor
|
|||
import './transform' as : Transform && [object [transformPoint tp] [unTransform utp] inverse]
|
||||
|
||||
export : define [mix a b p] : a + (b - a) * p
|
||||
export : define [ratio l r m] : if [l === r] 0 ((m - l) / (r - l))
|
||||
export : define [barmixL l r b p] : if (l > r) [barmixL r l b p] (l + b + p * (r - l - b * 3))
|
||||
export : define [barmixM l r b p] : [barmixL l r b p] + b / 2
|
||||
export : define [barmixR l r b p] : [barmixR l r b p] + b
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue