• <menu id="w2i4a"></menu>
  • logo VectorDraw Developer Framework使用教程

    文檔首頁(yè)>>VectorDraw Developer Framework使用教程>>VDF常見(jiàn)問(wèn)題整理(十三):透明度如何在VDF中運(yùn)行?

    VDF常見(jiàn)問(wèn)題整理(十三):透明度如何在VDF中運(yùn)行?


    VectorDraw Developer Framework(VDF)是一個(gè)用于應(yīng)用程序可視化的圖形引擎庫(kù)。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。

    VectorDraw Developer Framework試用版下載


    問(wèn):

    透明度如何在VDF中發(fā)揮作用?

    答:

    在版本6023中,我們?yōu)関dFigure對(duì)象添加了一個(gè)名為TransparencyMethod的新屬性。此屬性從vdFigure.TransparencyMethodEnum獲取值,如下所示:

    TransparencyMethodEnum.ByLayer 該對(duì)象采用透明度(AlphaBlending值)的顏色為圖層pencolor AlphaBlending。
    TransparencyMethodEnum.ByBlock 該對(duì)象獲取所有者的顏色透明度(AlphaBlending值)。所有者是一個(gè)帶有AlphaBlending筆顏的vdInsert。
    TransparencyMethodEnum.Default默認(rèn)值 如果對(duì)象是真彩色,則對(duì)象將獲得自己的透明度值。如果筆觸是索引,則使用調(diào)色板的顏色透明度值。
    TransparencyMethodEnum.KeepOwn 該對(duì)象總是采用它自己的pencolor透明度(AlphaBlending值)。

    除此屬性外,還有Solid2dTransparency屬性,該屬性僅應(yīng)用于陰影線/填充對(duì)象,并且僅應(yīng)用于2D(線)模式,而不應(yīng)用于3D(Wire3d / Shade / Hide / ShadeOn / Render)模式。因此,如果您希望填充的對(duì)象僅在2D而不是3D中透明,則可以使用此屬性。

    另一方面,如果您希望對(duì)象在3D和2D模式下透明,則需要使用TransparencyMethod屬性并將AlphaBlending值設(shè)置為vdFigure (KeepOwn,Default)或vdLayer(ByLayer)或parent(vdBlock)。AlphaBlending將值從0(完全透明,如不可見(jiàn))取值到255(根本不透明)。

    本方法適用于版本6.6023.x及更高版本,因?yàn)橐郧暗?023版本中不存在用于vdFigure的TransparencyMethod。

    下面的代碼將向您演示對(duì)象的透明度如何在VDF中工作:

       public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            
            vdDocument doc;
            private void Form1_Load(object sender, EventArgs e)
            {
                doc = vdFramedControl1.BaseControl.ActiveDocument;
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //Transparency of vdCurves (line, polyline etc).
                // For better display of this transparency a thicker line type is used in the code
                doc.New();
    
                vdRect rect = new vdRect(doc, new gPoint(0, 0, -0.1), 10, 2, 0);
                rect.HatchProperties = new vdHatchProperties(VdConstFill.VdFillModeSolid);
                doc.Model.Entities.AddItem(rect); // this is added just for better transparency display
    
                // Using the transparency in the object by setting the AlphaBlending
                vdCircle cir1 = new vdCircle(doc, new gPoint(2, 2), 1.0d);
                cir1.LineWeight = VdConstLineWeight.LW_211;
                cir1.PenColor.ColorIndex = 2;
                cir1.PenColor.AlphaBlending = 120;
                // the PenColor.AlphaBlending will be applied
                cir1.TransparencyMethod = vdFigure.TransparencyMethodEnum.KeepOwn; 
                doc.Model.Entities.AddItem(cir1);
    
                // Using the transparency in the Layer
                vdLayer lay = new vdLayer(doc, "Transparent");
                lay.PenColor.FromSystemColor(Color.Red); // layer is red !!!
                lay.PenColor.AlphaBlending = 120; // setting layer's transparency
                doc.Layers.AddItem(lay);
                vdCircle cir2 = new vdCircle(doc, new gPoint(4.7, 2), 1.2d);
                cir2.LineWeight = VdConstLineWeight.LW_200;
                cir2.Layer = lay;
                cir2.PenColor.ColorIndex = 2;
                // but object is not colored by layer, only transparency is by layer here
                // Layer's alpha blending wil be applied
                cir2.TransparencyMethod = vdFigure.TransparencyMethodEnum.ByLayer; 
                doc.Model.Entities.AddItem(cir2);
    
                // Using the transparency inside blocks/inserts
                vdBlock blk = new vdBlock(doc, "Transparecy");
                vdCircle cir3 = new vdCircle(doc, new gPoint(8, 2, 0), 1.5); // bigger circle
                cir3.PenColor.ColorIndex = 2;
                cir3.LineWeight =  VdConstLineWeight.LW_158;
                // the insert's Aplha blending will be applied
                cir3.TransparencyMethod = vdFigure.TransparencyMethodEnum.ByBlock; 
                blk.Entities.AddItem(cir3);
    
                cir3 = new vdCircle(doc, new gPoint(8, 2, 0), 0.7); //smaller circle
                cir3.PenColor.ByBlock = true;
                cir3.LineWeight = VdConstLineWeight.LW_158;
                // the layer's Aplha blending will be applied which isn't transparent
                cir3.TransparencyMethod = vdFigure.TransparencyMethodEnum.ByLayer; 
                blk.Entities.AddItem(cir3);
    
                doc.Blocks.AddItem(blk);
                vdInsert ins = new vdInsert(doc, blk, new gPoint(0, 0, 0), 0, 1, 1, 1);
                // setting the inserts draw to use the Alpha Blending
                ins.TransparencyMethod = vdFigure.TransparencyMethodEnum.Default; 
                ins.PenColor.FromSystemColor(Color.Yellow);
                ins.PenColor.AlphaBlending = 120; // setting transparency to 120
                doc.Model.Entities.AddItem(ins);
    
                doc.Model.ZoomExtents(); doc.Redraw(true);
            }
    
    
            private void button2_Click(object sender, EventArgs e)
            {
                // Hatches/Filled objects and Transparency
                doc.New();
    
                vdRect rect = new vdRect(doc, new gPoint(0, 0, -0.1), 10, 2, 0);
                rect.HatchProperties = new vdHatchProperties(VdConstFill.VdFillModeSolid);
                doc.Model.Entities.AddItem(rect); // this is added just for better transparency display
    
                // 2D Transparency Does NOT work in 3D modes (hide/shade/render/wire3D)
                vdCircle cir1 = new vdCircle(doc, new gPoint(2, 2), 1.0d);
                cir1.HatchProperties = new vdHatchProperties(VdConstFill.VdFillModeSolid);
                cir1.HatchProperties.Solid2dTransparency = 80; // values 0 (invisible)  to 255 (no transparency)
                cir1.PenColor.FromSystemColor(Color.Red);
                cir1.HatchProperties.FillColor.FromSystemColor(Color.Green);
                doc.Model.Entities.AddItem(cir1);
    
                // Transparency in PenColor work ALSO in 3D modes (hide/shade/render/wire3D)
                vdCircle cir2 = new vdCircle(doc, new gPoint(4.7, 2), 1.2d);
                cir2.HatchProperties = new vdHatchProperties(VdConstFill.VdFillModeSolid);
                cir2.PenColor.FromSystemColor(Color.Green);
                cir2.HatchProperties.FillColor.FromSystemColor(Color.Red);
                cir2.HatchProperties.FillColor.AlphaBlending = 80;// values 0 (invisible)  to 255 (no transparency)
                doc.Model.Entities.AddItem(cir2);
    
                // the above modes can be compbined with TransparencyMethod of vdfigure (that work in 3D modes), like
                vdCircle cir3 = new vdCircle(doc, new gPoint(8, 2, 0), 1.5);
                cir3.PenColor.ColorIndex = 4;
                cir3.LineWeight = VdConstLineWeight.LW_200;
                cir3.PenColor.AlphaBlending = 80;
                cir3.HatchProperties = new vdHatchProperties(VdConstFill.VdFillModeSolid);
                cir3.HatchProperties.FillColor.FromSystemColor(Color.Green);
                cir3.HatchProperties.FillColor.AlphaBlending = 80;
                cir3.TransparencyMethod = vdFigure.TransparencyMethodEnum.KeepOwn;
                doc.Model.Entities.AddItem(cir3);
    
                doc.Model.ZoomExtents(); doc.Redraw(true);
            }
    
        }

    相關(guān)資料推薦:

    VectorDraw Developer Framework(VDF)示例


    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();