Loading ...
Sorry, an error occurred while loading the content.

Re: [cc2-dev-l] FCW to SVG Progress

Expand Messages
  • BC Holmes
    ... I m certainly willing to share any code I write, but at the moment, I m not writing anything in .Net, so I don t have any glue routines. The code I ve
    Message 1 of 27 , Feb 27, 2012
    • 0 Attachment
      On 12-02-27 11:10 AM, L. Lee Saunders wrote:
      >
      > BC, if you write any glue routines, please post them for all to use, OK?


      I'm certainly willing to share any code I write, but at the moment, I'm
      not writing anything in .Net, so I don't have any glue routines. The
      code I've written so far has been in Java.

      I'll probably end up porting my code back to C eventually (my C is rusty
      though).

      BCing you
      --
      B.C. Holmes \u2625 http://www.bcholmes.org/
      "All my life I've wanted to be somebody; I guess I should've been
      more specific." -- Lily Tomlin
    • BC Holmes
      ... w00t! Today, I finally reached the ah-ha moment of b-splines and Bezier curves! Here s the town of Greenheight, again:
      Message 2 of 27 , Mar 11 4:55 PM
      • 0 Attachment
        On 12-02-24 9:57 AM, Peter Olsson wrote:
        > I'm a bit confused about if SVG uses Cubic B-splines or Bezier functions.
        >
        > There are conversions between the two though. Google turned up this paper:
        > http://i33www.ibds.uni-karlsruhe.de/papers/Buchauswahl.pdf
        > See 5.10 on PDF-page 44 (number 72 on the page)
        >
        > Since it is possible there ought to be more practical references as well.


        w00t! Today, I finally reached the ah-ha moment of b-splines and Bezier
        curves!

        Here's the town of Greenheight, again:

        http://bcholmes.org/maps/TownOf%20Greenheight.svg

        and PNG:

        http://bcholmes.org/maps/TownOf%20Greenheight.png


        I like this example because it has a number of curves in it.

        Here's the algorithm I used: the FCW path entity has a number of points
        identified. Let's call them B[0], B[1], ... B[n].

        To turn this into a Cubic Bezier, we need to imagine that we've broken
        up the B-Spline into n different curves. Our first task is to identify
        the end points of those curves. Thus, the first curve goes from S[0] to
        S[1], and the second from S[1] to S[2].

        Clearly, S[0] = B[0], and S[n] = B[n], where 'n' is the last index.

        This paper over here, gave me the following algorithm:

        http://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf

        S[i] = 1/6 B[i-1] + 2/3 B[i] + 1/6 B[i+1]

        This is based on an idea that in order to define a particular point on
        the B-spline, you can break up the line connecting, say, B[0] to B[1]
        into thirds. Thus, you can imagine a triangle with one corner at B[1],
        and the other two corners defined by the newly-imagined "third of the
        way" to B[0] and the point "a third of the way" to B[2]. The edge of
        that triangle (opposite from B[1]) touches the B-Spline at S[1].

        Now, clearly, we define the math of points in the obvious way:

        a * Point(x, y) = Point(a * x, a * y)

        and

        Point(x1, y1) + Point(x2, y2) = Point(x1 + x2, y1 + y2).

        So now that we have the endpoints, we just need to the Bezier control
        points, and we define the curve using two end points and two control points:

        Curve[i] = S[i-1], 2/3 B[i-1] + 1/3 B[i], 1/3 B[i-1] + 2/3 B[i], S[i]

        I gotta say, I'm feeling pretty chuffed at the moment. I knew none of
        this math a few weeks ago, and now, not only do I have a working
        solution, I actually understand it!

        BCing you
        --
        B.C. Holmes \u2625 http://www.bcholmes.org/
        "All my life I've wanted to be somebody; I guess I should've been
        more specific." -- Lily Tomlin
      • Peter Olsson
        Good job! Thanks for sharing your efforts. Peter ... Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För BC Holmes Skickat: den 12 mars
        Message 3 of 27 , Mar 12 2:23 AM
        • 0 Attachment
          Good job!

          Thanks for sharing your efforts.

          Peter

          -----Ursprungligt meddelande-----
          Från: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] För BC
          Holmes
          Skickat: den 12 mars 2012 00:56
          Till: cc2-dev-l@yahoogroups.com
          Ämne: [cc2-dev-l] Splines

          On 12-02-24 9:57 AM, Peter Olsson wrote:
          > I'm a bit confused about if SVG uses Cubic B-splines or Bezier
          functions.
          >
          > There are conversions between the two though. Google turned up this
          paper:
          > http://i33www.ibds.uni-karlsruhe.de/papers/Buchauswahl.pdf
          > See 5.10 on PDF-page 44 (number 72 on the page)
          >
          > Since it is possible there ought to be more practical references as
          well.


          w00t! Today, I finally reached the ah-ha moment of b-splines and Bezier
          curves!

          Here's the town of Greenheight, again:

          http://bcholmes.org/maps/TownOf%20Greenheight.svg

          and PNG:

          http://bcholmes.org/maps/TownOf%20Greenheight.png


          I like this example because it has a number of curves in it.

          Here's the algorithm I used: the FCW path entity has a number of points
          identified. Let's call them B[0], B[1], ... B[n].

          To turn this into a Cubic Bezier, we need to imagine that we've broken up
          the B-Spline into n different curves. Our first task is to identify the
          end points of those curves. Thus, the first curve goes from S[0] to S[1],
          and the second from S[1] to S[2].


          Clearly, S[0] = B[0], and S[n] = B[n], where 'n' is the last index.

          This paper over here, gave me the following algorithm:

          http://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf

          S[i] = 1/6 B[i-1] + 2/3 B[i] + 1/6 B[i+1]

          This is based on an idea that in order to define a particular point on the
          B-spline, you can break up the line connecting, say, B[0] to B[1] into
          thirds. Thus, you can imagine a triangle with one corner at B[1], and the
          other two corners defined by the newly-imagined "third of the way" to B[0]
          and the point "a third of the way" to B[2]. The edge of that triangle
          (opposite from B[1]) touches the B-Spline at S[1].

          Now, clearly, we define the math of points in the obvious way:

          a * Point(x, y) = Point(a * x, a * y)

          and

          Point(x1, y1) + Point(x2, y2) = Point(x1 + x2, y1 + y2).

          So now that we have the endpoints, we just need to the Bezier control
          points, and we define the curve using two end points and two control
          points:

          Curve[i] = S[i-1], 2/3 B[i-1] + 1/3 B[i], 1/3 B[i-1] + 2/3 B[i], S[i]

          I gotta say, I'm feeling pretty chuffed at the moment. I knew none of
          this math a few weeks ago, and now, not only do I have a working solution,
          I actually understand it!

          BCing you
          --
          B.C. Holmes \u2625 http://www.bcholmes.org/
          "All my life I've wanted to be somebody; I guess I should've been more
          specific." -- Lily Tomlin


          ------------------------------------

          To Post a message, send it to: cc2-dev-l@...
          To Unsubscribe, send a blank message to:
          cc2-dev-l-unsubscribe@...! Groups Links
        • bi11_h0ward
          The FCW to SVG results are already looking pretty impressive. What do you plan to do with the completed program? It would be a very, very useful way of
          Message 4 of 27 , Mar 12 8:45 AM
          • 0 Attachment
            The FCW to SVG results are already looking pretty impressive. What do you plan to do with the completed program?

            It would be a very, very useful way of showing complex maps in all their glory on the web!

            Bill H
          • L. Lee Saunders
            Plus I hope he is going to reverse the process. I would love to be able to roundtrip a map with Inkscape, CorelDraw or Illustrator! From:
            Message 5 of 27 , Mar 12 8:53 AM
            • 0 Attachment

              Plus I hope he is going to reverse the process.  I would love to be able to roundtrip a map with Inkscape, CorelDraw or Illustrator!

               

              From: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] On Behalf Of bi11_h0ward
              Sent: Monday, March 12, 2012 10:45 AM
              To: cc2-dev-l@yahoogroups.com
              Subject: [cc2-dev-l] Re: FCW to SVG Progress

               

               

              The FCW to SVG results are already looking pretty impressive. What do you plan to do with the completed program?

              It would be a very, very useful way of showing complex maps in all their glory on the web!

              Bill H

            • BC Holmes
              ... Hey Bill, Thanks for the kind words. You do ask the interesting question: what s going to become of this? The answer is that I m not sure. I ve pondered
              Message 6 of 27 , Mar 12 3:58 PM
              • 0 Attachment
                On 12-03-12 11:45 AM, bi11_h0ward wrote:
                > The FCW to SVG results are already looking pretty impressive. What
                > do you plan to do with the completed program?


                Hey Bill,

                Thanks for the kind words. You do ask the interesting question: what's
                going to become of this? The answer is that I'm not sure.

                I've pondered a couple of ideas here and there -- one thought was to
                port my Java code back to C or C++ and then put a bit of an Objective-C
                wrapper around it to build a viewer that I can use to view maps on my
                Mac. It's kinda bummed me out not being able to do anything with these
                maps on the Mac.

                Mostly, though, I just started doing it on a lark, and I kept being
                engaged because of interesting technical challenges here and there.

                One option, obviously, would be to get the code in a good enough state
                (including, probably, a conversion to C or C++) that ProFantasy can use
                it to create an "Export as SVG" menu option. I don't know if they have
                any interest in that, but I'm certainly willing to share my code with
                them (after all, people on this forum have been great about sharing
                their expertise with me!)

                Did you (or anyone else on this mailing list) have any good ideas?


                > It would be a very, very useful way of showing complex maps in all
                > their glory on the web!

                *nod* I hear ya!

                It feels to me like exporting to SVG is going to have certain
                limitations -- I mean, for example, I've only tackled vector
                capabilities, and I can foresee of a whole batch of complications if I
                start thinking about raster images (which seems to be the more popular
                side of CC3 these days).


                BCing you
                --
                B.C. Holmes \u2625 http://www.bcholmes.org/
                "All my life I've wanted to be somebody; I guess I should've been
                more specific." -- Lily Tomlin
              • BC Holmes
                ... Eeeep! Wow, that s a tall order. I mean, just thinking about importing Inkscape is mind-boggling enough. What do you do with all the SVG features that
                Message 7 of 27 , Mar 12 4:02 PM
                • 0 Attachment
                  On 12-03-12 11:53 AM, L. Lee Saunders wrote:
                  > Plus I hope he is going to reverse the process. I would love to be able to
                  > roundtrip a map with Inkscape, CorelDraw or Illustrator!


                  Eeeep! Wow, that's a tall order.

                  I mean, just thinking about importing Inkscape is mind-boggling enough.
                  What do you do with all the SVG features that don't map nicely to the
                  FCW format? Colors, filters, gradients. It's a bit daunting.

                  But, hey, sometimes daunting is exciting.

                  BC
                  --
                  B.C. Holmes \u2625 http://www.bcholmes.org/
                  "All my life I've wanted to be somebody; I guess I should've been
                  more specific." -- Lily Tomlin
                • L. Lee Saunders
                  ... Even a partial round trip would help a lot. Just vectors would be great. Just think of it ... some of the vector effects in these other apps ... I
                  Message 8 of 27 , Mar 12 5:53 PM
                  • 0 Attachment
                    > > Plus I hope he is going to reverse the process. I would love to be able to
                    > > roundtrip a map with Inkscape, CorelDraw or Illustrator!
                    >  
                    >  Eeeep! Wow, that's a tall order.


                    Even a partial round trip would help a lot.  Just vectors would be great.  Just think of it ... some of the vector effects in these other apps ... I wouldn't even know how to start coding some of those effects into CC3.
                      
                    >  I mean, just thinking about importing Inkscape is mind-boggling enough.
                    >  What do you do with all the SVG features that don't map nicely to the
                    >  FCW format? Colors, filters, gradients. It's a bit daunting.

                    True ...

                    >  But, hey, sometimes daunting is exciting.



                    Very true ...
                  • L. Lee Saunders
                    ... Going one way, you can actually embed the bitmap bytes in the SVG file. Going the other way, you will need to reference an external file.
                    Message 9 of 27 , Mar 12 5:57 PM
                    • 0 Attachment


                      >  It feels to me like exporting to SVG is going to have certain
                      >  limitations -- I mean, for example, I've only tackled vector
                      >  capabilities, and I can foresee of a whole batch of complications if I
                      >  start thinking about raster images (which seems to be the more popular
                      >  side of CC3 these days)


                      Going one way, you can actually embed the bitmap bytes in the SVG file.  Going the other way, you will need to reference an external file.
                    • BC Holmes
                      ... Oh, sure. It s not a technical limitation. But I seem to recall CC3 going to lengths to protect their PNG images and keep them from being redistributed.
                      Message 10 of 27 , Mar 12 6:07 PM
                      • 0 Attachment
                        On 12-03-12 8:57 PM, L. Lee Saunders wrote:
                        >
                        >> It feels to me like exporting to SVG is going to have certain
                        >> limitations -- I mean, for example, I've only tackled vector
                        >> capabilities, and I can foresee of a whole batch of complications
                        >> if I start thinking about raster images (which seems to be the more
                        >> popular side of CC3 these days)

                        > Going one way, you can actually embed the bitmap bytes in the SVG
                        > file. Going the other way, you will need to reference an external
                        > file.

                        Oh, sure. It's not a technical limitation. But I seem to recall CC3
                        going to lengths to protect their PNG images and keep them from being
                        redistributed. If the Export as SVG function makes it easy to plonk an
                        image into an SVG file, then the images aren't terribly well-protected.

                        *shrug*

                        BCing you
                        --
                        B.C. Holmes \u2625 http://www.bcholmes.org/
                        "All my life I've wanted to be somebody; I guess I should've been
                        more specific." -- Lily Tomlin
                      • Simon Rogers
                        We would prefer links to art. Does the SVG file format support relative paths? Our file names can start with a #, representing the path to CC3, or a $
                        Message 11 of 27 , Mar 13 5:22 AM
                        • 0 Attachment
                          We would prefer links to art. Does the SVG file format support relative
                          paths? Our file names can start with a #, representing the path to CC3, or a
                          $ representing the folder in which the current map resides.
                          --
                          Simon

                          -----Original Message-----
                          From: cc2-dev-l@yahoogroups.com [mailto:cc2-dev-l@yahoogroups.com] On Behalf
                          Of BC Holmes
                          Sent: 13 March 2012 01:08
                          To: cc2-dev-l@yahoogroups.com
                          Subject: Re: [cc2-dev-l] Re: FCW to SVG Progress

                          On 12-03-12 8:57 PM, L. Lee Saunders wrote:
                          >
                          >> It feels to me like exporting to SVG is going to have certain
                          >> limitations -- I mean, for example, I've only tackled vector
                          >> capabilities, and I can foresee of a whole batch of complications if
                          >> I start thinking about raster images (which seems to be the more
                          >> popular side of CC3 these days)

                          > Going one way, you can actually embed the bitmap bytes in the SVG
                          > file. Going the other way, you will need to reference an external
                          > file.

                          Oh, sure. It's not a technical limitation. But I seem to recall CC3 going
                          to lengths to protect their PNG images and keep them from being
                          redistributed. If the Export as SVG function makes it easy to plonk an
                          image into an SVG file, then the images aren't terribly well-protected.

                          *shrug*

                          BCing you
                          --
                          B.C. Holmes \u2625 http://www.bcholmes.org/
                          "All my life I've wanted to be somebody; I guess I should've been more
                          specific." -- Lily Tomlin


                          ------------------------------------

                          To Post a message, send it to: cc2-dev-l@...
                          To Unsubscribe, send a blank message to:
                          cc2-dev-l-unsubscribe@...! Groups Links
                        • bi11_h0ward
                          I can see that included images of any type would be an issue, particularly if these are copyright as it is all too easy to extract data from websites. The
                          Message 12 of 27 , Mar 13 10:34 AM
                          • 0 Attachment
                            I can see that included images of any type would be an issue, particularly if these are copyright as it is all too easy to 'extract' data from websites. The major problem being to sort out which images are (copyright) acceptable and which not.

                            However the program itself would still be of major value to people like me who make extensive use of the vector facilities of CC3. Also (for me at least) Java isn't really an issue, as I can run it on any machine.

                            I currently a problem with some my more detailed maps (for the web) where I need very high resolutions, as I get can aborts from CC3 (perhaps the 32bit limit?) and have to keep adjusting the resolution until it works. The program would (potentially) be a great solution.
                          • BC Holmes
                            ... Hey Bill, Thanks for your comments. They ve helped crystalize some thoughts in my own head. When I started this exercise, I feared that there might be
                            Message 13 of 27 , Mar 14 6:53 PM
                            • 0 Attachment
                              On 12-03-13 1:34 PM, bi11_h0ward wrote:
                              >
                              > However the program itself would still be of major value to people
                              > like me who make extensive use of the vector facilities of CC3. Also
                              > (for me at least) Java isn't really an issue, as I can run it on any
                              > machine.


                              Hey Bill,

                              Thanks for your comments. They've helped crystalize some thoughts in my
                              own head.

                              When I started this exercise, I feared that there might be some push
                              back on the overall conversion. One way of looking at what I'm doing is
                              to see it as something that enables people to take their maps out of CC3
                              -- one might legitimately ask the question, "will people stop using CC3
                              if Inkscape or whatever is more easily available?" I think the answer
                              to that is "no," because CC3 is specialized for a role that is very
                              different than general-purpose vector art tools.

                              But I don't think I had really asked myself, "why does it help people to
                              be able to have SVG exports of maps?" For me, the answer was just
                              simply, "SVG is cool!" I think that you raise a good answer to that
                              question -- that it's nice to be able to post maps to web sites. You
                              can make the case that PNG already gives you that ability, but SVG is
                              scriptable! Imagine interactive maps on the Internet. That work on Mac
                              and Linux! That's kind of exciting.

                              Increasingly, I'm thinking about this in terms of "workflow". Like, say
                              I want to create a maps in CC3, and then after it's all designed, I want
                              to touch it up with some graphic effects -- maybe I want to "age" the
                              map so that it looks like parchment, or rough it up in ways that tools
                              like Illustrator are good at. I think that SVG can be a good, enabling
                              way to take diagrams from one tool into another tool. I'm sure people
                              do that with PNGs, today, but vector gives you more options.


                              > I currently a problem with some my more detailed maps (for the web)
                              > where I need very high resolutions, as I get can aborts from CC3
                              > (perhaps the 32bit limit?) and have to keep adjusting the resolution
                              > until it works. The program would (potentially) be a great
                              > solution.


                              So, uh, I'm ambivalent about suggesting this, but if you're interested,
                              I'd be happy to make a copy of the code available to you (or anyone who
                              wants it). I'm ambivalent because I'm sure that you'll be disappointed
                              by all the things that I don't yet have good support for. But if you
                              want to give it a whirl I could do that (I've already been emailed by
                              one person who was interested, and I put a downloadable zip file on my
                              server).


                              BCing you
                              --
                              B.C. Holmes \u2625 http://www.bcholmes.org/
                              "All my life I've wanted to be somebody; I guess I should've been
                              more specific." -- Lily Tomlin
                            • Simon Rogers
                              Message 14 of 27 , Mar 15 1:45 AM
                              • 0 Attachment
                                <<
                                When I started this exercise, I feared that there might be some push back on
                                the overall conversion. One way of looking at what I'm doing is to see it
                                as something that enables people to take their maps out of CC3
                                -- one might legitimately ask the question, "will people stop using CC3 if
                                Inkscape or whatever is more easily available?" I think the answer to that
                                is "no," because CC3 is specialized for a role that is very different than
                                general-purpose vector art tools.
                                >>

                                I agree - many people do after effects in Photoshop, too.

                                From the other perspective, an import filter would be very useful to CC3
                                users - there is a lot of material out there in SVG format.

                                Simon
                              • bi11_h0ward
                                I agree that refining maps in Photoshop/Paintshop would be an excellent use to give `Work of Art maps that final touch. Another use that I was thinking of
                                Message 15 of 27 , Mar 15 3:36 AM
                                • 0 Attachment
                                  I agree that refining maps in Photoshop/Paintshop would be an excellent use to give `Work of Art' maps that final touch. Another use that I was thinking of was displaying maps on the internet with overlays. These might be grid systems, hotspot, dragable character-icons and 'Fog of War' obscurement etc. (The later is not quite as useful unless backend processed as the Internet is just too easy to 'hack' , how much do you trust your players?)

                                  Looking forward to seeing the latest instalment in your development!

                                  Bill H
                                • L. Lee Saunders
                                  ... I agree with Simon on this. Not only is there a lot of Stuff out there in SVG format, but there are a lot of vector stuff out there period. And, since
                                  Message 16 of 27 , Mar 16 7:14 AM
                                  • 0 Attachment

                                    > From the other perspective, an import filter would be very useful to CC3
                                    > users - there is a lot of material out there in SVG format.

                                    > Simon

                                    I agree with Simon on this.  Not only is there a lot of "Stuff" out there in SVG format, but there are a lot of vector stuff out there period.  And, since SVG is a standard output format, no matter what format it is currently in, we can get it into SVG.
                                     
                                    If you come at it with the idea that if you do not know how to convert the element, just ignore it and go to the next element, at least we can get SOMETHING into CC3 from SVG.
                                     
                                    Lee

                                  • bcholmes2001
                                    ... Okay. I buy this. Let me see what I can wrestle up. BCing you
                                    Message 17 of 27 , Mar 16 7:27 AM
                                    • 0 Attachment
                                      --- In cc2-dev-l@yahoogroups.com, "L. Lee Saunders" <saunderl@...>
                                      >
                                      > I agree with Simon on this. Not only is there a lot of "Stuff"
                                      > out there in SVG format, but there are a lot of vector stuff out
                                      > there period. And, since SVG is a standard output format, no
                                      > matter what format it is currently in, we can get it into SVG.
                                      > If you come at it with the idea that if you do not know how to
                                      > convert the element, just ignore it and go to the next element,
                                      > at least we can get SOMETHING into CC3 from SVG.

                                      Okay. I buy this.

                                      Let me see what I can wrestle up.

                                      BCing you
                                    Your message has been successfully submitted and would be delivered to recipients shortly.