• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to convert all diagonals to 45 degrees?

Engaged ,
Dec 26, 2016 Dec 26, 2016

Copy link to clipboard

Copied

I'm getting in to Illustrator scripts in a big way at the moment.

Some amazing and USEFUL scripts out there by the likes of Wundes and Sato Hiroyuki!

In an ill-advised attempt to compile a single master script (to rule them all!!) I'm looking for a script that will convert all selected diagonal path segments in to either:

a) perfect 45 degree segments or

b) in to a nice faux-iso angle, such as might be good for iso vector artwork (as used in phone games, etc).

Doing this manually is not an option (too many paths).

Any leads?

Views

663

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Dec 26, 2016 Dec 26, 2016

Copy link to clipboard

Copied

Try to think like the script. If you were the script and I instructed you to "convert all selected segments into perfect 45 degree segments," what would you take that to mean?

Scripts cannot perform ambiguous instructions.

For example, consider a single closed path which was drawn with the Polygon Tool, and has 5 equal length segments (i.e., a pentagon). What would "make all segments into 45 degree segments" mean?

Rotate each segment about its center such that it is literally angled at what Illustrator's coordinate system considers 45 degrees (the angle 45 degrees counter-clockwise from horizontal)? All segments would end up at the same angle, and the result would look like a single 45 degree line.

Rotate each segment such that it makes a 45 degree angle with its adjacent segment? That leads to "but what if" questions requiring decisions which have to lead to geometrically possible answers.

Are the segments to remain connected as a single, closed path? If so, how do you reconcile that five 45 degree angles total only 225 degrees, not 360 degrees? An equilateral polygon consisting of only 45 degree angles is an octagon. How and where is the script supposed to add the three missing segments?

See what I mean? When writing a script, you have to be able to explain what you want to occur in explicit statements which covers all possible circumstances and what to do in each circumstance. That's  what is meant by "pseudo-code." Try to write out in normal language what specific steps the script should perform. Test the logic of those instructions by thinking them through in any given situation and see if you can mentally perform them without running into ambiguities or impossibilities.

JET

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 26, 2016 Dec 26, 2016

Copy link to clipboard

Copied

Thanks Jet, so you don't know of a script that already exists?

I'll consider you input seriously though while I await any other responses.

Cheers.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 26, 2016 Dec 26, 2016

Copy link to clipboard

Copied

...so you don't know of a script that already exists?

What I'm saying is, your description of what you want the script to do is too ambiguous to write a script based on that description. You also mention "iso". Assuming that is a reference to isometric drawing, I'm at a loss as to what 45 degrees has to do with that.

You need to describe the problem more fully. Post a screenshot of an example of a drawing you would run the script on and another of what you would expect as result.

JET

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 26, 2016 Dec 26, 2016

Copy link to clipboard

Copied

I don't' know, figured the questions plenty precise enough for posting

purposes- I mean the kind of people able to help will know fairly well what

I'm talking about (similar scripts exist already for similar jobs).

My jsx coding's a little rusty but I imagine the script would cycle through

the doc's object array and perform some basic trig type function to

populate a temporary array of path segments fitting pre-defined slope

criteria. It might then use that in a move point function- moving one or

both of the relevant points at either end of the segments (compensating for

orientation) to achieve the correct angle.

All of which is pretty speculative and irrelevant though as I'm not looking

to write it from scratch. If I were I'd not post it as a question.

I'll post a grab soon too though, in case that helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 31, 2016 Dec 31, 2016

Copy link to clipboard

Copied

LATEST

Just adding some clarity in case anyone's up for assisting in this thread:

True isometric artwork is based on a 30 degree angle.

The angles used in game art are not really isometric, they are rather a type of dimetric projection (26.56 degrees).

This short wikipedia article outlines this fairly concisely.

It also gives the correct camera view angles necessary to achieve both game dimetric (usually called isometric) and true isometric renders, for those interested in leveraging their software to produce perfect isometric artwork quickly.

Here's a demo image of how (any why) some diagonals are desirable and others are not:

pixel lines.jpg

As you can see, 90 degree, 45 degree and a few other angles form neat lines of pixels while the rest are an ugly mess.

In a script that might aim to auto-correct poorly drawn diagonals in Illustrator, we'd need to cycle through each pathItem and move the points according to a few, very simple, rules.

I figure that while I'm running through all the path objects and snapping corners to true rectilinear, I may as well sort out any diagonals too. Some user-defined tolerances will be necessary here.

Interestingly, for me, the built-in facilities for pixel perfect artwork in Illustrator seem to still have some quirks.

See this grab- a demo of how, even on perfect 45 degree angles (1:1 pixel slope ratio, shown upper middle) there is still a pale grey line of pixels under the slope and under the nearby horizontal...

Screen Shot 2016-12-31 at 18.30.25.png

Not good for pixel art or many screen graphic uses.

Of course it disappears if you uncheck "Anti-Alias Artwork" in Prefs, but what is the file really going to look like in use?

The context for this is the instant correction of any rectilinear artwork LiveTraced (or just hastily constructed), without the total loss of all deliberately diagonal lines.

Right. That cleared up I'm off to write a "snap to rectilinear" script as a start

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines