Comments (29)
ColourMap would be a good idea.
Perhaps adding function to change saturation or tinting if it's possible.
Original comment by [email protected]
on 19 Jul 2013 at 10:20
from androidsvg.
I was wondering if it would make sense to use the id value.
so for instance if you give a <path> element an id, say id="Element1" then you
can use that to update various attributes, for example fill.
i.e. SVG.updateFillByID (String id, newColour);
I'm looking at the source code and seeing if I can implement something myself.
although I'm not a very good coder.
Original comment by [email protected]
on 20 Aug 2013 at 7:00
from androidsvg.
When I implement this feature, I probably will add the ability to restrict the
changes to a portion of the document. Probably by id or class.
I wouldn't want to implement osoto's suggestion exactly as described though.
If I implement the ability to modify the attributes and style of elements, I
would want to do it in a more standard way and implement partial support for
the SVG DOM.
So osoto's example would be more like:
svg.getElementById(id).getStyle().setProperty("fill", newColour);
Implementing DOM support would be quite a big job though, as it would require a
fair amount of refactoring of the code.
Original comment by [email protected]
on 20 Aug 2013 at 9:22
from androidsvg.
Yeah, totally makes sense.
I had a look at the code, and I see your point about needing to refactor to get
a nice clean solution implemented.
I might do some dirty hacks to suit my needs, which I'll of course be happy to
share, although they will probably not be good enough to go into the main
branch. If I get more comfortable with the code, I might do something cleaner
as well.
btw, thanks a lot for the library and your continued support. It's really
appreciated!
Original comment by [email protected]
on 20 Aug 2013 at 12:05
from androidsvg.
Why not "simply" allow to add CSS stylesheet?
With two modes, "standard" mode (overridden by tag's attributes) and an
"override mode" (which is applied after and override even tag's attributes),
most of the code is already there and it's more versatile.
Original comment by [email protected]
on 31 Aug 2013 at 1:53
from androidsvg.
Overriding styles via CSS makes sense. It's a bit more work for the developer
using the library but is a much more "standard" and flexible way of doing
things. You would be able to adjust other style properties and not just
colours.
Although I am not sure about your first mode ("standard"). It goes against the
rules on the order that styles are applied (1. attributes, 2. CSS, 3. "style"
attribute)
Original comment by [email protected]
on 31 Aug 2013 at 3:39
from androidsvg.
In the following example, if I want to make it red, a 4th rule should be added,
otherwise, the rect will be green.
SVG:
<rect x="50" y="50" width="100" height="100" style="fill:green" fill="pink"/>
CSS:
rect {
fill: red;
}
1. attributes
2. CSS
3. "style" attribute
4. CSS override (not standard) so you can override the green to red in the
example
Original comment by [email protected]
on 1 Sep 2013 at 11:54
from androidsvg.
I don't see that situation as a particular problem. If you are using this
feature, you wouldn't, or shouldn't use the style attribute.
Original comment by [email protected]
on 1 Sep 2013 at 1:36
from androidsvg.
[deleted comment]
from androidsvg.
I m looking forward to DOM support for getting specific elements, but i saw
your source code implementing the svg parser by SAX.
What's your intention to achieve this
"svg.getElementById(id).getStyle().setProperty("fill", newColour);"? Change the
parsing to "org.w3c.dom" or implement the dom-like cache by SAX?
For now, the library parse the SVG file as a whole, i guess using "org.w3c.dom"
is a viable method
Original comment by [email protected]
on 14 Nov 2013 at 8:02
from androidsvg.
I don't know yet. I haven't thought about that subject enough yet to make a
decision.
At the moment I parse into an object tree that is not very DOM-like. The most
likely approach would be to change that to one that is.
Original comment by [email protected]
on 14 Nov 2013 at 8:02
from androidsvg.
Parsing the whole file into a tree is necessary to properly render documents.
So that wouldn't change.
Original comment by [email protected]
on 14 Nov 2013 at 8:04
from androidsvg.
[deleted comment]
from androidsvg.
Any news on this?
Original comment by [email protected]
on 7 Aug 2014 at 7:47
from androidsvg.
This would be a cool feature! Is there anything I can test?
Original comment by [email protected]
on 17 Aug 2014 at 7:04
from androidsvg.
[deleted comment]
from androidsvg.
Sorry for the lack of progress on this feature everyone. I have just been very
busy with my day job. Rest assured it has a high priority.
Original comment by [email protected]
on 22 Sep 2014 at 2:55
from androidsvg.
[deleted comment]
from androidsvg.
[deleted comment]
from androidsvg.
Thanks for your effort. :)
I am tracing the source code and already found a private method
getElementById() :)
I also want to add a method public Array<SVGElement> getElementsByClass(String
class)
(Class is many-to-many. One element can hv multiple classes, seperated by
space; and multiple elements can comply to one class)
To Implement that, maybe a Map<String, Array<SVGElement>> is enough, and the
implementation should be similar to your getElementById().
And if you allow ppl to get elements by anything, all your non-abstract
protected classes should turn public
Original comment by [email protected]
on 24 Sep 2014 at 4:26
from androidsvg.
https://code.google.com/r/wonson-androidsvg-2/source/browse/src/com/caverock/and
roidsvg/SVG.java
This is my clone
Original comment by [email protected]
on 24 Sep 2014 at 5:04
from androidsvg.
[deleted comment]
from androidsvg.
[deleted comment]
from androidsvg.
[deleted comment]
from androidsvg.
If allow us to change color, save and restore state, and reset to original is
needed. Maybe need to be Serializable with ByteArrayInputStream and
ByteArrayOutputStream.
Original comment by [email protected]
on 8 Oct 2014 at 8:04
from androidsvg.
https://github.com/wonson/androidsvg
My patched androidsvg with ability to change attributes and serialization for
push and pop(save and restore)
Original comment by [email protected]
on 7 Nov 2014 at 8:29
from androidsvg.
Btw wonson we noticed that this function was missing an addAll in the recursive
call in your getElementsByTagName.
The fixed function is posted below:
public List<SvgObject> getElementsByTagName(SvgContainer obj, Class clazz)
{
List<SvgObject> result = new ArrayList<SvgObject>();
if (obj.getClass() == clazz)
result.add((SvgObject) obj);
for (SvgObject child: obj.getChildren())
{
if (child.getClass() == clazz)
result.add(child);
if (child instanceof SvgContainer)
result.addAll(getElementsByTagName((SvgContainer) child, clazz));//append result of recursive call to result
}
return result;
}
Original comment by [email protected]
on 5 Feb 2015 at 9:26
from androidsvg.
Thanks :D
Original comment by [email protected]
on 6 Feb 2015 at 2:14
from androidsvg.
The following patch may be of use to people until I get some free time to work
on a new release.
It is by Gerrit van Niekerk and adds the ability to set a ColorFilter when
rendering.
Original comment by [email protected]
on 8 Apr 2015 at 1:13
Attachments:
from androidsvg.
Related Issues (20)
- SVGAndroidRenderer.processMaskBitmaps is very slow HOT 1
- SVGParser is not thread-safe [with fix] (SVG parse error: Invalid colour keyword: white) HOT 2
- Feature request: replace text HOT 6
- FAQ promotes extremely bad backward-compatibility practice HOT 6
- Image references missing SVG support. HOT 3
- Canvas changed after renderToCanvas HOT 1
- Position of Rectf ignored when renderToCanvas HOT 1
- Support for hardware acceleration
- Android version support HOT 1
- Android version support HOT 1
- Pattern fills are rendered with visible grid HOT 4
- Provide copy constructor or allow rendering to multiple viewBox at once HOT 3
- migrate the repository HOT 3
- Move project to Github HOT 1
- NullPointerException in 1.2.2-beta1 when parsing SVG document HOT 4
- SVGImageView crashes on Android 5.0 and higher HOT 5
- Proguard breaks reflective CSS selectors HOT 1
- java.lang.ArrayIndexOutOfBoundsException: length=0; index=-2 in SVGAndroidRenderer.arcTo(SourceFile:2572) HOT 1
- Incorrect rendering of SVG image HOT 5
- Unable to execute dex: Multiple dex files define HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidsvg.