Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AN IDEA! #1

Open
quitequinn opened this issue Jul 4, 2016 · 12 comments
Open

AN IDEA! #1

quitequinn opened this issue Jul 4, 2016 · 12 comments

Comments

@quitequinn
Copy link

quitequinn commented Jul 4, 2016

Instead of having a fixed oval as the form to determine stroke width why not calculate the shortest straight line between any two points of your paths and the cursor. That way it could live calculate the CURRENT stroke width and you could use the tool to determine transitions of any stroke width? (not just monolinear ones)

UPDATE
not monolinear per say.. more like taking tool rotation into consideration. After playing with it more I realize my goal and this extensions goal isn't quite the same so perhaps this isn't a great use of an "issue". ANYWAYS, smart extension.

@quitequinn
Copy link
Author

For example:
screen shot 2016-07-04 at 3 43 52 pm

@weiweihuanghuang
Copy link
Owner

Great Idea! I actually originally wanted to make the ball sticky and stick to a certain side to achieve a more accurate reading, but that was alas beyond my current abilities... This is even harder I believe, especially to find where the line should be drawn. I suggested to @simoncozens if his Calipers tool could work around an entire /o and I think it was a similar issue https://twitter.com/w__h_/status/710460919151763456

@quitequinn
Copy link
Author

quitequinn commented Jul 8, 2016

RIGHT THE OPPOSING SIDE.. and the opposite path too.

Lets explore that for a second. Lets do it for an O(two paths) and an S(one path).
As long as the goal is to find a strait line I don't think this is a problem. Even if we compare EVERY path... as long as it only shows the closest path we should be set. Here is a possible solution (please forgive my made up functions, pythony foreach and javascript.. I don't think as fluidly in python):

var smallestDistance;
var lines = [];

var glyph = { 
   name: "S",
   paths: [ ],
};
foreach path, pathIndex in glyphFromRobofont {
   glyph.paths.push({
      index: pathIndex,
      name: path.name,
      instances: []
   });
   foreach instance, instanceIndex in path.instances {
      glyph.paths[pathIndex].push({
         index: instanceIndex,
         name: instance.name,
         distanceFromCursor: distance(instance.location, cursor.location)
   }
   foreach instance, instanceIndex in glyph.paths.instances {
      foreach instance2, instanceIndex2 in glyph.paths.instances {
         if (line(instance, cursor.location, instance2)){
            line.push({
               instance1: instance,
               cusor: cursor,
               instance2: instance2,
               distance: distance(instance.location, cursor.location, instance2.location)
            });
         }
      }
   }
}


smallestDistance = smallestInList(lines, distance);

// This is the line that is the shortest length that intersects any two points on all paths and your cursor
style(smallestDistance);

Before I wrote that solution I considered an alternative... I don't think this conversation is helpfull in the case of a strait line but maybe it is useful for Gauge tool.

How do we find the opposite path: This will only happen with two or more paths so we don't need to explore S. Why not just calculate distances for all paths? BUT then there is the possibility of having overlapped measurements.. but that probably wouldn't be the end of the world.

How do we find the opposing side: Well you could calculate all instance of a path. You could then display those instances in a list with the instance id and distances from that instances' location and the cursor. Once you have that all you need to do is divide that list in half and you should have a range that doesn't include the other side of a glyph.

@simoncozens
Copy link

Unfortunately, just finding the closest segment doesn't work. The closest segment from the marked point of this bold /n is not the other side of the stem, but the other side of the aperture:

screen shot 2016-07-08 at 13 01 29

@quitequinn
Copy link
Author

quitequinn commented Jul 8, 2016

Right! but if you put the cursor within the body of the "n" it would draw a line to the other side of the stem. If your cursor was within the aperture of the "n" wouldn't you expect it to draw the line within that aperture?

@quitequinn
Copy link
Author

if you wanted to get super specific you could add an if that doesn't draw any line if the cursor is actually on a path.

@quitequinn
Copy link
Author

ALTHOUGH you could have situations like so... but no tool is perfect.

screen shot 2016-07-07 at 8 10 35 pm

@quitequinn
Copy link
Author

Some more examples..
screen shot 2016-07-07 at 8 12 49 pm
screen shot 2016-07-07 at 8 12 14 pm
screen shot 2016-07-07 at 8 11 43 pm

@simoncozens
Copy link

Incidentally, Fontlab VI does this, and it's really funky:
flvi-stem

@quitequinn
Copy link
Author

Right! That's the same idea but using the heart line instead of the cursor.

@weiweihuanghuang
Copy link
Owner

weiweihuanghuang commented Jul 8, 2016

Do you know what though, this would be a GREAT tool for easily measuring the width of diagonal stems, I don't know the right equations to find the two closest point between two segments.

@simoncozens
Copy link

Glyphs has Objective C functions you can use to do this. I don't know if they're exposed to Python. Look in GSGeometrieHelper.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants