Methods


AddGradientHatch


This sample showcases the powerful AddGradientHatch method available in the DXFReader.NET Component. By utilizing this method, you can easily generate a new drawing that includes various gradient types, resulting in visually stunning and dynamic designs. The picture below provides a visual representation of the different gradient types that will be demonstrated in this sample:

C#

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DXFReaderNET;
namespace AddGradientHatch
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object senderEventArgs e)
        {
            int k;
            int j;
            int n = 0;

            dxfReaderNETControl1.NewDrawing();
            dxfReaderNETControl1.SetLimits(new Vector2(-1-1), new Vector2(3131));
            for (k = 0k <= 2k++)
            {
                for (j = 0j <= 2j++)
                {
                    List<DXFReaderNET.Entities.LwPolylineVertexpolyVertexes = new List<DXFReaderNET.Entities.LwPolylineVertex>();
                    polyVertexes.Add(new DXFReaderNET.Entities.LwPolylineVertex(j * 10k * 10));
                    polyVertexes.Add(new DXFReaderNET.Entities.LwPolylineVertex(j * 10 + 9k * 10));
                    polyVertexes.Add(new DXFReaderNET.Entities.LwPolylineVertex(j * 10 + 9k * 10 + 9));
                    polyVertexes.Add(new DXFReaderNET.Entities.LwPolylineVertex(j * 10k * 10 + 9));

                    List<DXFReaderNET.Entities.EntityObjectBoundary = new List<DXFReaderNET.Entities.EntityObject>();
                    Boundary.Add(dxfReaderNETControl1.AddLightWeightPolyline(polyVertexestrue));

                    DXFReaderNET.Entities.HatchGradientPatternType hgType = (DXFReaderNET.Entities.HatchGradientPatternType)n;
                    n += 1;

                    Vector3 Position = polyVertexes[3].Position.ToVector3() + new Vector3(00.20);
                    dxfReaderNETControl1.AddText(hgType.ToString(), PositionPosition0.7);

                    dxfReaderNETControl1.AddGradientHatch(hgTypeBoundary);
                }
            }

            dxfReaderNETControl1.ZoomLimits();
            dxfReaderNETControl1.Refresh();
        }
    }
}


VB

Imports DXFReaderNET
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        dxfReaderNETControl1.NewDrawing()
        dxfReaderNETControl1.CustomCursor = CustomCursorType.CrossHair
    End Sub

    Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
        Dim k As Integer
        Dim j As Integer
        Dim n As Integer = 0
        dxfReaderNETControl1.NewDrawing()
        dxfReaderNETControl1.SetLimits(New Vector2(-1-1), New Vector2(3131))
        k = 0
        Do While (k <= 2)
            j = 0
            Do While (j <= 2)
                Dim polyVertexes As List(Of DXFReaderNET.Entities.LwPolylineVertex= New List(Of DXFReaderNET.Entities.LwPolylineVertex)
                polyVertexes.Add(New DXFReaderNET.Entities.LwPolylineVertex(j * 10, k * 10))
                polyVertexes.Add(New DXFReaderNET.Entities.LwPolylineVertex(j * 10 + 9, k * 10))
                polyVertexes.Add(New DXFReaderNET.Entities.LwPolylineVertex(j * 10 + 9, k * 10 + 9))
                polyVertexes.Add(New DXFReaderNET.Entities.LwPolylineVertex(j * 10, k * 10 + 9))
                Dim Boundary As List(Of DXFReaderNET.Entities.EntityObject= New List(Of DXFReaderNET.Entities.EntityObject)
                Boundary.Add(dxfReaderNETControl1.AddLightWeightPolyline(polyVertexes, True))
                Dim hgType As DXFReaderNET.Entities.HatchGradientPatternType = CType(n, DXFReaderNET.Entities.HatchGradientPatternType)
                n = (n + 1)
                Dim Position As Vector3 = (polyVertexes(3).Position.ToVector3 + New Vector3(00.20))
                dxfReaderNETControl1.AddText(hgType.ToString, Position, Position0.7)
                dxfReaderNETControl1.AddGradientHatch(hgType, Boundary)
                j = (j + 1)
            Loop

            k = (k + 1)
        Loop

        dxfReaderNETControl1.ZoomLimits()
        dxfReaderNETControl1.Refresh()
    End Sub
End Class


The AddGradientHatch method allows you to apply gradient fills to selected objects or regions within your DXF drawing. With this method, you can achieve captivating effects by smoothly transitioning colors across defined areas, adding depth and dimension to your designs.

To utilize the AddGradientHatch method effectively, you can specify various parameters such as the start and end colors, gradient angle or direction, and the blending mode. These parameters provide you with fine-grained control over the appearance of the gradients, enabling you to create stunning visual effects tailored to your specific design requirements.

In this sample, we will generate a new drawing that showcases different gradient types, including linear gradients, radial gradients, and angular gradients. Each gradient type offers a unique visual style and can be customized further to achieve the desired effect. By exploring the implementation of the AddGradientHatch method in this sample, you will gain valuable insights into leveraging gradient fills within your DXF drawings.


Download C# code from GitHub

Download Visual Basic code from GitHub

 


Warning!
All samples, data, places and images in this section are only for tutorial scope. They are fictitious and may not correspond to real cases.

Any similarities to actual persons or places is merely coincidental.

To evaluate all code samples you need to download and install the DXFReader.NET Compoonent first.