Drawing math shape

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bH

    Drawing math shape

    Hi All,
    I have been looking at javascript drawing from this website :

    http://www.cwdjr.net/geometricDraw/pentagon_draw.h tml"

    and I am wondering why the author made it
    into two images : upper half then lower half?. Is there a rule that
    says
    you can't do it in one set of calculated values for all the points as
    the points
    are placed in the document.write( )?

    The javascript is placed below for reference:
    .....start of copied?

    <script type="text/javascript">

    document.bgColo r="000000";

    var py1=150 // y position of center of pentagon ;
    var px=272 // x psition of center of pentagon ;
    var r1=150 // radius that just holds pentagon
    var ctr=0 ; // division counter ;

    anga=(2*Math.PI )/5 ;
    sl=r1*Math.sin( (2*Math.PI)/5) ;
    d=r1*Math.cos(( Math.PI)/5) ;
    e=r1*Math.cos(( 2*Math.PI)/5) ;
    h1=d+e ;
    f=e*Math.tan(an ga) ;
    px1=px-f ; px2=px+f ;
    h2=r1-e ;
    sbeta=e/r1 ;
    gamma=(Math.PI - anga)/2 ;
    phi=gamma+Math. asin(sbeta) ;
    tphi=Math.tan(p hi) ;
    line=px2-px1 ;

    for (r=0;r<h2;r=r+1 ) {
    z=Math.round((r *line)/(2*h2)) ;
    x=px1+z ;
    y=py1-r ;
    wd=line-2*z ;
    rd=255 ; gn=0 ; bl=0 ;
    document.write( '<div id=\"a'+ctr+'\" style=\"positio n:absolute;
    left:'+x+'px; top:'+y+'px; height: 1px; width:'+wd+'px;

    background-color: rgb('+rd+','+gn +','+bl+'); z-index:1;
    visibility:visi ble\"><\/div>') ;
    ctr=ctr+1 ;
    window.status=" DIVISIONS
    WRITTEN="+ctr ;
    for (r=0;r<h1;r=r+1 ) {
    z=Math.round(r/tphi) ;
    x=px1+z ;
    y=py1+r ;
    wd=line-2*z ;
    rd=255 ; gn=0 ; bl=0 ;
    document.write( '<div id=\"a'+ctr+'\" style=\"positio n:absolute;
    left:'+x+'px; top:'+y+'px; height: 1px; width:'+wd+'px;

    background-color: rgb('+rd+','+gn +','+bl+'); z-index:1;
    visibility:visi ble\"><\/div>') ;
    ctr=ctr+1 ;
    window.status=" DIVISIONS WRITTEN="+ctr ;
    }
    </script>
    </head>
    <body>
    <script type="text/javascript">
    if (px1<0 || px1>544 || px2<=px1 || px2>544) {
    window.status=" Input values too extreme." } ;
    </script>

    .....end of copied
    TIA
    bH
  • Thomas 'PointedEars' Lahn

    #2
    Re: Drawing math shape

    bH wrote:
    I have been looking at javascript drawing from this website :
    >
    http://www.cwdjr.net/geometricDraw/pentagon_draw.h tml"
    >
    and I am wondering why the author made it into two images : upper half
    then lower half?.
    There are no images. Firebug shows there are but a number of generated 1px
    high HTML `div' elements, a rather stupid design.
    Is there a rule that says you can't do it in one set of calculated values
    for all the points as the points are placed in the document.write( )?
    There is a rule that says: the right tool for the right purpose. The right
    tool here is (standards-compliant) SVG (which is supported well enought to
    be used in Wikipedia for all kinds of scalable graphics) or maybe
    (proprietary) Canvas; certainly not plain HTML. The whole thing there is a
    nice inefficient beginner's exercise, nothing more.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee

    Comment

    • SAM

      #3
      Re: Drawing math shape

      bH a écrit :
      Hi All,
      I have been looking at javascript drawing from this website :
      >
      http://www.cwdjr.net/geometricDraw/pentagon_draw.h tml"
      In same idea :
      <http://www.walterzorn. com/jsgraphics/jsgraphics_e.ht m>
      and I am wondering why the author made it
      into two images : upper half then lower half?.
      perhaps because he could not resolve the drawing of a pentagone ?
      and preferred to draw a triangle then a trapeze ?

      How do you do to find the position of the 5 points of a pentagone
      (relatively to x and y axes)


      Same question using canvas or svg ... ? !

      --
      sm

      Comment

      • Bart Van der Donck

        #4
        Re: Drawing math shape

        Thomas 'PointedEars' Lahn wrote:
        bH wrote:
        >I have been looking at javascript drawing from this website :
        >
        >http://www.cwdjr.net/geometricDraw/pentagon_draw.h tml"
        >and I am wondering why the author made it into two images : upper half
        >then lower half?.
        >
        There are no images.  Firebug shows there are but a number of generated1px
        high HTML `div' elements, a rather stupid design.
        >
        >Is there a rule that says you can't do it in one set of calculated values
        >for all the points as the points are placed in the document.write(  )?
        >
        There is a rule that says: the right tool for the right purpose.  The right
        tool here is (standards-compliant) SVG (which is supported well enought to
        be used in Wikipedia for all kinds of scalable graphics) or maybe
        (proprietary) Canvas; certainly not plain HTML.
        I would probably prefer a Google Chart that outputs PNG to an <img
        srccall. For example, the requirement of the original poster:



        Manual:
        Discover the resources for adding interactive charts for browsers and mobile devices.


        --
        Bart

        Comment

        • bH

          #5
          Re: Drawing math shape

          On Aug 2, 9:31 am, Bart Van der Donck <b...@nijlen.co mwrote:
          Thomas 'PointedEars' Lahn wrote:
          bH wrote:
          I have been looking at javascript drawing from this website :
          >
          >http://www.cwdjr.net/geometricDraw/pentagon_draw.h tml"
          and I am wondering why the author made it into two images : upper half
          then lower half?.
          >
          There are no images.  Firebug shows there are but a number of generated 1px
          high HTML `div' elements, a rather stupid design.
          >
          Is there a rule that says you can't do it in one set of calculated values
          for all the points as the points are placed in the document.write(  )?
          >
          There is a rule that says: the right tool for the right purpose.  Theright
          tool here is (standards-compliant) SVG (which is supported well enoughtto
          be used in Wikipedia for all kinds of scalable graphics) or maybe
          (proprietary) Canvas; certainly not plain HTML.
          >
          I would probably prefer a Google Chart that outputs PNG to an <img
          srccall. For example, the requirement of the original poster:
          >
          http://chart.apis.google.com/chart?c...d=t:70,70,70,7...
          >
          Manual:http://code.google.com/apis/chart/
          >
          --
           Bart- Hide quoted text -
          >
          - Show quoted text -
          Hi Bart,
          The demo is really an eye popper. And it was easy to make color
          and size adjustments. For me it was a first time to visit this
          web site.

          Thanks

          bH

          Comment

          • Bart Van der Donck

            #6
            Re: Drawing math shape

            bH wrote:
            On Aug 2, 9:31 am, Bart Van der Donck <b...@nijlen.co mwrote:
            >>
            The demo is really an eye popper. And it was easy to make color
            and size adjustments. For me it was a first time to visit this
            web site.
            Thanks. I think the other equivalents are also quite easy.

            --------------------------------------------------------------------
            pentagon.svg

            --------------------------------------------------------------------
            <?xml version="1.0" standalone="yes "?>
            <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
            "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
            <svg width="400" height="400" style="backgrou nd-color: black"
            xmlns="http://www.w3.org/2000/svg" version="1.1">
            <polygon fill="red" stroke="red" stroke-width="1"
            points="145,15 277,111 227,266 63,266 13,111" />
            </svg>
            --------------------------------------------------------------------

            Problem is that MSIE doesn't know the .svg-extension, so it will offer
            the file for download by default. One could do it in (the immensely
            inpopular) VML, like e.g. Google Maps does.

            --------------------------------------------------------------------
            pentagon.htm for MSIE
            Gain technical skills through documentation and training, earn certifications and connect with the community

            --------------------------------------------------------------------
            <html>
            <head>
            <title>Red Pentagon in VML</title>
            <style>
            v\: * {
            behavior:url(#d efault#VML);
            display:inline-block
            }
            </style>
            </head>
            <body style="backgrou nd-color: black">
            <xml:namespac e ns="urn:schema s-microsoft-com:vml" prefix="v"/>
            <v:polyline strokecolor="re d" strokeweight="1 px" fillcolor="red"
            points="145px,1 5px,277px,111px ,227px,266px,63 px,266px,13px,1 11px"
            />
            </body>
            </html>
            --------------------------------------------------------------------

            Walter Zorn has done investigations how to do it in javascript:
            Slot88 resmi persembahan rrq88 slot merupakan situs link slot gacor hari ini dengan rtp live tertinggi setiap hari.

            Slot88 resmi persembahan rrq88 slot merupakan situs link slot gacor hari ini dengan rtp live tertinggi setiap hari.


            Generally, I think the Google Chart should be the best choice here.

            Cheers

            --
            Bart

            Comment

            • Jorge

              #7
              Re: Drawing math shape

              On Aug 1, 8:19 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
              wrote:
              maybe (proprietary) Canvas;
              As "propietary " as any other w3c open standard can be : <http://
              www.w3.org/TR/html5/the-canvas.html#the-canvas>

              --Jorge.

              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: Drawing math shape

                Bart Van der Donck wrote:
                Walter Zorn has done investigations how to do it in javascript:
                Slot88 resmi persembahan rrq88 slot merupakan situs link slot gacor hari ini dengan rtp live tertinggi setiap hari.

                http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm
                It talks about "canvas", but eventually it is just a more sophisticated
                `div' element nonsense.


                PointedEars
                --
                var bugRiddenCrashP ronePieceOfJunk = (
                navigator.userA gent.indexOf('M SIE 5') != -1
                && navigator.userA gent.indexOf('M ac') != -1
                ) // Plone, register_functi on.js:16

                Comment

                • bH

                  #9
                  Re: Drawing math shape

                  On Aug 3, 10:21 am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
                  wrote:
                  Bart Van der Donck wrote:
                  >
                  Walter Zorn has done investigations how to do it in javascript:
                  Slot88 resmi persembahan rrq88 slot merupakan situs link slot gacor hari ini dengan rtp live tertinggi setiap hari.

                  http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm
                  >
                  It talks about "canvas", but eventually it is just a more sophisticated
                  `div' element nonsense.
                  >
                  PointedEars
                  --
                  var bugRiddenCrashP ronePieceOfJunk = (
                      navigator.userA gent.indexOf('M SIE 5') != -1
                      && navigator.userA gent.indexOf('M ac') != -1
                  )  // Plone, register_functi on.js:16
                  Hi All,
                  Thanks for your efforts to present the "store house of graphic
                  options"
                  I would guess that it would take a while to "discover" those (+,+)and
                  (-,-)
                  of each.

                  bH

                  P.S Bart, up above, you wrote "One could do it in (the immensely
                  inpopular) VML" was that a typo for "unpopular" .
                  if it is, I would like to ask "why is it unpopular?"





                  Comment

                  • slebetman

                    #10
                    Re: Drawing math shape

                    On Aug 2, 2:19 am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
                    wrote:
                    bH wrote:
                    I have been looking at javascript drawing from this website :
                    >
                    http://www.cwdjr.net/geometricDraw/pentagon_draw.h tml"
                    >
                    and I am wondering why the author made it into two images : upper half
                    then lower half?.
                    >
                    There are no images.  Firebug shows there are but a number of generated1px
                    high HTML `div' elements, a rather stupid design.
                    >
                    There is a rule that says: the right tool for the right purpose.  The right
                    tool here is (standards-compliant) SVG (which is supported well enought to
                    be used in Wikipedia for all kinds of scalable graphics)
                    SVG is unfortunately not well supported at all. On IE and Firefox <= 2
                    you'd need the Adobe SVG plugin to see SVG on web pages. Unfortunately
                    that plugin is nowhere near as polished as Adobe's Flash plugin. It
                    crashed both IE and Firefox the last time I tried it and when it works
                    the rendering was buggy for some of my SVG files.

                    For the record, Wikipedia does not *serve* SVG content. They just
                    allow you to upload SVG files which they'll automatically render to
                    PNG on their server. Saying SVG support on the web is good because you
                    can use them on Wikipedia is like saying MS Word doc file support on
                    the web is good because you can use then on Google Docs.

                    Comment

                    • Thomas 'PointedEars' Lahn

                      #11
                      Re: Drawing math shape

                      slebetman wrote:
                      Thomas 'PointedEars' Lahn wrote:
                      >bH wrote:
                      >>I have been looking at javascript drawing from this website :
                      >>http://www.cwdjr.net/geometricDraw/pentagon_draw.h tml" and I am
                      >>wondering why the author made it into two images : upper half then
                      >>lower half?.
                      >There are no images. Firebug shows there are but a number of generated
                      >1px high HTML `div' elements, a rather stupid design.
                      >>
                      >There is a rule that says: the right tool for the right purpose. The
                      >right tool here is (standards-compliant) SVG (which is supported well
                      >enought to be used in Wikipedia for all kinds of scalable graphics)
                      >
                      SVG is unfortunately not well supported at all.
                      IBTD.
                      On IE and Firefox <= 2 you'd need the Adobe SVG plugin to see SVG on web
                      pages.
                      You are correct about IE/MSHTML, but not about Firefox. SVG (and Canvas)
                      is at least partially supported in Firefox since version 1.5 "Deer Park"
                      (released 2005-11-29 CE) which uses Gecko 1.8.
                      Unfortunately that plugin is nowhere near as polished as Adobe's Flash
                      plugin. It crashed both IE and Firefox the last time I tried it and when
                      it works the rendering was buggy for some of my SVG files.
                      I have found it to be quite stable, and it was frequently mentioned as
                      development target here. But one should not install it where there is
                      built-in SVG support as both features would interfere with each other.
                      For the record, Wikipedia does not *serve* SVG content. They just allow
                      you to upload SVG files which they'll automatically render to PNG on
                      their server. [...]
                      Unfortunately, I had observed this to be true earlier today.


                      PointedEars
                      --
                      Anyone who slaps a 'this page is best viewed with Browser X' label on
                      a Web page appears to be yearning for the bad old days, before the Web,
                      when you had very little chance of reading a document written on another
                      computer, another word processor, or another network. -- Tim Berners-Lee

                      Comment

                      • Bart Van der Donck

                        #12
                        Re: Drawing math shape

                        bH wrote:
                        Bart, up above, you wrote "One could do it in (the immensely
                        inpopular) VML"  was that a typo for "unpopular" .
                        if it is, I would like to ask "why is it unpopular?"
                        Yes, that was a typing mistake. I think the following reasons made VML
                        unpopular:

                        - There have always been many alternatives to VML: PGML, SVG, java,
                        javascript, PNG, GIF, JPG, Flash, UML.
                        - VML is proprietary; it only works with MSIE and not "on the web".
                        It's not likely that other browsers will ever adopt VML.
                        - Crappy MS-Office HTML conversions gave a rather bad name to VML,
                        MSXML and the like: tons of illegible code with many errors; and often
                        incompatible even across different versions of Internet Explorer.
                        - There was never a big need for VML; drawing vectors on-the-fly is
                        usually only for very specific applications.
                        - Microsoft does not have a good reputation supporting its current
                        technologies in future software releases.

                        --
                        Bart

                        Comment

                        • Thomas 'PointedEars' Lahn

                          #13
                          Re: Drawing math shape

                          Jorge wrote:
                          On Aug 1, 8:19 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
                          wrote:
                          >maybe (proprietary) Canvas;
                          >
                          As "propietary " as any other w3c open standard can be : <http://
                          www.w3.org/TR/html5/the-canvas.html#the-canvas>
                          | Status of this document
                          |
                          | This section describes the status of this document at the time of
                          | its publication. Other documents may supersede this document. [...]
                          |
                          | Implementors should be aware that this specification is not stable.
                          | Implementors who are not taking part in the discussions are likely
                          | to find the specification changing out from under them in
                          | incompatible ways. Vendors interested in implementing this
                          | specification before it eventually reaches the
                          | Candidate Recommendation stage should join the aforementioned
                          | mailing lists and take part in the discussions.
                          |
                          | The publication of this document by the W3C as a W3C Working Draft
                          | does not imply that all of the participants in the W3C HTML working
                          | group endorse the contents of the specification. Indeed, for any
                          | section of the specification, one can usually find many members of
                          | the working group or of the W3C as a whole who object strongly to
                          | the current text, the existence of the section at all, or the idea
                          | that the working group should even spend time discussing the concept
                          | of that section.

                          Probably someone has told you about that before.


                          PointedEars
                          --
                          realism: HTML 4.01 Strict
                          evangelism: XHTML 1.0 Strict
                          madness: XHTML 1.1 as application/xhtml+xml
                          -- Bjoern Hoehrmann

                          Comment

                          • Henry

                            #14
                            Re: Drawing math shape

                            On Aug 4, 5:18 pm, Thomas 'PointedEars' Lahn wrote:
                            <snip>
                            >| ... , for any section of the specification, one can usually
                            >| find many members of the working group or of the W3C as a
                            >| whole who object strongly to the current text, the existence
                            >| of the section at all, or the idea that the working group
                            >| should even spend time discussing the concept of that section.
                            <snip>

                            With a disclaimer like that it sounds like a fair percentage of the
                            W3C don't want to see this ever getting to the status of being a
                            recommendation.

                            Comment

                            • Jorge

                              #15
                              Re: Drawing math shape

                              On Aug 4, 7:04 pm, Henry <rcornf...@rain drop.co.ukwrote :
                              On Aug 4, 5:18 pm, Thomas 'PointedEars' Lahn wrote:
                              <snip>>| ... , for any section of the specification, one can usually
                              | find many members of the working group or of the W3C as a
                              | whole who object strongly to the current text, the existence
                              | of the section at all, or the idea that the working group
                              | should even spend time discussing the concept of that section.
                              >
                              <snip>
                              >
                              With a disclaimer like that it sounds like a fair percentage of the
                              W3C don't want to see this ever getting to the status of being a
                              recommendation.
                              Don't you know what's been going on between the W3C and the WHATWG ?



                              --Jorge.

                              Comment

                              Working...