Git Product home page Git Product logo

Comments (5)

PPDEMOone avatar PPDEMOone commented on June 9, 2024 1

There are some broken paths in the SVG that has been generated.

from maker.js.

PPDEMOone avatar PPDEMOone commented on June 9, 2024 1

Also, I call the scale method and export the svgPathData, some points are not connected

makerJs.model.zero(guitarKnife);
makerJs.model.originate(guitarKnife);
makerJs.model.scale(guitarLineTextModel, 0.3, false);
makerJs.model.addModel(guitarKnife, guitarLineTextModel, "guitarLineTextModel");
console.log(makerJs.exporter.toSVGPathData(guitarKnife));
image

The right side is normal and the left side is not connected, maybe need the 'Z' command close the path here ?

image

I read scale and distort methods in the source code.
I believe that the issue is being caused by the export rules for the SVG file format, I am currently still working on that.

from maker.js.

danmarshall avatar danmarshall commented on June 9, 2024

Hello, cool app! Something in the while loop seems to cause it to error. When I removed your code:

while (
  targetMeasureRect.width >= CARVED_MAX_WIDTH ||
  targetMeasureRect.height >= CARVED_MAX_HEIGHT ||
  !isContain(collisionRegionRect, targetMeasureRect.low, targetMeasureRect.high)
) {
  if (times) {
    scale = Number((scale - SCALE_RATIO_STEP).toFixed(2));
  }

  if (scale <= 0) {
    break;
  }

  lineTextModel = lineTextContent.models!["lineTextModel"] =
    makerJs.model.distort(lineTextModel, scale, scale);
  targetMeasureRect = makerJs.measure.modelExtents(lineTextModel);
  // console.log(targetMeasureRect);
  makerJs.model.moveRelative(lineTextModel, [
    (CARVED_MAX_WIDTH - targetMeasureRect.width) / 2,
    (CARVED_MAX_HEIGHT - targetMeasureRect.height) / 2,
  ]);

  const { low, high } = targetMeasureRect;
  const overflowBottom = makerJs.measure.isPointInsideModel(
    low,
    collisionRegionRect
  );
  const overflowTop = makerJs.measure.isPointInsideModel(
    high,
    collisionRegionRect
  );

  if (overflowBottom && overflowTop) {
    break;
  } else if (!overflowTop) {
    makerJs.model.moveRelative(lineTextModel, [0, -Math.abs(high[1])]);
  } else if (!overflowBottom) {
    makerJs.model.moveRelative(lineTextModel, [0, Math.abs(low[1])]);
  } else {
    continue;
  }
  targetMeasureRect = makerJs.measure.modelExtents(lineTextModel);
  times++;
   console.log(scale);
}

I was able to get a better export:
image

Looking at this code, I'm guessing the distort function call is where the bug might be occurring. Perhaps some unit tests on distorting a font/text might help encapsulate the condition.

from maker.js.

PPDEMOone avatar PPDEMOone commented on June 9, 2024

As in the above case, the makerjs.model.scale function happens, too πŸ€”

from maker.js.

PPDEMOone avatar PPDEMOone commented on June 9, 2024

The problem occurs in while, when I give a default distort value, itβ€˜s normally working

lineTextModel = lineTextContent.models!['lineTextModel'] = makerJs.model.distort(
      lineTextModel,
      0.9,
      0.9,
    );
    targetMeasureRect = makerJs.measure.modelExtents(lineTextModel);
    makerJs.model.moveRelative(lineTextModel, [
      (CARVED_MAX_WIDTH - targetMeasureRect.width) / 2,
      (CARVED_MAX_HEIGHT - targetMeasureRect.height) / 2,
]);
image

There's no break in this path 🧐
When I repeatedly calling the distort method, like this

lineTextModel = makerJs.model.distort(lineTextModel, 1, 1);
lineTextModel = makerJs.model.distort(lineTextModel, 0.99, 0.99);
lineTextModel = makerJs.model.distort(lineTextModel, 0.98, 0.98);
lineTextModel = makerJs.model.distort(lineTextModel, 0.97, 0.97);
lineTextModel = makerJs.model.distort(lineTextModel, 0.96, 0.96);
lineTextModel = makerJs.model.distort(lineTextModel, 0.95, 0.95);
lineTextModel = makerJs.model.distort(lineTextModel, 0.94, 0.94);
lineTextModel = makerJs.model.distort(lineTextModel, 0.93, 0.93);
targetMeasureRect = makerJs.measure.modelExtents(lineTextModel);
// console.log(targetMeasureRect);
makerJs.model.moveRelative(lineTextModel, [
  (CARVED_MAX_WIDTH - targetMeasureRect.width) / 2,
  (CARVED_MAX_HEIGHT - targetMeasureRect.height) / 2,
]);

On the last time distorted basis, the paths will be broken 🧐

image

from maker.js.

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.