How to use the paper.Path.Rectangle function in paper

To help you get started, we’ve selected a few paper examples, based on popular ways it is used in public projects.

github techninja / cncserver / src / components / core / drawing / fillers / cncserver.drawing.fillers.hatch.js View on Github external
fillUtil.connect((path, settingsOverride) => {
  settings = { ...settings, ...settingsOverride };
  fillPath = path;
  viewBounds = fillUtil.project.view.bounds;
  exportGroup = new Group();

  // Init boundpath and traversal line
  // The path drawn around the object the line traverses
  boundPath = new Path.Ellipse({
    center: path.position,
    size: [path.bounds.width * 2, path.bounds.height * 2],
  });

  // Init canvas boundary line to intersect if beyond the printable area.
  canvasBounds = new Path.Rectangle({
    from: [0, 0],
    to: [viewBounds.width, viewBounds.height],
  });

  while (dynamicLineFillNext()) {
    // console.log('*');
  }

  fillUtil.finish(exportGroup);
});
github emfmesquita / beyondhelp / src / services / PaperMapService.js View on Github external
// removes old item and creates another
    const props = PaperMapService.getAreaData(jqArea) || {};
    if (props.paperId) {
        const item = paper.project.activeLayer.children.find(child => child.id === props.paperId);
        if (item) item.remove();
    }

    let path = null;
    if (areaType === C.MapAreaCircle) { // circle
        const center = new Point(splited[0], splited[1]);
        path = new Path.Circle(center, splited[2]);
    } else if (areaType === C.MapAreaRect) { // rect
        const p1 = new Point(splited[0], splited[1]);
        const p2 = new Point(splited[2], splited[3]);
        const rect = new Rectangle(p1, p2);
        path = new Path.Rectangle(rect);
    } else { // rho or comment
        path = new Path();
        for (let i = 0; i < splited.length; i += 2) {
            path.add(new Point(splited[i], splited[i + 1]));
        }
        path.closed = true;
    }

    const defaultColor = props.color || "black";
    applyColor(path, defaultColor);
    path.strokeWidth = 2;

    PaperMapService.setAreaData(jqArea, "paperId", path.id);

    // if not always on (normal mode) only shows the area that mouse is over
    if (!paper.alwaysOn) {
github aamks / aamks / gui / interface / src / app / views / main / risk / results / results.component.ts View on Github external
public append_dd_geoms() {
    // We attach to the static geoms
    var g;

    for (var i = 0; i < this.dd_geoms['rectangles'].length; i++) {
      g = this.dd_geoms['rectangles'][i];
      this.staticGeoms.addChild(new Path.Rectangle({ point: new Point(g["xy"][0], -g["xy"][1]), size: new Size(g["width"], -g["depth"]), strokeColor: g['strokeColor'], strokeWidth: g['strokeWidth'], fillColor: g['fillColor'], opacity: g['opacity'] }));
    }

    for (var i = 0; i < this.dd_geoms['lines'].length; i++) {
      g = this.dd_geoms['lines'][i];
      this.staticGeoms.addChild(new Path.Line({ from: new Point(g["xy"][0], -g["xy"][1]), to: new Point(g["x1"], -g["y1"]), strokeColor: g['strokeColor'], strokeWidth: g['strokeWidth'], opacity: g['opacity'] }));
    }

    for (var i = 0; i < this.dd_geoms['circles'].length; i++) {
      g = this.dd_geoms['circles'][i];
      this.staticGeoms.addChild(new Path.Circle({ center: new Point(g["xy"][0], -g["xy"][1]), radius: g["radius"], fillColor: g['fillColor'], opacity: g['opacity'] }));
    }
    for (var i = 0; i < this.dd_geoms['texts'].length; i++) {
      g = this.dd_geoms['texts'][i];
      this.staticGeoms.addChild(new PointText({ point: new Point(g["xy"][0], -g["xy"][1]), content: g["content"], fontFamily: 'Play', fontSize: g["fontSize"], fillColor: g['fillColor'], opacity: g['opacity'] }));
    }
  }
github aamks / aamks / gui / interface / src / app / views / main / risk / results / results.component.ts View on Github external
public highlightGeom(key) {
    try {
      new Path.Rectangle({ point: new Point(Math.round(this.rooms[key]["x0"]), -Math.round(this.rooms[key]["y0"])), size: new Size(Math.round(this.rooms[key]["width"]), -Math.round(this.rooms[key]["depth"])), opacity: 0.4, fillColor: "#0f0" });
    } catch (e) {
      new Path.Circle({ center: new Point(Math.round(this.doors[key]["center_x"]), -Math.round(this.doors[key]["center_y"])), radius: 100, opacity: 0.4, fillColor: "#0f0" });
    }
  }
github aamks / aamks / gui / interface / src / app / views / main / risk / results / results.component.ts View on Github external
this.staticGeoms.addChild(new Path.Rectangle({ point: new Point(this.rooms[key]["x0"], -this.rooms[key]["y0"]), size: new Size(this.rooms[key]["width"], -this.rooms[key]["depth"]), strokeColor: this.colors['stroke'], strokeWidth: 0.2, fillColor: this.colors[this.rooms[key]["type_sec"]] }));
    }

    for (var i = 0; i < this.obstacles.length; i++) {
      this.staticGeoms.addChild(new Path.Rectangle({ point: new Point(this.obstacles[i]["x0"], -this.obstacles[i]["y0"]), size: new Size(this.obstacles[i]["width"], -this.obstacles[i]["depth"]), strokeColor: this.colors['obsts'], strokeWidth: this.wallsSize }));
    }

    if (this.labelsSize != 0) {
      for (var key in this.rooms) {
        this.staticGeoms.addChild(new PointText({ point: new Point(this.rooms[key]["x0"] + 10, -this.rooms[key]["y0"] - 30), fillColor: this.colors["fg"], content: this.rooms[key]["name"], fontFamily: 'Play', fontSize: this.labelsSize }));
      }
    }

    for (var key in this.doors) {
      if (this.doorsSize != 0) {
        this.staticGeoms.addChild(new Path.Rectangle({ point: new Point(this.doors[key]["x0"], -this.doors[key]["y0"]), size: new Size(this.doors[key]["width"], -this.doors[key]["depth"]), strokeColor: this.colors['door'], strokeWidth: this.doorsSize }));
      }
      if (this.labelsSize != 0) {
        this.staticGeoms.addChild(new PointText({ point: new Point(this.doors[key]["center_x"] - 10, -this.doors[key]["center_y"] + 10), fillColor: this.colors["fg"], content: this.doors[key]["name"], opacity: 0.7, fontFamily: 'Play', fontSize: this.labelsSize * 0.75 }));
      }
    }

  }
github fponticelli / tempo / paperjs / src / path.ts View on Github external
  >((_: State) => new Path.Rectangle(options.args), options)