惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
C
Cisco Blogs
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Scott Helme
Scott Helme
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
M
MIT News - Artificial intelligence
L
LINUX DO - 热门话题
I
InfoQ
GbyAI
GbyAI
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More
TaoSecurity Blog
TaoSecurity Blog
Simon Willison's Weblog
Simon Willison's Weblog
A
About on SuperTechFans
Spread Privacy
Spread Privacy
月光博客
月光博客
W
WeLiveSecurity
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
有赞技术团队
有赞技术团队
Security Latest
Security Latest
人人都是产品经理
人人都是产品经理
PCI Perspectives
PCI Perspectives
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
T
Troy Hunt's Blog
Martin Fowler
Martin Fowler
The Hacker News
The Hacker News
T
Tor Project blog
C
CERT Recently Published Vulnerability Notes
Apple Machine Learning Research
Apple Machine Learning Research
Stack Overflow Blog
Stack Overflow Blog
K
Kaspersky official blog
Cloudbric
Cloudbric
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
D
DataBreaches.Net
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tenable Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - Franky
L
LINUX DO - 最新话题
MyScale Blog
MyScale Blog

博客园 - 小兔快跑

实现线程中的参数传递 利用rank() 和 dense_rank() 来实现分类排名 利用Relations实现多DataTable的聚合 Web应用中实现发送带附件的电子邮件 为什么这样的SQL会锁记录? 在Word里实现禁止复制和选定 [VS2005]解决“由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题” Word转pdf方法小结 原来数据库编程也可以这么美好! ASP.NET生成WORD文档服务器部署注意事项 ASP.NET:页面保存为WORD出现的问题! 动态绑定图片url:数据绑定出现的问题 .NET对Excel的读写 .NET中的CString知识点 水滴石穿之页面遮罩层实现、向window.open()打开的窗口POST数据 动态加载和使用类型 WinForm 控件的事件委托剖析 如何:使用反射将委托挂钩 水滴石穿之子页面的滚动条设置 表格的固定高度宽度问题 复制带格式的文本
SVG常见问题汇总
小兔快跑 · 2007-11-13 · via 博客园 - 小兔快跑

1. SVG背景透明的解决办法
  IE中,完全可以支持SVG透明。
  条件:使用<embed>标签 (自己测试的,其他标签未知)
  Tip: Internet Explorer supports an additional attribute, wmode="transparent", that let the HTML page background shine through.
  tip:ie浏览器支持一个附加的属性,wmode="transparent",用来使html背景透明。
      -------来自W3C Schools SVG教程。
      <embed src="rect.svg" width="300" height="100" type="image/svg+xml" wmode="transparent" />
2.SVG中文显示
  首先要注意的是字体问题
  要在svgviewer中显示中文字体,需要将中文字体名称进行“国际化”,即将汉字字体名称改为英文名称,
  如将“宋体”改为“Simsun",“黑体”改为"Simhei"等,下面是部分字体对照列表: 
  English Name    Localized Name  
  SimSun                宋体  
  SimHei                黑体  
  FangSong_GB2312       仿宋_GB2312  
  KaiTi_GB2312      楷体_GB2312  
  YouYuan       幼圆  
  STSong       华文宋体  
  STZhongsong      华文中宋  
  STKaiti    华文楷体  
  STFangsong   华文仿宋  
  STXihei    华文细黑  
  STLiti    华文隶书  
  STXingkai    华文行楷  
  STXinwei    华文新魏  
  STHupo    华文琥珀  
  STCaiyun    华文彩云  
  FZYaoTi    方正姚体简体  
  FZShuTi    方正舒体简体  
  NSimSun    新宋体  
  LiSu     隶书
  其次要注意文件编码问题:将svg文件保存的时候要选择utf-8编码或者unicode编码,当然svg文件的encoding属性也应该是"utf-8"
3.判断鼠标事件来源
  
