Jump to content
GreenGirl

Edit 'W' for all curves without having to select individually or group and skew the transform?

Recommended Posts

Finally... all 5 rules complete... first circular slide rule complete. Swift program taking inputs spits out the SVG that I can import back into Designer and colour / texture as I need. 

Thanks to everyone over two threads who helped with this; special shout outs to @John Rostron and @v_kyr

Very disappointing that Designer couldn't have working SVG support and some of the buttons / functions in Designer don't work as advertised... but it's done. 1 down, 4 more to go!

outerTicks.jpg.144d19d3c5cf668815027749e2babee9.jpg

 

 

Share this post


Link to post
Share on other sites

Well done GreenGirl aka "Tenacious G", and amazing support from @John Rostron and @v_kyr


iMac 27" Late 2015 Fully Loaded, iMac 27" Mid 2011 both running High Sierra 10.13.6 - Affinity Designer/Photo & Publisher - Illustrator CC, Inkscape, Blender, Sketchup, Pepakura Designer, MTC, Pixelmator & Pixelmator Pro + more... XP-Pen Artist-22E, - iPad Pro 12.9 B|  

Affinity Help - Affinity Desktop Tutorials - Feedback - FAQ - most asked questions

Share this post


Link to post
Share on other sites

@GreenGirl Although you have solved your problem, I thought I would give you my final solution using a Spreadsheet..

I generated a label "tick1", "tick2" or "tick3" based on the decimals in the angle. The angle is in column C, the decimal portion in column D and the tick label in column D. I get column D using the formula: =C7-FLOOR(C7,1). From this I get the tick label using the formula: =IF(D7=0,"tick1",IF(D7=0.5,"tick2","tick3")). 

I then generate the use directive by concatenating the various fragments using the formula: =J$3&E7&J$4&G7&J$5.

The three common components are in J3, J4 and J5. This image shows them being calculated:

SVGcalc.png.402a37d55e6b8bc1b7953b0c54cef313.png

For inserting two elements, I found that concatenation was more convenient than using the SUBSTITUTE function.

I copied the use directives from the spreadsheet into an svg file containing three lines as follows:

    <g id="tick1" >
    <line x1="1024" y1="1800" x2="1024" y2="2000" style="stroke: black; stroke-width: 3pt" />
    </g>
    <g id="tick2" >
        <line x1="1024" y1="1800" x2="1024" y2="1950" style="stroke: black; stroke-width: 2.5pt" />
    </g>
    <g id="tick3" >
        <line x1="1024" y1="1800" x2="1024" y2="1900" style="stroke: black; stroke-width: 2pt" />
    </g>
 

Here is the final result.

1583854498_ThreeLines.thumb.png.b73d5512bc072082ff6cb407d745836f.png

John

 

 


Windows 10, Affinity Photo 1.8,3 Designer 1.8.3 and Publisher 1.8.3 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

Share this post


Link to post
Share on other sites
9 minutes ago, John Rostron said:

Here is the final result.

The whole drawing needs a 180° clock- or anticlock rotation.


☛ Affinity Designer 1.8.3 ◆ Affinity Photo 1.8.3 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites
Just now, v_kyr said:

The whole drawing needs a 180° clock- or anticlock rotation.

Yes, I know, but since this was just a proof of concept rather than a definitive solution, I did not bother to correct it. In a circular slide rule, does it matter? My earlier svg files, using path directives (generated by Designer) were the right way up. In writing the line directives, I was assuming that the origin was at the bottom left when I should have assumed it was top left .

John


Windows 10, Affinity Photo 1.8,3 Designer 1.8.3 and Publisher 1.8.3 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

Share this post


Link to post
Share on other sites

I think it's no problem. - Such SVG drawings can be generated in a couple of ways, even with an interactive calculator like Gnu bc here ...

/* Calculate some circle slide rule tick marks via Gnu BC, 
   can be run as "bc -l draw_tick_marks.bc > output.svg" */

/* Define pi as 4*atan(1) */
pi = 4*a(1)

/* Define sine of x */
define sin(x)
{
  return (s(x))
}

/* Define logarithm (base 10) of x */
define log(x) {
  return (l(x)/l(10));
}

/* Convert degrees to radiants */
define deg2rad(x) {
  return (x * pi/180);
}

/* Calculates the rotation angle theta */
define calc_angle(radius, number) {
  return ((radius/2) * (2 + log(s(deg2rad(number)))))
}

/* Draw a tick mark via a SVG rotate transformation */
define draw_tick(angle) {
  value = calc_angle(360,angle);
  print "<use xlink:href=\q#Outer\q transform=\qrotate(",value,", ",1024.0,", ",1024.0,")\q />"	
}

define draw_slide_scale() {
  print "<?xml version=\q1.0\q encoding=\qUTF-8\q standalone=\qno\q?>\n";
  print "<!DOCTYPE svg PUBLIC \q-//W3C//DTD SVG 1.1//EN\q \qhttp://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\q>\n"
  print "<svg viewBox=\q0 0 2048 2048\q version=\q1.1\q xmlns=\qhttp://www.w3.org/2000/svg\q xmlns:xlink=\qhttp://www.w3.org/1999/xlink\q>\n"
  
  print "<g id=\qOuter\q>\n"
  print "  <path d=\qM1024,218L1024,99\q style=\qfill:none;stroke:rgb(255,0,245);stroke-width:6.67px;\q/>\n"
  print "</g>\n"

  for (i=0.6; i<10; i+=0.1) {
    draw_tick(i);
  }

  for (i=10; i<40; i+=0.5) {
   draw_tick(i);
  }

  for (i=40; i<60; i++) {
   draw_tick(i);
  }

  for (i=60; i<80; i+=2) {
   draw_tick(i);
  }

  for (i=80; i<=90; i+=10) {
   draw_tick(i);
  }

  print "</svg>\n"
  
}

/* Call func draw_slide_scale */
draw_slide_scale()
quit

... though using a real programming language (C/C++, Swift, Python etc.) does offer even more powerful possibilities here, especially in terms of more efficient SVG code output definition and generation. - However, since I personally don't like to type in a lot of boring repetitive strings (programers are sometimes lazy), or fiddling around with spreadsheet cells, I tend more to let a program do all the bloody work.


☛ Affinity Designer 1.8.3 ◆ Affinity Photo 1.8.3 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites
12 hours ago, v_kyr said:

However, since I personally don't like to type in a lot of boring repetitive strings (programers are sometimes lazy), or fiddling around with spreadsheet cells, I tend more to let a program do all the bloody work.

In this context, I would argue that the spreadsheet is more efficient than a 'real programming language'. There are only a couple of actual 'calculations' (formulae) to enter. You can drag these formulae down the column to complete the set.

John


Windows 10, Affinity Photo 1.8,3 Designer 1.8.3 and Publisher 1.8.3 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

Share this post


Link to post
Share on other sites
1 hour ago, John Rostron said:

In this context, I would argue that the spreadsheet is more efficient than a 'real programming language'. There are only a couple of actual 'calculations' (formulae) to enter. You can drag these formulae down the column to complete the set.

John

@John Rostron Actually, as someone who started this whole thing, I can most assuredly say, that considering this isn't just about drawing 'tick' marks, but also placing specific text at specific radii in relation to specific ticks, rotating and offsetting each rule in relation to others by exact and specific amounts to produce specific calculation abilities and that the text to be displayed is a semi-complex subset of the numbers belonging to every tick, that having tried drawing manually, doing spreadsheets, and now written a Swift app to generate n number of x type of rules each with their own y formula and comprising of z text requirements... once I understood how to do it in 'real' code... it's much simpler, quicker to change / edit, and much less work to add new rules / rulers and formulae to.

I know @v_kyr will say to me "I told you so..." and as I said to him "I knew you were right..." but I was trying to get the job done, and spending what ended up as 8 days getting my head around Swift code AND SVG xml syntax... it was the best decision. 

Last night, a key person driving the project approached me and pointed out that there were some things needed to be added / changed. I changed a formula, I added an offset, ran the code and re-created the SVG in less time that it would have taken to have made a new spreadsheet and hacked an SVG by hand. 

Thankfully what ended up taking 30 mins could easily have been hours if not longer, using the methods I had previously been using. 

Edited by GreenGirl

Share this post


Link to post
Share on other sites
2 hours ago, John Rostron said:

In this context, I would argue that the spreadsheet is more efficient than a 'real programming language'. There are only a couple of actual 'calculations' (formulae) to enter. You can drag these formulae down the column to complete the set.

Well for spreadsheet formulaes that's sort of graphical calculator style and more of a mouse based point and drag comfort feature for spreadsheet available functions. With a good IDE or text editor, which then is fine tuned to support the used prog languages, you have all sort of language and text specific auto completion and mouse completions (selection lists etc.) too.

Such tools also know to add closing braces or insert paaring quotes and positioning the cursor inbetween and so on further, so have a bunch of comfort and quick turn around features too for less typing. - So what I meant in general more is, to shorten the overall whole input in order to get a complete output generation via a program. Whose language then hopefully supports all kind of loops and range definitions and thus let's you express all kind of possible needed program flow, in order to generate the output text format structures as needed by the problem domain.


☛ Affinity Designer 1.8.3 ◆ Affinity Photo 1.8.3 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites
1 hour ago, GreenGirl said:

I know @v_kyr will say to me "I told you so..." and as I said to him "I knew you were right..." but I was trying to get the job done, and spending what ended up as 8 days getting my head around Swift code AND SVG xml syntax... it was the best decision. 

Now look at it also from the other side, you will also learn a powerful cool programming language, which you can use for just about anything when you have an urgend need for it. - With that, some knowledge and imagination, you can even do things which Affinity by no way can do out of the box. ;-)


☛ Affinity Designer 1.8.3 ◆ Affinity Photo 1.8.3 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites

-@GreenGirl and @v_kyr. An interesting commentary from each of you. I have never heard of Swift until this thread. I would concede that if I needed to create this from scratch, I would probably written it in Python or Ruby, probably following much the same structure as you have done.

I can also support @firstdefencesdescription of @GreenGirl as tenacious!

John

 


Windows 10, Affinity Photo 1.8,3 Designer 1.8.3 and Publisher 1.8.3 (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

Share this post


Link to post
Share on other sites
10 minutes ago, John Rostron said:

I have never heard of Swift until this thread.

13 minutes ago, John Rostron said:

I would concede that if I needed to create this from scratch, I would probably written it in Python or Ruby, probably following much the same structure as you have done.

You can use any better programming language for these things! - Once upon a time the first prog language I've learned was Algol/Pascal, next C/C++, then went the main OO route with Smalltalk, Obj-C, CLOS/Lisp, Eiffel (during academic OO software engineering). In the recent past and so lately Java, C# and Swift. - Beside this named order, I also spend time with scripting tools/langagues for hacking OS related tasks (Unix related the obvious oldies Awk, sed, grep, Perl etc.), which all nowadays have mostly been commonly replaced by Python.

No need to say, that I've forgotten to code in some of the above named programming languages once learned, since as always time goes by, the market priorities do change and thus other major players do dominate nowadays the working field.

 


☛ Affinity Designer 1.8.3 ◆ Affinity Photo 1.8.3 ◆ OSX El Capitan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please note the Annual Company Closure section in the Terms of Use. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.