Further simplify boole kit code

This commit is contained in:
be5invis 2020-12-08 20:21:39 -08:00
parent 30b6469f8f
commit 4db665ce07
2 changed files with 6 additions and 12 deletions

View file

@ -7,10 +7,6 @@ export : define [SetupBuilders args] : begin
define [BooleImplFn] : begin
define k : {}.slice.call arguments 0
return : lambda [dontinc] : begin
local g : new Glyph
set g.gizmo : this.gizmo || GlobalTransform
if (k.length == 0) : return g
local contourArcs : getArcsFromProc this k.0
if (k.length === 1) : set contourArcs : TypoGeom.Boolean.removeOverlap
begin contourArcs
@ -27,9 +23,7 @@ export : define [SetupBuilders args] : begin
local ctx : new CurveUtil.BezToContoursSink
TypoGeom.ShapeConv.transferBezArcShape contourArcs ctx
set g.contours ctx.contours
this.includeGlyph g
return g
this.includeContours ctx.contours 0 0
define [getArcsFromProc g p] : begin
local g1 : new Glyph

View file

@ -116,7 +116,7 @@ module.exports = class Glyph {
includeGeometry(geom, shiftX, shiftY) {
if (!geom || !geom.contours || !geom.contours.length) return null;
if (this.includeGeometryAsTransparentReferences(geom, shiftX, shiftY)) return null;
return this.includeGeometryImpl(geom, shiftX, shiftY);
return this.includeContours(geom.contours, shiftX, shiftY);
}
isPureComposite() {
@ -138,7 +138,7 @@ module.exports = class Glyph {
if (!geom.isPureComposite()) return false;
for (const sr of geom.semanticInclusions) {
const cs = this.includeGeometryImpl(sr.glyph, sr.x + shiftX, sr.y + shiftY);
const cs = this.includeContours(sr.glyph.contours, sr.x + shiftX, sr.y + shiftY);
if (cs) {
this.semanticInclusions.push({
glyph: sr.glyph,
@ -150,11 +150,11 @@ module.exports = class Glyph {
}
return true;
}
includeGeometryImpl(geom, shiftX, shiftY) {
includeContours(contours, shiftX, shiftY) {
let newContours = [];
for (const contour of geom.contours) {
for (const contour of contours) {
let c = [];
c.tag = contour.tag || geom.tag || this.defaultTag;
c.tag = contour.tag || contours.tag || this.defaultTag;
for (const z of contour) c.push(Point.translated(z, shiftX, shiftY));
this.contours.push(c);
newContours.push(c);