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

Compound pens

Expand Messages
  • Adam Versteegen
    I m fairly new (as in about an hour) to the canvas... I ve done extensive 2D work mainly in windows but have long been looking for a suitable web browser based
    Message 1 of 3 , May 2, 2006
    • 0 Attachment
      I'm fairly new (as in about an hour) to the canvas... I've done extensive 2D work mainly in windows but have long been looking for a suitable web browser based environment for 2D drawing.

      So far this looks awesome. One question I have is whether there is any API or combination of other API's that would enable the emulation of 'compound pens'. Anyone familiar with GDI+ on windows would know what i'm talking about, but for those that aren't it essentially enables you to create a pen made of mutiple lines.

      The way it works is you specify the width of your pen, then specify how the pen is 'composed' (bad word, but not sure how else to describe it).

      As an example, say you have a pen 10 pixels wide. You could specify that the first 20% is stroked, the next 20% not and the final 60% is. Anything you stroked with that pen would then be stroked with 2 lines, one thin next to one thick.

      Another example would be drawing traing tracks. Using a single pen you could specify the first 10% and last 10% of the pen is stroked, while the middle isn't. Anything you draw with that would then be drawn with two parallel lines.



      Anyone know if its possible or know ways to use other API's to achieve the same thing? I'm trying to achieve two effects to verify this (or similar) capability... The first is being able to draw 2 equal thickness parallel bezier and/or quadratic curves (eg like train tracks) the second is to be able draw a set of 'lop sided' train tracks where the two curves are parallel but one side may be thicker than the other.

      Any ideas?

      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com

    • Chris Nokleberg
      ... In general I think it would be hard to do this in pure javascript, there is a lot of math going on. I ve needed something very similar for a dynamic SVG
      Message 2 of 3 , May 2, 2006
      • 0 Attachment
        On Tue, May 02, 2006 at 11:07:23AM -0700, Adam Versteegen wrote:
        > Anyone know if its possible or know ways to use other API's to achieve
        > the same thing? I'm trying to achieve two effects to verify this (or
        > similar) capability... The first is being able to draw 2 equal
        > thickness parallel bezier and/or quadratic curves (eg like train
        > tracks) the second is to be able draw a set of 'lop sided' train
        > tracks where the two curves are parallel but one side may be thicker
        > than the other.

        In general I think it would be hard to do this in pure javascript, there
        is a lot of math going on.

        I've needed something very similar for a dynamic SVG application, and my
        solution was to have a Java-based server which I make XMLHttpRequest
        calls to. I pass it the outline of the shape I want stroked, and the
        type of stroke, and the server sends back the path commands describing
        the result. This is all serialized in JSON. The code to actually create
        the strokes on the server-side is pretty simple in Java2D.

        Chris
      • adamvesty
        ... Not sure if that would work for me... I m looking to create an in browser drawing application that would need the ability to draw lines as explained above.
        Message 3 of 3 , May 2, 2006
        • 0 Attachment
          --- In canvas-developers@yahoogroups.com, Chris Nokleberg <chris@...>
          wrote:
          >
          > On Tue, May 02, 2006 at 11:07:23AM -0700, Adam Versteegen wrote:
          > > Anyone know if its possible or know ways to use other API's to achieve
          > > the same thing? I'm trying to achieve two effects to verify this (or
          > > similar) capability... The first is being able to draw 2 equal
          > > thickness parallel bezier and/or quadratic curves (eg like train
          > > tracks) the second is to be able draw a set of 'lop sided' train
          > > tracks where the two curves are parallel but one side may be thicker
          > > than the other.
          >
          > In general I think it would be hard to do this in pure javascript, there
          > is a lot of math going on.
          >
          > I've needed something very similar for a dynamic SVG application, and my
          > solution was to have a Java-based server which I make XMLHttpRequest
          > calls to. I pass it the outline of the shape I want stroked, and the
          > type of stroke, and the server sends back the path commands describing
          > the result. This is all serialized in JSON. The code to actually create
          > the strokes on the server-side is pretty simple in Java2D.


          Not sure if that would work for me... I'm looking to create an in
          browser drawing application that would need the ability to draw lines
          as explained above. If it needed to talk to a server to determine
          exactly how to render a given line I imagine that would slow the
          responsiveness of the application down to the point where it would
          make it not worthwhile.

          I'll keep playing though...
        Your message has been successfully submitted and would be delivered to recipients shortly.