4 Replies Latest reply on Jun 2, 2008 9:56 AM by Newsgroup_User

    draw() in imaging lingo - thick lines?

    Level 7
      Is there a good way to draw a thick line on a linegraph using imaging lingo?
      I figured out the whole [#lineSize:3] thing, but it looks terrible - the
      line is all dashed at every interval, squashed on curves that are
      near-horizontal, and vertically broken and skewed on steeper slopes. It's
      seems like the rect you give it is being used for the entire line segment,
      instead of the endpoints of the segment. The thicker you make the line, the
      worse it gets. The best solution I could come up with was to draw the line
      at 1 pixel thickness, then redraw it again 1 pixel up, 1 pixel down, 1 pixel
      to the left, and 1 pixel to the right. This looks okay, but of course takes
      5 times as long to render, and I don't like the speed it runs at. Any other
      suggestions?


        • 1. draw() in imaging lingo - thick lines?
          Chunick Level 3
          use vectorshapes:
          -- thickness can be a floating point value between 1 and 100
          on createLine (point1, point2, thickness, colour)
          vertList = [[#vertex: point1], [#vertex: point2]]
          mem = new(#vectorShape)
          mem .vertexList = vertList
          mem.strokeWidth = thickness
          -- colour is optional, default is black
          if voidP(colour) then colour = color( 0, 0, 0 )
          mem.strokeColor = colour
          img = mem.image.duplicate()
          mem.erase()
          return img
          end

          if you wanted to create it to input the length then it might look like this:
          -- lineDirection = #updown, #leftright
          on createLine (lineLength, lineDirection, thickness, colour)
          if lineDirection = #updown then
          vertList = [[#vertex: point(0,0)], [#vertex: point(lineLength, 0)]]
          else
          vertList = [[#vertex: point(0,0)], [#vertex: poing(0, lineLength)]]
          end if
          mem = new(#vectorShape)
          mem .vertexList = vertList
          mem.strokeWidth = thickness
          -- colour is optional, default is black
          if voidP(colour) then colour = color( 0, 0, 0 )
          mem.strokeColor = colour
          img = mem.image.duplicate()
          mem.erase()
          return img
          end

          ** Note: this is untested code.
          • 2. Re: draw() in imaging lingo - thick lines?
            Level 7
            > use vectorshapes:

            I don't know - just about every time I've touched vectorshapes in Director,
            they end up glitching out and/or crashing the program. As far as I'm
            concerned, they're a broken and unusable feature - unless this has been
            fixed as of D11? I'm still on MX04 and will likely stay that way for a
            while (until some of the other ugly issues I've been hearing about are
            resolved).

            I did come up with an interim solution, which was to add lineSize/2 around
            all sides of the rect for the draw() function - the only stipulation being
            that you have to add to the first param and subtract from the third when the
            slope goes up, and vice versa when the slope goes down. A little more code
            than should be necessary for this (though still considerably less than the
            vectorshape method, and much more stable too), so I'm satisfied for now.


            • 3. Re: draw() in imaging lingo - thick lines?
              Chunick Level 3
              Using vectorshapes in a limited fashion for imaging lingo has always worked fine for me... well, the code is there to reference, if you need.
              • 4. Re: draw() in imaging lingo - thick lines?
                Level 7
                > Using vectorshapes in a limited fashion for imaging lingo has always
                > worked fine for me... well, the code is there to reference, if you need.

                Hmm, looking at how that works it might not be so bad - except I'd have to
                severely modify it, as I have more than one line displaying on the graph at
                once, and if I used this method, it would overwrite the existing graph every
                time, and only the last line drawn would show. Is it possible to have more
                than one differently-colored line display in a vectorshape? Or to maybe
                overlay the line onto the bitmap sprite without erasing the existing line(s)
                already on there?