在SVG中会经常遇到判断鼠标事件来源的问题,比如:鼠标单击或者双击、滚轮事件等等。这里做一个简单的介绍。
  判断鼠标是左键还是右键?
      在onclick事件中,if(evt.button==0)则为左击,否则为右击
      无论单击还是双击evt.detail==1
      判断鼠标是单击还是双击?
      在onclick事件中,if(evt.detail==2)则为双击,否则为单击
      判断鼠标的滚轮事件?

function mousewheel()
{
   origscale
=root.currentScale;
   origscale 
+=event.wheelDelta / 1200;
   
if (origscale > 0)
   
{
      root.currentScale
=origscale;
      root.currentTranslate.x
=midx*root.currentScale+event.offsetX*(1-root.currentScale/midscale);
   root.currentTranslate.y
=midy*root.currentScale+event.offsetY*(1-root.currentScale/midscale); 

   midscale
=root.currentScale;
   midx
=root.currentTranslate.x/root.currentScale;
   midy
=root.currentTranslate.y/root.currentScale; 
   }

}

4. SVG自适应高度和宽度

<?xml version="1.0" encoding="UTF-8"?>
<?AdobeSVGViewer resolution="1200" save="snapshot"?>
<svg id="tstSVG" viewBox= "0 0 1000 1000" preserveAspectRatio= "xMidYMid meet" xmlns:xlink="http://www.w3.org/1999/xlink";>
<script>
try
{
var oParentWin= (window.parent)?(window.parent):(window.__parent__);
var oParentBody= oParentWin.document.body;
var oSVG= null;
var fZoom= 1.0;
function onResize(event)
{
         try
         {
  if (!oSVG)
  {
   window.focus();// 
   make sure oSVG= oParentWin.document.activeElement;                                   
   oParentBody.style.overflow= "auto";
                        setTimeout("oSVG=oParentWin.document.activeElement;onResize(null);", 250);
                }
  else
  {
  //((oSVG.tagName=="EMBED"))
   try
   {
    if (!event)
     return false;
    switch((event.type)?(event.type):(""))
    {
     case "mousewheel":
     {
      var actDefaultAntialias= window.getDefaultAntialias();                                                          
      if(actDefaultAntialias)
       setDefaultAntialias(false);
      if(isNaN(fZoom))
       fZoom= 1.0;
      var fInc= (event.wheelDelta >= 120)?(.1):(-.1);
      fZoom= (fZoom>1)?(Math.floor(fZoom+fInc*10)):(fZoom+fInc);
      fZoom= Math.max(.1, Math.min(10., fZoom));
      oSVG.style.zoom= fZoom;
      oSVG.height= oParentBody.clientHeight;
      oSVG.width=  oParentBody.clientWidth;
      if(actDefaultAntialias)
       setTimeout("window.setDefaultAntialias("+actDefaultAntialias+")", 1000);
      oParentWin.status= "Zoom: " + oSVG.style.zoom;
     }
     break;
     default:
     {
      oSVG.style.posHeight = oParentBody.clientHeight;
      oSVG.style.posWidth= oParentBody.clientWidth;
      oParentWin.status= ("Resized: [" + oParentBody.clientHeight + "x" + oParentBody.clientWidth + "]");
     }
    }//switch(evt.type)
   }
   catch(e)
   { 
    alert(e.description);
   }
  }
 }
 catch(e)
 {
  alert(e.description);
 }
}
{
oParentWin.attachEvent("onresize",onResize);
oParentWin.attachEvent("onbeforeprint", onResize);
oParentWin.document.attachEvent("onmousewheel", onResize);
};
}
catch(e)
{
 alert(e.description);
}
</script>
<style type="text/css">
<![CDATA[
@media print 
{
}
]]>
</style>
<g  style="fill:red; stroke:navy;">
 
<circle cx="500" cy="500" r="100" style="fill:gold;"/>
        
<path d="M0,495 l1000,0 l0,10 l-1000,0 z" />
        
<path d="M495,0 l10,0 l0,1000 l-10,0 z" />
</g>
</svg>