mysticsymbolic / mysticsymbolic.github.io

Fun with procedurally generated visionary art!
https://mysticsymbolic.art/
Other
52 stars 11 forks source link

attachment orientation #184

Closed ninapaley closed 3 years ago

ninapaley commented 3 years ago

I notice that symbols, when attached to other symbols, may have varying orientations. I have experimented with the orientation of the attachment point arrows, but things like this still happen: Screen Shot 2021-06-23 at 2 22 47 PM Is there a way to establish consistency, so that I can control whether a symbol will attach "up" or "down" to an attachment point? For example, I'd like to be able to control - via the existing orientation arrows alone - how the wings in the symbol above orient, so I could get this if I wanted: wing_orientation I believe the orientation arrows have an order of points, so if they are flipped that information can be used, even though they remain visually symmetric.

toolness commented 3 years ago

Ah! I think this is because of the following code, which was added early into the existence of the creature creator to ensure that e.g. left arms would be horizontally mirroring right arms:

https://github.com/mysticsymbolic/mysticsymbolic.github.io/blob/bdc96e8c5a185fe2374714cf84f16f6c42f6117a/lib/creature-symbol.tsx#L130-L138

At least I think that's what's making things look the way they do in your first screenshot. Is there a way for me to reproduce it, or was that basically created by clicking "randomize" a bunch?

One funky thing is that the horizontal flipping isn't actually about rotating the image, it's about scaling it by -1 around the x axis (which causes the flip).

One "quick fix" might be to add a never_flip_attachments flag to the symbol metadata... but that wouldn't allow you to define things on a per-attachment-point basis. Another option, if I understand your suggestion correctly, is to detect what order the points in the spec arrows are defined in and use that to figure out whether to flip the symbols or not. I think I can do that but one concern I have is that it won't be immediately apparent to the human eye whether a spec arrow is defining its points in clockwise or counter-clockwise order, so it might be particularly hard to debug...

I wonder if another option is to somehow make the arrow slightly asymmetrical? For instance, if the arrow is a bit "lop-sided", it might be easier to tell visually whether it has been flipped around the x-axis:

image

Sort of like a Star Trek logo I guess.

Anyways, those are just some ideas, let me know what you think!

ninapaley commented 3 years ago

never_flip_attachments is a great idea! Certainly the easiest for now.

But I still want to control the orientation of wings and hands and arms, so I should adjust the attachment arrows as you suggest. If I do so, will I have to go in and re-do every single arrow on every single existing symbol? And would they all have to be adjusted exactly the same way, or could I just go in there and manually shift the innermost points to more or less resemble a star trek arrow, and have that be sufficient?

toolness commented 3 years ago

Oh good question. Hmm so one thing we can do is try to detect whether an attachment point looks like a star trek arrow or a symmetric arrow... if it looks like a symmetric arrow, we treat it the way we've always treated arrows, and apply the horizontal flipping logic like we've been doing, while also paying attention to never_flip_attachments, but if it looks like a star trek arrow, then we use the orientation of the star trek arrow and ignore the auto-flipping logic and whatever never_flip_attachments says (if it's even present). That way all the existing symbols could behave like they currently do, but you get the fine-grained control over attachment points if you really want it on a per-attachment-point basis... does that make sense?

ninapaley commented 3 years ago

Yes that makes sense.

Here is the same test file I left in #187 . It has both star trek arrows AND black arrows. skeleton_test.svg.zip

toolness commented 3 years ago

Er, so one thing I'm realizing is kind of weird is that even though the star trek symbol is asymmetrical, it's still a bit ambiguous what the actual orientation of an attached symbol should be, given the orientation of the star trek symbol. For instance, should we assume that the "natural" orientation is the Star Trek symbol, i.e. with the "skinny" side of the arrow on the right? If so then a star trek symbol that looks like a regular star trek symbol should mean "don't flip the attached symbol horizontally" while one that looks horizontally mirrored (i.e. with the skinny side on the left) should mean "flip the attached symbol horizontally".

It makes me wonder if there's an alternative that's easier to remember. What if instead of having four points, the arrow actually had five:

image

If we think of the fifth point, which would appear on either side of the arrow, as being a thing that "points" in the direction of the flip, with pointing to the right meaning "the normal orientation of the symbol", then a symbol like the one above would mean that the attached symbol shouldn't be horizontally-flipped, while an arrow with the fifth point pointing to the left would mean the attached symbol should be horizontally-flipped. Does that make any sense? If it's just as confusing as the star trek symbol, or if you've already been making lots of symbols using the star trek symbol, don't worry about it--I can just implement the star trek symbol...

ninapaley commented 3 years ago

I can certainly add a point to the arrows. My questions are:

  1. will I need to do this to ALL the arrows on all the symbols?
  2. do the arrows have to be exactly the same shape, or can I just make them more-or-less look like this?

If they don't have to be exactly the same shape, but more-or-less the same shape, I can go into Moho and use the add-a-point tool and manually make all the arrows look more-or-less like this. That would be easier than copy-pasting a new, precise arrow shape, because I'd have to manually position and angle each of those all over again.

toolness commented 3 years ago

Oh good questions!

  1. Nope, you won't need to do them to all arrows, only the ones on which you want to override our default behavior explained above.
  2. I think you can make them just more-or-less look like the shape I drew. I will just add logic basically asking "is the extra point to the left or right of the main direction the arrow is pointing?" which wouldn't require every arrow to look exactly the same. Can you make an example SVG like you did above so I can try out my strategy and see if it works?
ninapaley commented 3 years ago

OK! Here are two test svg files with some modified points. The anchor points are as yet unmodified. I can modify those too if needed. Archive.zip

toolness commented 3 years ago

Urf, so I made a failed experiment in #202. Hmm.

@ninapaley how about this: what if you actually put each arrow into its own layer under the specs layer, and in that layer added another GRAY arrow (e.g. #aaaaaa) on top of (or underneath, it doesn't matter) pointing in the direction you wanted the symbol to face? Or is that too much of a hassle?

If it is, maybe I should just implement never_flip_attachments for now until we figure out a better convention...

ninapaley commented 3 years ago

@toolness Instead of doing that, I can roll up my sleeves and copy-paste a single arrow shape, instead of modifying existing arrow shapes. For that I can design the ideal perfect asymmetrical arrow and use it over and over. Yes it will be a pain to re-do all the specs layers, but then it will be done.

ninapaley commented 3 years ago

@toolness What if I added a little line coming out of the center of an arrow? Would that have to be absolutely precise, or could there be wiggle room on that? Like, whichever side of the arrow the line crosses (regardless of how far the line extends, or whether it starts at the absolute center, and regardless of exact angle) that is its "dominant" side? A line would only cross one edge or the other, not both. It would be pretty easy for me to add these lines where needed. arrow_line

toolness commented 3 years ago

Hmm so the one thing I'm actually a bit worried about right now is that Moho itself might be varying the order in which it writes out the order of points in those arrows, depending on how you're rotating them... Blargh.

Hmm, it's possible the line-out-of-the-center-of-the-arrow thing could work. Could you try making a version of face_nest using that technique?

In the meantime, I've added never_flip_attachments support in #203, so hopefully that is good enough for the immediate future.

ninapaley commented 3 years ago

@toolness Try this: face_nest_arrowlines.svg.zip

toolness commented 3 years ago

Er, so the one thing I'm worried about with the line-out-of-the-center-of-the-arrow thing is that, unless the arrow and line are grouped together on a separate Moho layer, my code will have to figure out which lines correspond to which arrows. They could conceivably do that by just finding the pairs that are closest together, but that could become error prone for attachment points that are spaced very close together... oy oy oy.

toolness commented 3 years ago

Hmm, what if never_flip_attachments were actually a list of attachment point types, rather than a single boolean? e.g.:

never_flip_attachments = ["arm", "leg"]

would essentially mean "don't flip anything attached to arm or leg points, but use the default flipping behavior for all other points."

ninapaley commented 3 years ago

Hmm, what if never_flip_attachments were actually a list of attachment point types, rather than a single boolean? e.g.:

That would work. What I wonder about though, is how to control the orientation of, say, wings, or bed.svg, which show up "upside down" as often as they do right-side up. Like how can I make the bed right-side up all or most of the time?

ninapaley commented 3 years ago

See the dang bed keeps being upside-down: Screen Shot 2021-07-05 at 6 53 41 PM

But it should still be flipped horizontally, as it is now. It's just the whole thing should be flipped vertically too. But not always; sometimes its vertical orientation is correct, as below: Screen Shot 2021-07-05 at 6 55 48 PM

There's just no way for me to control the vertical orientation of these symbols right now.

toolness commented 3 years ago

Oh interesting! Ok lemme noodle on this a bit and get back to you.

toolness commented 3 years ago

Er... is it theoretically possible that we might have to specify something about the symbols being attached, and not just the attachment points on the root symbol?

For instance, one thing I fear is that fixing the orientation of the bed on your first image above might then cause, say, legs attached to those same points appear to be either upside-down or horizontally mirrored the wrong way...

Anyways I will noodle on this more and get back to you.

ninapaley commented 3 years ago

I figured once we had a system for determining orientation - should I say secondary orientation? the main orientation is working fine - then I would go back into all the symbols and flip them vertically as needed. I already did that with the wings; they were appearing upside-down more often than rightside-up, so I flipped some of them vertically. (They're inconsistent so they still attach upside-down on some symbols.) If we get a system that has the legs rightside-up, but the wings upside-down, I will go in and flip the wings back.

BUT if there's a way to control this via the attached symbol, rather that the root symbol's attachment points, I'm all for it! Like something on the wings that says, "please orient me rightside-up as much as you can, unless I'm angled more than 150° downward" or something.

ninapaley commented 3 years ago

I tried testing never_flip_attachments in face_nest.toml. First I just included the line never_flip_attachments, while face_nest.svg had black arrows. That failed, so I changed the toml line to say never_flip_attachments = ["arm", "leg"] . That failed, so I changed the arrows in face_nest.svg to green ("arm"), and that failed. Good thing I have my own branch to fail instead of messing up main!

ninapaley commented 3 years ago

Haha I'm an idiot I forgot = true . Thanks for making the program work even when my brain doesn't!