TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SVG has more potential

428 点作者 kp25超过 8 年前

25 条评论

c-smile超过 8 年前
SVG is too complex&#x2F;heavy for simple tasks and actually is not that good for complex tasks - more or less complex image requires special editing WYSIWYG application to create it.<p>Let&#x27;s imagine that you need to render simple icon using CSS that should change color on :hover:<p><pre><code> div.icon { background: url(simple.svg) no-repeat; background-size: 1em 1em; } div.icon:hover { ??? what to do here to change the color ??? } </code></pre> Just to render this thing you will need: to download the file, parse SVG, build DOM tree and &quot;play&quot; that DOM tree on canvas. Each task is not trivial.<p>While ago I&#x27;ve proposed at w3c-styles simple and lightweight solution for vector images and shapes in CSS - so called path URLs:<p><pre><code> div.icon { background: url(path:c 50,0 50,100 100,100 c 50,0 50,-100 100,-100) no-repeat; background-size: 1em 1em; stroke: #000; &#x2F;* vector stroke color *&#x2F; } div.icon:hover { stroke: #F00; } </code></pre> The path uses the same format as &quot;d&quot; attribute in SVG&#x27;s &lt;path&gt; element:<p><pre><code> &lt;path d=&quot;c 50,0 50,100 100,100 c 50,0 50,-100 100,-100&quot; fill=&quot;#000&quot; &#x2F;&gt; </code></pre> Parsing is trivial and rendering of such &quot;images&quot; is just a set of primitive drawing operations. No DOM or anything like that.<p>More on the subject (with illustrations in Sciter) : <a href="http:&#x2F;&#x2F;sciter.com&#x2F;lightweight-inline-vector-images-in-sciter&#x2F;" rel="nofollow">http:&#x2F;&#x2F;sciter.com&#x2F;lightweight-inline-vector-images-in-sciter...</a>
评论 #12588438 未加载
评论 #12588155 未加载
评论 #12589812 未加载
评论 #12588390 未加载
ptrincr超过 8 年前
Look no further than D3.js as an example of the kind of visualisations which are possible with SVG.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;d3&#x2F;d3&#x2F;wiki&#x2F;Gallery" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;d3&#x2F;d3&#x2F;wiki&#x2F;Gallery</a><p>At least this is what introduced me to working with SVG. As much as I like D3, mainly for charting, it&#x27;s not the easiest thing to pick up.
评论 #12585223 未加载
评论 #12584743 未加载
igt0超过 8 年前
SVG is amazing, my main concern about it. it is because it creates a huge burden to browser developers. The spec is <i>huge</i> [1]. And some parts are outdated[2].<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;WebKit&#x2F;webkit&#x2F;tree&#x2F;master&#x2F;Source&#x2F;WebCore&#x2F;svg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;WebKit&#x2F;webkit&#x2F;tree&#x2F;master&#x2F;Source&#x2F;WebCore&#x2F;...</a> [2] <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;SVG&#x2F;SVG_animation_with_SMIL" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;SVG&#x2F;SVG_animati...</a>
评论 #12585031 未加载
评论 #12585435 未加载
formula1超过 8 年前
I am using svgs in a project now.<p>- The first issue was the designer Im working with didnt know how to export to svg.<p>- Second problem is my svgs ended up with very weird numbers and groups. Such as the main groups offset was -60, 190 then another group to dlightly compensate. Then the paths themselves compensated further.<p>- Another issue is &quot;cutouts&quot; are nonintuitive for designers and also complex to reverse when they are curves.<p>- Another issue is linking and styling to an external svg. Despite you can put them in an image tag, it cannot be styled this way. If you put it inside a use tag, styling externally requires targeting ids.<p>- anothwr issue is that they dont follow the normal rules of width&#x2F;height. By default they are 300x150 and takes a bit of patience to ensure they exist as 100% width (which I assumed was default)<p>Other than that, I am quite pleased with the format and am expecting great things for it!
评论 #12586916 未加载
评论 #12585094 未加载
CiPHPerCoder超过 8 年前
SVG also has more risk: stored XSS, which isn&#x27;t something you&#x27;d expect from a file whose MIME type starts with &quot;image&#x2F;&quot;.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;w3c&#x2F;svgwg&#x2F;issues&#x2F;266" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;w3c&#x2F;svgwg&#x2F;issues&#x2F;266</a>
评论 #12584589 未加载
评论 #12585015 未加载
Pxtl超过 8 年前
When I first heard about svg, I was excited. Finally everybody getting behind a vector graphics format... and since then the more I see the worse it looks. A boosted, text-oriented, JavaScript-enhanced resource monster. All the worst attributes of HTML, but in vector graphics.<p>Did anybody want this? I know I wanted a jpg of vector graphics - a resource-friendly small system for embedding vector graphics into things. Something where I don&#x27;t have to worry about an image having an xss vulnerability. Something that degrades gracefully so it can still work in some form on an anemic piece of equipment.<p>But no. We throw bigger and heavier hardware at more trivial problems.
评论 #12587129 未加载
评论 #12587334 未加载
评论 #12587211 未加载
评论 #12587241 未加载
评论 #12587063 未加载
Animats超过 8 年前
SVG as a representation language for draw programs is pretty good. Most draw programs don&#x27;t utilize it fully. While SVG can represent dimensions as inches or mm, most programs only support dimensions as pixels, which makes SVG useless for CAD drawings.<p>If you need drawings with lines and boxes, Inkscape is very helpful. Most drawings in Wikipedia are in SVG, and many were drawn with Inkscape. You can update drawings in Wikipedia by bringing them into Inkscape and editing them, then checking them back in as an update. It&#x27;s not a read-only notation, like Postscript.<p>Manually tweaking SVG text, though? Painful. It&#x27;s encapsulated like XML, so you can, but you probably shouldn&#x27;t. After you&#x27;ve done that, most draw programs won&#x27;t be able to handle the fancy stuff. And really, drawing by typing text is like pounding a screw with a hammer.
评论 #12584900 未加载
contingencies超过 8 年前
Timing! I just pulled a 4AM night last night creating my first ever Lua library, <i>svglover</i>[0], to facilitate SVG display in LÖVE[1], for a roguelike. Motivation was primitive[2] posted[3] last week. It&#x27;s actually pretty easy to work with, even for lazy coders who find regex parsing acceptable like me[4] :) I&#x27;m no oldschool demo coder, but the coordinate transformation system is basically just a simple layer on top of an OpenGL pipeline. You don&#x27;t even need viewbox, just groups with &lt;g&gt;&lt;&#x2F;g&gt;<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;globalcitizen&#x2F;svglover" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;globalcitizen&#x2F;svglover</a> [1] <a href="http:&#x2F;&#x2F;love2d.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;love2d.org&#x2F;</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;fogleman&#x2F;primitive" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fogleman&#x2F;primitive</a> [3] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12539109" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12539109</a> [4] <i>Make it work first, then make it work fast</i>.
niedzielski超过 8 年前
Gordon Lee[0] has made a ton of sophisticated SVGs for Wikipedia and its projects and recently presented at Wikimania. The Burj Khalifa[1] is one of my favorites. Inspired, I wrote this short script for fun that chops up a Blender file into PNGs[2] which I used to generate an animated SVG.<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;User:Cmglee" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;User:Cmglee</a> [1] <a href="https:&#x2F;&#x2F;upload.wikimedia.org&#x2F;wikipedia&#x2F;commons&#x2F;0&#x2F;06&#x2F;Burj_Khalifa_floors.svg" rel="nofollow">https:&#x2F;&#x2F;upload.wikimedia.org&#x2F;wikipedia&#x2F;commons&#x2F;0&#x2F;06&#x2F;Burj_Kha...</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;rndmem&#x2F;ndice&#x2F;blob&#x2F;master&#x2F;blend&#x2F;d&#x2F;render" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rndmem&#x2F;ndice&#x2F;blob&#x2F;master&#x2F;blend&#x2F;d&#x2F;render</a>
iamleppert超过 8 年前
SVG works for the trivial graphics use cases that are presented. But it falls apart for anything that requires more complexity, or dealing with documents of arbitrary complexity.<p>There is little provision for incremental rendering, and poor control and visibility of the internals of the rendering process. Once you dump your SVG to the browser, that&#x27;s basically it. There&#x27;s no way to find out what is going on.<p>It&#x27;s really nice to just set a break point in your imperative Canvas code, or WebGL code and see exactly what is happening, and use all the standard debugging and profiling techniques. I have yet to see the same for SVG.
评论 #12586850 未加载
edejong超过 8 年前
Three years ago I was amazed by the versatility of SVG when I discovered it through D3 and it inspired our graphical designer to ask us designs never before seen in SaaS applications. Once you&#x27;re willing to dive into the specifications, you&#x27;ll find a treasure trove of possibilities.<p>There are some caveats beginning users should be aware of. First of all, better forget multi line text or sophisticated text layout within the SVG. I still think that&#x27;s really missing in the current specification. As a commute project I once wrote the dynamic programming layout of Knuth (used in TeX) for SVG and JavaScript, but it was slow and didn&#x27;t allow for multi line selections.<p>Another problem is rendering speed. SVG renderers can be fast, but you have to know what can be optimized by the gpu and what requires the CPU.
评论 #12586206 未加载
评论 #12584759 未加载
thom超过 8 年前
Annoyances with SVG:<p>- Modularity is tough: you can nest &lt;svg&gt; or &lt;g&gt; elements with various transforms, but there&#x27;s no first class layout concept.<p>- Pixel imperfections: browsers don&#x27;t always render things &#x27;nicely&#x27;, and all sorts of horrid aliasing can happen.<p>- Styling options: all sorts of simple stuff like a double outline of a shape is really difficult (without extremely complex filters)<p>- Export: taking an SVG and exporting it as an image has lots of complications, especially with embedded fonts.<p>All that said, the output is mostly okay, and it&#x27;s possibly the easiest graphical technology to integrate with React-style frameworks.
评论 #12587365 未加载
评论 #12585754 未加载
amelius超过 8 年前
I&#x27;m wondering if it would be possible to parameterize SVG files. Suppose I have an icon in the file &quot;icon.svg&quot;, it would be awesome if I could say in the CSS:<p><pre><code> .icon:hover { background-image: url(&quot;.&#x2F;icon.svg&quot;) main-color=#ff0000; } </code></pre> where &quot;main-color&quot; is a parameter of the SVG file. So the icon turns red upon hovering (just an example).<p>Is something like this possible?
评论 #12585019 未加载
评论 #12585061 未加载
评论 #12585710 未加载
shurcooL超过 8 年前
I really like SVG and this was a great article that contained many things I didn&#x27;t know.<p>That said, I _tried_ to use SVG for something as simple as displaying some multiline monospaced text with whitespace preserved, and found it&#x27;s either really hard, or actually not possible (unless you position each glyph manually). Is that really the case?
评论 #12587458 未加载
mojuba超过 8 年前
SVG has another interesting application: it can be used as a UI language for graphically rich and complex interfaces, almost game-like but not quite. You often see this kind of interfaces in audio, i.e. soft synths&#x2F;effects. Though you will need to create your own extension to the markup and a subsystem that supports it in your OS, which in the end is not too complicated.<p>(Shameless self-plug as an example of an SVG-based GUI: <a href="https:&#x2F;&#x2F;itunes.apple.com&#x2F;us&#x2F;app&#x2F;magnetola-vintage-cassette&#x2F;id1027234156" rel="nofollow">https:&#x2F;&#x2F;itunes.apple.com&#x2F;us&#x2F;app&#x2F;magnetola-vintage-cassette&#x2F;i...</a>)
tofflos超过 8 年前
I&#x27;d use it a bit more if I could style it with CSS without inlining the SVG source code within my HTML.
评论 #12585329 未加载
评论 #12585879 未加载
robszumski超过 8 年前
As a designer using SVGs across the web, there are a few drawbacks that are easy to fix:<p>- platforms like Twitter and Google Slides not accepting SVGs. I assume this is due to security concerns.<p>- Using SVGs on a website doesn&#x27;t render with included WebFonts like normal text would. This leads to outlining text, which is a huge maintainability burden.<p>- Graphics programs have tones of SVG bugs. Even &quot;leading&quot; software like Illustrator and Sketch have a lot of bumps in the road.<p>Overall really excited about SVGs and use them as much as possible.
xnmvvv超过 8 年前
The main problems I&#x27;ve experienced:<p>* SVG&#x27;s performance degrades sharply after a few hundred objects, then you have to use canvas or WebGL, or prerender to images * browser differences<p>otherwise good
Hyperized超过 8 年前
We use SVG extensively at: <a href="https:&#x2F;&#x2F;fd.nl&#x2F;krant" rel="nofollow">https:&#x2F;&#x2F;fd.nl&#x2F;krant</a>
flatline超过 8 年前
Generally I agree that SVG is awesome, but there are a variety of cross-platform issues with it and I worry it does not get enough serious use to see them addressed. The status quo is pretty good, but if you run into issues there is not always a work around.
dahart超过 8 年前
I&#x27;m quite excited for SVG absolute positioning to become available in all browsers. It&#x27;ll mean real responsive images, not just resizing, being able to move parts of the SVG instead of scaling proportionally, as the image is resized.
wrong_variable超过 8 年前
The issue that makes me not enjoy working with svg is the lack of negative scaling values. It makes it hard to do complex transformations on your vector widgets. Canvas is so much more better.
评论 #12584588 未加载
评论 #12585888 未加载
bradoyler超过 8 年前
This is why d3-node is the way to go... <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;d3-node" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;d3-node</a>
aikah超过 8 年前
The second example is supported neither in Edge nor in Firefox, that&#x27;s the problem. Extremely poor SVG support accross browsers.
评论 #12587297 未加载
SFJulie超过 8 年前
SVG? Wasn&#x27;it the new tech (10 Years after ARM) in 2000 that was supposed to be so wonderful it would be very easily adopted?<p>We are in 2016 ... ARM are still promising and SVG is still the new promising thing. Well, SVG has not taken a wrinkle, nor grown up a lot. It is still overpromising and complex.<p>Let me watch my backyard cristal balls for new innovations..<p>DCOM and RPC maybe? Oh, crumbs, it is called the cloud. All FW problems solved by using HTTP with cookies that are so safe.<p>I can&#x27;t wait for the next new thing... GUI, Universal Display format (aka display postscript from NeXT), Xanadoo, XUL, sprites, linear framebuffers with blitters?