Change the size of a ink drawn line

Started by markem, April 18, 2014, 06:00:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

markem

Ok - last posting for the night.  I've now thrown out the dimensioned array in favor of just keeping the last line segment and I have it also going from really thin to larger.  I'm beginning to think that just going from large to small may be the only thing I need - but not sure about that.  Still - I'm including a screen snapshot of a quick and dirty river I drew.  Note that I now also have color (just blue) and can now change the color up and down as I want.  Also, all rivers start at 0.001 and go up from there.

g'night everyone! :-)

Just posting the new module

Dim WithEvents vsoWindow As Visio.Window
Dim xc As Double
Dim yc As Double
Dim myButton As String
Dim ox As Double
Dim oy As Double
Dim I As Long
Dim mw As Double
Dim myDir As Long

Private Sub Class_Initialize()

    Set vsoWindow = ActiveWindow
    myButton = "LU"
    Math.Randomize
    mw = 0.001
    myDir = 1
   
End Sub

Private Sub Class_Terminate()

    Set vsoWindow = Nothing

End Sub

Private Sub vsoWindow_MouseDown(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    vsoWindow.DeselectAll
    ox = x
    oy = y
    mw = 0.001
    myDir = 1

    If Button = 1 Then
        myButton = "LD"
        Debug.Print "Left mouse button clicked"
    ElseIf Button = 2 Then
        myButton = "MD"
        Debug.Print "Right mouse button clicked"
    ElseIf Button = 16 Then
        myButton = "RD"
        Debug.Print "Center mouse button clicked"
    End If

End Sub

Private Sub vsoWindow_MouseMove(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
    rateOfChange = 0.001
    If (myButton = "LD") Then
        Set vsoShape = ActivePage.DrawLine(ox, oy, x, y)
        vsoShape.Cells("CenterX") = True
        vsoShape.Cells("CenterY") = True
        vsoShape.Cells("LineColor").Formula = "=RGB(0,0,255)"
        myRand = Math.Rnd * rateOfChange
Debug.Print "mw = "; mw
        If mw < 0.1 And myDir > 0 Then
            mw = mw + myRand
            vsoShape.Cells("LineWeight").Formula = "=" & mw
            ElseIf mw > 0.001 And myDir < 1 Then
                mw = mw - myRand
                vsoShape.Cells("LineWeight").Formula = "=" & mw
            ElseIf mw > 0.1 And myDir > 0 Then
                myDir = 0
                mw = mw - myRand
                vsoShape.Cells("LineWeight").Formula = "=" & mw
            ElseIf mw < 0.001 And myDir < 1 Then
                myDir = 1
                mw = mw + myRand
                vsoShape.Cells("LineWeight").Formula = "=" & mw
            End If
        End If

    ox = x
    oy = y
    vsoWindow.DeselectAll
End Sub

Private Sub vsoWindow_MouseUp(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    ox = x
    oy = y
    mw = 0.001
    myDir = 1

    If Button = 1 Then
        myButton = "LU"
        Debug.Print "Left mouse button released"
    ElseIf Button = 2 Then
        myButton = "MU"
        Debug.Print "Right mouse button released"
    ElseIf Button = 16 Then
        myButton = "RU"
        Debug.Print "Center mouse button released"
    End If
       
    Set myMouseListener = Nothing
    vsoWindow.DeselectAll
End Sub


Yacine

Quote from: wapperdude on April 22, 2014, 02:29:27 AM
@Yacine:  You do realize that page 3 looks like a swan floating on water?   ;)   8)
It's a seal.   ;)   8)
Yacine

markem


Yacine

Quote from: markem on April 22, 2014, 06:12:22 AM
Yacine:  Nice!  I like it!  :-)
I would have prefered, that you like my previous posting.
I think, you are on the wrong path with your line segments. These drawings won't be editable anymore.
Yacine

markem

I don't know why you are saying that.  Are you afraid that there will be too many objects in the drawing?  I DO have some Visio drawings which are so huge that I can only export them as 150-200dpi jpegs.  I'm also not looking for stylized drawings.  I'm looking for something that looks like a jagged river.  Also, once I have something I can use I can always generate a PNG or JPG from the line segments.

If, on the other hand, you are thinking I won't be able to adjust the river after I have drawn it - I've already tested that and can do so easily.  I just zoom in and click on one of the line segments while holding down the shift key and once I have both line segments I can then move that point and both line segments come with me.

Remember that I am using Visio 2003.  Here is what I get using the various drawing tools:

1. Line segment - only short, straight lines.  Useless for drawing rivers
2. Arc - see #1 above
3. Freeform - great if you always want smooth, nice looking curves.  I need jagged ones.  Rivers seen from space would look nice and curvy but up close they eat away at river banks, collapse them, and leave jagged gashes here and there (one of the things I want to do later on).
4. Pencil - See #2 above
5. Inks - These will do what I want and I can convert them to a Geometric type afterwards but it has only one line width.

I know that Visio Guy posted some years ago how to do random shapes in Visio's line drawings and I tried it.  It worked ok and did the same kinds of things that you did with your example but I don't want to end up with a smooth sided object.  As I keep saying - I want a jagged object.  Being able to draw a variable width line is just the first step.  Actually - just being able to draw a line programmatically is the first step.  Then seeing how to do multiple lines is next.  Then adding in color.  Unselecting everything so you don't wind up with a selection box was another step.

Inkscape:  I have Inkscape and think it is ok.  I played around with it when it first came out and it was not all that great.  Now - it is a heck of a lot better and my hat off to them for sticking with it but it isn't Visio and I happen to like Visio as much as some people like Inkscape.  So I'm doing this in Visio.  :-)

Now - if you think what I'm doing NOW in Visio has no merit - just wait until I switch over to PHP and begin converting all of the bitmap images I have for mountains, trees, and so forth into vector images.  There are about 5,000 images and I'd like to convert all of them over.  So I plan on taking what I am learning now and apply it to that.  So why do this?  Because the way Visio works is to always make a copy of whatever it is you put in as an image.  Believe me.  I've tried making shape libraries, templates, etc....  And what I still wound up with were drawings that are over a gigabyte in size because they contain bitmap images and Visio 2003 seems to always just make a copy of the entire image instead of just making a pointer to the image and using that.  So one of the reasons I am going to do this is to see how Visio handles having detailed vector shapes.  If it works like I think it is going to work then my maps will take up a lot less space in memory and they also might be a lot more scaleable.  I'm looking at using PolyLines for those (unless it is just one dot that is a certain color - then a line segment would be used.  Too bad Visio doesn't have a point function.  It would come in handy for those kinds of things.  I may also look at the rectangle function.)

Now.  I have something to say to you, Yacine, and everyone else:  My ultimate goal is to learn the ins and outs of programming Visio 2003.  What I need is HELP.  What I do not want is to have to fight an uphill battle against anyone and everyone who wants to say "But you can do it THIS way".  I do not want to do it THAT way.  I want to learn how to program Visio to make it do what I want it to do.  If you know how to program Visio - then lend your help showing me how to improve on what I am programming.  But if all you want to do is to stop me from achieving my goal of learning how to program Visio - then please go away.  I do not need the hindrance - I need the help.  And I hate to make it sound harsh - but I'm not going to stop trying to learn how to program Visio.  I tried learning it a few years ago but gave up because VBA is just whacky in some ways.  As a programmer who started programming in 1972 - I think I know whacky when I see it.  And VBA is whacky.  So I gave up then but now VBA is making sense to me for unknown reasons and some of the whackiness is also now making sense.  Not that the whackiness is less - just I am now going "Oh.  THAT is why they did that."  So if you want to help - then help me achieve >my< goals.  Don't tell me there is an easier way to do this.  You always have to go through all of the mistakes before you learn the right way to program something.  That is just how it is with programming.  When I get done - I expect to know a lot about VBA and the inner workings of Visio.  I am looking forwards to knowing how to load images, macros, or whatever and to be able to automatically execute whatever script I need to run in order to be able to do what I want to do.  Your help in achieving this goal is appreciated.  But trying to deflect me from this goal - is not.

I do hope you who read this understand what I am saying.  I am NOT trying to be nasty and I am NOT trying to be harsh or ungrateful or anything negative like that.  What I am trying to say is "Help me achieve my goals".  Come with me, stand beside me, show me where I am making my mistakes in my programs.  Show me how I can make them better.  How I can make them run faster or smarter.  Show me - but let me make my mistakes.  It is the only way to learn what not to do as well as what to do.

Thanks!   :)

Yacine

#20
Quote from: markem on April 22, 2014, 06:07:36 PM
Now.  I have something to say to you, Yacine, and everyone else:  My ultimate goal is to learn the ins and outs of programming Visio 2003.  What I need is HELP.  What I do not want is to have to fight an uphill battle against anyone and everyone who wants to say "But you can do it THIS way".  I do not want to do it THAT way.  I want to learn how to program Visio to make it do what I want it to do.  If you know how to program Visio - then lend your help showing me how to improve on what I am programming.  But if all you want to do is to stop me from achieving my goal of learning how to program Visio - then please go away.  I do not need the hindrance - I need the help.  And I hate to make it sound harsh - but I'm not going to stop trying to learn how to program Visio. 

Hi Markem,
sorry for the impression my answers gave to you. I've posted so many answers in this forum, that I probably got beyond answering just the exact question posted to this forum. I, and most of the senior members here, try to think further about how the solution will evolve, how the audience will accept a solution, how this solution can be maintained, what the actual purpose is, ... etc.
Myself and others will often not tell you to just not do somtething, but how to do it better. This is legitim. We can expect this to be respected. It is only fair that everyone can  stands for its convictions.

As I wrote previously, I don't think Visio is the ideal tool for the job, but also that the task is challenging and worth working on it.

As for your wish to learn how to program Visio, we certainly can bring you to an acceptable level. All of the contributors here are very eager to share their knowledge. Some patience and "social competence" are of course helpful.

So far for the "emotional" part, the technical part to follow on further posts.
Yacine

vojo

for what its worth, if you can get the original into a EMF format, you can copy into visio and ungroup.   This will give a collection of shapes that make up the image...you can then group those shapes.  The result is a group with say 100 child shapes inside.

I agree freeform is tough....could play with the sensitivity so any twitches in your hand do not show up on the drawing

Finally, you could put image on background page....on foreground page (using the background page) zoom in to say 800%
and do trace by hand.  when done, disconnect background page in page properties

And if you really are not faint of heart, you could write some VBA to process the pixel into various geometries  ;-)

vojo

Since you are talking inkscape....there may be some Python tools you could use to get the image to some usable form

for example, save with background transparent (so you can place things near it with no problems)
I do know there are python packages to do image processing....so maybe one of those could be extended to do this.

Yacine

#23
Quote from: markem on April 22, 2014, 06:07:36 PM
If, on the other hand, you are thinking I won't be able to adjust the river after I have drawn it - I've already tested that and can do so easily.  I just zoom in and click on one of the line segments while holding down the shift key and once I have both line segments I can then move that point and both line segments come with me.

Remember that I am using Visio 2003.  Here is what I get using the various drawing tools:

1. Line segment - only short, straight lines.  Useless for drawing rivers
2. Arc - see #1 above
3. Freeform - great if you always want smooth, nice looking curves.  I need jagged ones.  Rivers seen from space would look nice and curvy but up close they eat away at river banks, collapse them, and leave jagged gashes here and there (one of the things I want to do later on).
4. Pencil - See #2 above
5. Inks - These will do what I want and I can convert them to a Geometric type afterwards but it has only one line width


It's the second thought.

Editable, means (to me at least) that the user can with a reasonable effort change the document.
With your solution, single vertices can be edited. But when this solution grows up to tens, then to hundreds of vertices every user will just give up.
So the solution should have an underlaying curve that can be edited easily.

Here come the freeform (Bezier) lines and the polylines. That is something to explore furthermore.
There are several cells in the geometry section, that can be decorticated to fullfill custom purposes.

Hope that helps for a first (second?) shot,

Yacine
Yacine

wapperdude

Hey Markem...

Generally, most posters have a vague idea what they want as an end result.  As, the thread progresses and details come out, then the process matures to yield an effective, efficient solution.  Some poster's, as it develops, have very specific criteria, and just get stuck and need a process to solve their issue.  Many of those require looking at alternative methods than the approach initially proposed.  Sometimes, there are no alternatives.  But, it's a process.  Occasionally, the solution lies outside of Visio.

I think your requirements are now better understood.  A critical piece is the "jagged" look.  I suspect, your application is RPG oriented, and that in part explains your tolerance for the intensive time and effort needed.  That's not typical.  But, just as a check point, you have, undoubtedly, looked at other Terrain Fractal programs?  I googled and there does seem to be a few out there, and most geared to RPG application.  Guess that doesn't help with your need to translate existing images.

Wapperdude
Visio 2019 Pro

markem

Yes it does Yacine and thank you for responding!  (You too vojo and wapperdude!)   :)

Yacine : Polylines are easily done via programming but they are considered a single line and thus only one width.  But for the importing of images - yes.  They are what I believe have to be used in order to draw the images (rather than them being bitmaps).  Especially since, if the first and last points are the same - the Polyline becomes a filled shape.  So if a mountain image is mainly just grey with some black lines on it I think I can make the Polyline do all of the grey followed by the black lines on top of that shape.

wapperdude : First - where DID you come up with that name?  I've seen a lot of user names before but yours is definitely unique.  Gotcha on what you said.  I have looked at several (and bought several) programs.  None of them approach the creation of things like coast lines in the same manner in which I want to approach it and none of them do more than let you build a Polyline of a river.  So what you get is a god's eye view of the river.  But woe unto he who tries to do more because you wind up with hours of frustration.  I worked at NASA from 1989 to 2006 and one of the things I did there was to help create maps.  We used Photoshop a lot but we also did it programmatically.  So I could do this in C/C++, PHP, FreeBasic, Perl, and other languages - but I'd like it to be in Visio which means I have to learn VBA.  Because I don't want it to just be an image and I don't want to write my own CAD system.  :)

I am including an example tavern.  Note the tavern looks really nice but the alcoves to the northeast are just added on so people can see where it is located.

wapperdude

 ;D  Well, the name kinda morphed into being.  Initials are WAP.  Work associate used to call me WAPPER.  I'm from Los Angeles, dude.  And, it's unique so no dumb numbers, as if I'm Wapperdude317.

I'm kind of surprised that the RPG community and the fractal orgs don't have something more suitable.  After all, it is 2014!!!

With all your effort, hope Visio and VBA don't end up being a dead end.

Wapperdude   ;)
Visio 2019 Pro

markem

#27
Here is a little something I have already done in Visio for a friend.  The hand drawn map and the Visio map.  :-)

Note on the color map that I used various shades of blue on the INK lines as well as changing the width of the lines as I went.  This is one of the things I want to avoid having to do in the future.

wapperdude

Well...guess I'm still not convinced that Visio is the way to go...perhaps I'm blurring the distinction between a map vs actual landscape rendering.  So, in the latter category, this looks really promising:  http://www.world-machine.com/.

In the former category (maps):  this link list a bunch, including your Campaign Cartography, but many more, including fractal based entries:  http://www.wherethemapends.com/writerstools/writers_tools_pages/world_builders.htm

So, when you take a break, perhaps there's something of interest.

Wapperdude


Visio 2019 Pro

markem

Ok - I looked at World Map/Maker - you don't get to say where things go.  It is more of a "Hey!  Look!  A new world!" kind of program.  You can give it such things as mountains, plateaus, and such but it is not like Visio in that you can place things where you want them to go.

As for the rest - own them.  Tried them.  Not like Visio and rivers are just lines.  The nBoss program can be programmed like Visio but I decided to just go with Viso.

I will be out of the loop for a few days.  I have found a strange bug in jQuery and am trying to figure out what I want to do with that.  Not that this is a Visio problem - but what jQuery is doing is it will load up a web page onto a computer and then just....die.  There aren't any error messages and Javascript doesn't throw any error messages either.  It just - dies.  Firebug doesn't even show any code.  IE's debugger breaks on a "|" symbol that doesn't exist, and my other debuggers are just as baffled.  I switched all of my PHP/Javascript/HTML web pages over to jQuery and now I'm wondering if I made the wrong choice.  So I need to go look at this and find out just exactly what is going on.  It may take me as long as a week and as short as five minute.

My next step I was working on is to use a Polyline to show the fractal line that would be drawn.  In this way I can add/remove the line as the person drags their cursor from point A to point B.  Once the person lets go of the mouse, the Polyline is removed and the line segments are put in its place with the varying widths.  I should have it up and running by next week.