praneybehl / jgraduate

Automatically exported from code.google.com/p/jgraduate
MIT License
0 stars 0 forks source link

jGraduate should create SVG document for div that launches it if required #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Having to include a small SVG document for the div that will launch
jGraduate to represent the paint is painful for the user of jGraduate.  It
would be nice if this could be done automatically from jGraduate upon first
call:

- if <div id="foo"> does not contain a <svg> node, then jGraduate will
create one and append it to the div:

  <svg id="foo_svg" xmlns="http://www.w3.org/2000/svg">
    <linearGradient id="foo_lg">
      <stop offset="0"/>
      <stop offset="1"/>
    </linearGradient>
    <rect width="100%" height="100%" fill="#rrggbb"/>
  </svg>

where #rrggbb is the background-color of the div#foo.

- if the div DOES have a <svg> node, get a reference to its linearGradient
and rect elements

The second part of this defect is that jGraduate itself should manage the
gradient and the rect's fill when ok is clicked so that the test page does
not have to.  jGraduate must still return a separate gradient node that can
be imported into the DOM.

This will reduce the test demo pages to very little code (unless the caller
needs to set up a gradient in the div before jGraduate is first called).

Original issue reported on code.google.com by codedr...@gmail.com on 23 Jul 2009 at 4:47

GoogleCodeExporter commented 9 years ago
It also occurred to me that jGraduate can do something similar to what jPicker 
does:
 Provide a convenience method that can be called beforehand to set up the div. 
Something like:

jGraduate_setPaintLG(div, {x1, y1, x2, y2, beginColor, beginOpacity, endColor,
endOpacity})

This method will return a <svg> document that is ready to be inserted into the 
<div>.

So:

1) if user does not need a gradient to be shown in the div prior to launching
jGraduate, then simply set background-color and call jGraduate().  In this case,
jGraduate will handle creating the SVG document and managing it.

2) if user wants a gradient to be shown in the div prior to launching 
jGraduate, then
call jGraduate_setPaintLG($('div#foo'), {...} ) and then call jGraduate().

Original comment by codedr...@gmail.com on 23 Jul 2009 at 4:51

GoogleCodeExporter commented 9 years ago

Original comment by codedr...@gmail.com on 23 Jul 2009 at 4:54

GoogleCodeExporter commented 9 years ago
I've decided that this is a lot of work for some minor convenience.  It's 
better to
just illustrate how developers would do this in the example demo/test page.

Original comment by codedr...@gmail.com on 27 Jul 2009 at 4:26

GoogleCodeExporter commented 9 years ago

Original comment by codedr...@gmail.com on 10 Aug 2009 at 2:11