working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,753 snippets matching: shape

    public by sherazam  120625  0  5  0

    How to Set Line Spacing of a Paragraph in an Excel Shape or Textbox inside .NET Apps

    This technical tip shows how to Set Line Spacing of the Paragraph in a Shape or Textbox in .NET applications. You can set the line space of the paragraph, its space before and space after using the TextParagraph.LineSpace, TextParagraph.SpaceBefore and TextParagraph.SpaceAfter respectively. The following example shows how to Set Line Spacing of the
    // Enter here the actual content of the snippet.            
    
    //[C# Code]
     
    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
    // The path to the documents directory.
    string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    
    // Create a workbook
    Workbook wb = new Workbook();
    
    // Access first worksheet
    Worksheet ws = wb.Worksheets[0];
    
    // Add text box inside the sheet
    ws.Shapes.AddTextBox(2, 0, 2, 0, 100, 200);
    
    // Access first shape which is a text box and set is text
    Shape shape = ws.Shapes[0];
    shape.Text = "Sign up for your free phone number.\nCall and text online for free.";
    
    // Acccess the first paragraph
    TextParagraph p = shape.TextBody.TextParagraphs[1];
    
    // Set the line space
    p.LineSpaceSizeType = LineSpaceSizeType.Points;
    p.LineSpace = 20;
    
    // Set the space after
    p.SpaceAfterSizeType = LineSpaceSizeType.Points;
    p.SpaceAfter = 10;
    
    // Set the space before
    p.SpaceBeforeSizeType = LineSpaceSizeType.Points;
    p.SpaceBefore = 10;
    
    // Save the workbook in xlsx format
    wb.Save(dataDir + "output_out_.xlsx", SaveFormat.Xlsx); 
    
    //[VB.NET Code]
    
    ' For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
    ' The path to the documents directory.
    Dim dataDir As String = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
    
    ' Create a workbook
    Dim wb As New Workbook()
    
    ' Access first worksheet
    Dim ws As Worksheet = wb.Worksheets(0)
    
    ' Add text box inside the sheet
    ws.Shapes.AddTextBox(2, 0, 2, 0, 100, 200)
    
    ' Access first shape which is a text box and set is text
    Dim shape As Shape = ws.Shapes(0)
    shape.Text = "Sign up for your free phone number." & vbLf & "Call and text online for free."
    
    ' Acccess the first paragraph
    Dim p As TextParagraph = shape.TextBody.TextParagraphs(1)
    
    ' Set the line space
    p.LineSpaceSizeType = LineSpaceSizeType.Points
    p.LineSpace = 20
    
    ' Set the space after
    p.SpaceAfterSizeType = LineSpaceSizeType.Points
    p.SpaceAfter = 10
    
    ' Set the space before
    p.SpaceBeforeSizeType = LineSpaceSizeType.Points
    p.SpaceBefore = 10
    
    ' Save the workbook in xlsx format
    wb.Save(dataDir & Convert.ToString("output_out_.xlsx"), SaveFormat.Xlsx) 
    
    

    public by sherazam  3160  0  6  0

    How to Convert a Visio Shape to Other File Formats inside .NET Applications

    // Enter here the actual content of the snippet.            The code snippets below show the complete source code for adding new shapes to a Visio diagram.
    
    // [C# Code Sample]
    
    double shapeWidth = 0;
    double shapeHeight = 0;
    
    // load Visio diagram
    Diagram srcVisio = new Diagram("C:/temp/MyVisio.vsd");
    // get Visio page
    Aspose.Diagram.Page srcPage = srcVisio.Pages[1];
    // remove background page
    srcPage.BackPage = null;
    
    // get hash table of shapes, it holds id and name
    Hashtable remShapes = new Hashtable();
    //Hashtable<Long, String> remShapes = new Hashtable<Long, String>();
    foreach (Aspose.Diagram.Shape shape in srcPage.Shapes)
        // for the normal shape
        remShapes.Add(shape.ID, shape.Name);
    
    // iterate through the hash table
    foreach (DictionaryEntry shapeEntry in remShapes)
    {
        long key = (long)shapeEntry.Key;
        string val = (string)shapeEntry.Value;
        Aspose.Diagram.Shape shape = srcPage.Shapes.GetShape(key);
        // check of the shape name
        if (val.Equals("GroupShape1"))
        {
            // move shape to the origin corner
            shapeWidth = shape.XForm.Width.Value;
            shapeHeight = shape.XForm.Height.Value;
            shape.MoveTo(shapeWidth * 0.5, shapeHeight * 0.5);
            // trim page size
            srcPage.PageSheet.PageProps.PageWidth.Value = shapeWidth;
            srcPage.PageSheet.PageProps.PageHeight.Value = shapeHeight;
        }
        else
        {
            // remove shape from the Visio page and hash table
            srcPage.Shapes.Remove(shape);
        }
    }
    remShapes.Clear();
    
    // specify saving options
    Aspose.Diagram.Saving.PdfSaveOptions opts = new Aspose.Diagram.Saving.PdfSaveOptions();
    // set page count to save
    opts.PageCount = 1;
    // set starting index of the page
    opts.PageIndex = 1;
    // save it
    srcVisio.Save("C:/temp/Output.pdf", opts);
    
    
    // [VB.NET Code Sample]
    
    Dim shapeWidth As Double = 0
    Dim shapeHeight As Double = 0
    
    ' load Visio diagram
    Dim srcVisio As New Diagram("C:/temp/MyVisio.vsd")
    ' get Visio page
    Dim srcPage As Aspose.Diagram.Page = srcVisio.Pages(1)
    ' remove background page
    srcPage.BackPage = Nothing
    
    ' get hash table of shapes, it holds id and name
    Dim remShapes As New Hashtable()
    'Hashtable<Long, String> remShapes = new Hashtable<Long, String>();
    For Each shape As Aspose.Diagram.Shape In srcPage.Shapes
        ' for the normal shape
        remShapes.Add(shape.ID, shape.Name)
    Next
    
    ' iterate through the hash table
    For Each shapeEntry As DictionaryEntry In remShapes
        Dim key As Long = CLng(shapeEntry.Key)
        Dim val As String = DirectCast(shapeEntry.Value, String)
        Dim shape As Aspose.Diagram.Shape = srcPage.Shapes.GetShape(key)
        ' check of the shape name
        If val.Equals("GroupShape1") Then
    	' move shape to the origin corner
    	shapeWidth = shape.XForm.Width.Value
    	shapeHeight = shape.XForm.Height.Value
    	shape.MoveTo(shapeWidth * 0.5, shapeHeight * 0.5)
    	' trim page size
    	srcPage.PageSheet.PageProps.PageWidth.Value = shapeWidth
    	srcPage.PageSheet.PageProps.PageHeight.Value = shapeHeight
        Else
    	' remove shape from the Visio page and hash table
    	srcPage.Shapes.Remove(shape)
        End If
    Next
    remShapes.Clear()
    
    ' specify saving options
    Dim opts As New Aspose.Diagram.Saving.PdfSaveOptions()
    ' set page count to save
    opts.PageCount = 1
    ' set starting index of the page
    opts.PageIndex = 1
    ' save it
    srcVisio.Save("C:/temp/Output.pdf", opts)
    
    

    public by Geometry  488  0  4  0

    FromLocationShape: Creates a new <see cref="LogLogisticDistribution"/> using the location-shape parametrization. In this parametrization, <see cref="Beta"/> is taken as 1 / <paramref name="shape"/>.

    Creates a new using the location-shape parametrization. In this parametrization, is taken as 1 / . The location parameter μ (mu) [taken as μ = α]. The distribution's shape value σ (sigma) [taken as σ = β]. A with α = μ and β = 1/σ.
    /// <summary>
    ///   Creates a new <see cref="LogLogisticDistribution"/> using 
    ///   the location-shape parametrization. In this parametrization,
    ///   <see cref="Beta"/> is taken as 1 / <paramref name="shape"/>.
    /// </summary>
    /// 
    /// <param name="location">The location parameter μ (mu) [taken as μ = α].</param>
    /// <param name="shape">The distribution's shape value σ (sigma) [taken as σ = β].</param>
    /// 
    /// <returns>
    ///   A <see cref="LogLogisticDistribution"/> with α = μ  and β = 1/σ.
    /// </returns>
    /// 
    public static LogLogisticDistribution FromLocationShape(double location, double shape)
    {
        return new LogLogisticDistribution(alpha: location, beta: 1 / shape);
    }

    public by Geometry  1245  0  6  0

    CreateAs: Creates a new multidimensional matrix with the same shape as another matrix.

    Creates a new multidimensional matrix with the same shape as another matrix.
    /// <summary>
            ///   Creates a new multidimensional matrix with the same shape as another matrix.
            /// </summary>
            /// 
    #if NET45
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
    #endif
            public static T[][] CreateAs<T>(T[,] matrix)
            {
                int rows = matrix.GetLength(0);
                int cols = matrix.GetLength(1);
                T[][] r = new T[rows][];
                for (int i = 0; i < r.Length; i++)
                    r[i] = new T[cols];
                return r;
            }

    public by Geometry  1206  0  6  0

    CreateAs: Creates a new multidimensional matrix with the same shape as another matrix.

    Creates a new multidimensional matrix with the same shape as another matrix.
    /// <summary>
            ///   Creates a new multidimensional matrix with the same shape as another matrix.
            /// </summary>
            /// 
    #if NET45
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
    #endif
            public static TOutput[,] CreateAs<TInput, TOutput>(TInput[][] matrix)
            {
                return new TOutput[matrix.Length, matrix[0].Length];
            }

    public by PBMCube  118  0  4  1

    Game Box Prototype

    command combinations Description: Quickly create operational games using simple box graphics from Phaser3 shapes (v3.13.x). This test game mechanics for enjoyment. Final Artwork added to game mechanisms, prototypes and mechanics as the final pipeline product phase.
    // ============
    //Example 4.1: Prototyping Graphics begins
    // ============
    //create a character avatar using the box prototype method 
    player = box({who: this, whereX: 150, whereY: 100,length:32, width:32, color: 0x0000FF,border: 0xFFFFFF});
    this.physics.add.existing(player);
    player.body.velocity.x = 10; //see update function
    player.body.velocity.y = 50;
    console.log("Stationary Blue character avatar created as 'player' variable.");
    // ------------  
    // OR the direct method using either rectangle or graphics
    //    and set movement velocities. 
    var avatar =  this.add.rectangle(100, 100, 32, 32, 0x0000FF).setStrokeStyle(5, 0x3399CC);
    console.log("Moving Blue character avatar created as 'player' variable.");
    var graphics = this.add.graphics({ fillStyle: { color: 0xFF0000 } });
    graphics.lineStyle(10,0xFF9900,0);
    graphics.strokeRect(100, 100, 32, 32);
    	
    //non-controlled movement (usage AI bot; see Chapter 6)
    graphics.fillRectShape(avatar);
    this.physics.add.existing(avatar);
    avatar.body.velocity.x = 50;
    avatar.body.velocity.y = 10;
    //non-controlled movement (usage AI bot; see Chapter 6)
    this.physics.add.existing(graphics);
    graphics.body.velocity.x = 50;
    graphics.body.velocity.y = 50;
    console.log("Moving Red avatar created as 'avatar' variable.\n Movement velocity set.");
    // ------------
    //create an opponent - direct method 
    var monster = this.add.rectangle(180, 60, 32, 32, 0x00FF00).setStrokeStyle(5, 0xFF9900);
    console.log("Green monster avatar created as 'monster' variable.");
    //Example 4.1: ends
    // ============
    

    public by missinglink  658  1  3  0

    Pre-indexed shapes using geo_shape filter (working)

    Pre-indexed shapes using geo_shape filter (working): gis-pre-indexed.sh
    #!/bin/bash
    
    ################################################
    # Pre-indexed shapes using geo_shape filter
    ################################################
    
    ES='localhost:9200';
    
    # Remove old data
    curl -XDELETE "$ES/shapes?pretty=true";
    curl -XDELETE "$ES/business?pretty=true";
    
    # Create shapes index, with mapping
    curl -XPOST "$ES/shapes?pretty=true" -d '
    {
      "mappings": {
        "municipalities": {
          "properties": {
            "poly": {
              "type": "geo_shape",
              "tree": "quadtree",
              "tree_levels": 26
            }
          }
        }
      }
    }';
    
    # Add a municipality to the shapes index
    curl -XPOST "$ES/shapes/municipalities/1?pretty=true" -d '
    {
      "poly": {
        "type":"Polygon",
        "coordinates": [
          [[-78.52364,38.022739],[-78.52335,38.023536],[-78.52313,38.02634],[-78.52005,38.02604],[-78.52026,38.028301],[-78.519832,38.028644],[-78.520179,38.029781],[-78.51833,38.02984],[-78.51829,38.028558],[-78.51431,38.02876],[-78.51101,38.03083],[-78.50961,38.03216],[-78.5088,38.03227],[-78.50796,38.03197],[-78.50711,38.032108],[-78.50458,38.03202],[-78.50184,38.03213],[-78.49779,38.033255],[-78.49853,38.033448],[-78.50025,38.034451],[-78.50166,38.036136],[-78.50346,38.036746],[-78.50125,38.04041],[-78.50204,38.041226],[-78.5036,38.042217],[-78.50422,38.04284],[-78.50498,38.042581],[-78.50577,38.04128],[-78.50523,38.041038],[-78.50593,38.040138],[-78.50614,38.03944],[-78.50683,38.039338],[-78.5081,38.035831],[-78.51333,38.037137],[-78.51553,38.036738],[-78.51689,38.039879],[-78.51638,38.040286],[-78.51737,38.04119],[-78.51607,38.04349],[-78.51396,38.04418],[-78.51463,38.044838],[-78.51141,38.04379],[-78.50678,38.04496],[-78.50593,38.04552],[-78.50484,38.047275],[-78.510297,38.051308],[-78.50753,38.05642],[-78.50134,38.057685],[-78.50088,38.05844],[-78.50231,38.06053],[-78.49885,38.06281],[-78.49553,38.064837],[-78.49503,38.065337],[-78.49264,38.06363],[-78.49158,38.06189],[-78.485154,38.069027],[-78.48253,38.067637],[-78.48113,38.066738],[-78.48094,38.06563],[-78.48031,38.065794],[-78.4789,38.065647],[-78.47719,38.064752],[-78.47598,38.06669],[-78.47453,38.06771],[-78.47494,38.068683],[-78.472985,38.07013],[-78.4714,38.070591],[-78.47073,38.06974],[-78.47234,38.067515],[-78.46853,38.068131],[-78.46843,38.067631],[-78.46689,38.06783],[-78.46547,38.065777],[-78.46433,38.064637],[-78.46784,38.05913],[-78.46963,38.055838],[-78.47223,38.052638],[-78.47143,38.050438],[-78.47213,38.049738],[-78.47233,38.049037],[-78.47082,38.048918],[-78.46993,38.04704],[-78.46612,38.045769],[-78.46543,38.047138],[-78.46533,38.048138],[-78.46438,38.04875],[-78.46403,38.049538],[-78.46145,38.04946],[-78.45733,38.049538],[-78.45717,38.05031],[-78.45872,38.05094],[-78.456921,38.055035],[-78.45658,38.05555],[-78.45471,38.054729],[-78.44905,38.05873],[-78.44776,38.057182],[-78.44749,38.0558],[-78.44759,38.054215],[-78.44717,38.051105],[-78.446311,38.04942],[-78.44729,38.04615],[-78.44909,38.045248],[-78.45182,38.045788],[-78.45392,38.045803],[-78.45464,38.045361],[-78.45484,38.043939],[-78.45411,38.042394],[-78.45419,38.039615],[-78.45499,38.037605],[-78.45619,38.03632],[-78.45877,38.034354],[-78.45994,38.033212],[-78.46032,38.03224],[-78.46036,38.03051],[-78.46101,38.02922],[-78.46077,38.02776],[-78.45938,38.02741],[-78.45828,38.02793],[-78.45762,38.028743],[-78.45611,38.029742],[-78.45467,38.029863],[-78.45323,38.028985],[-78.45246,38.02802],[-78.45264,38.02645],[-78.4547,38.022101],[-78.45665,38.021147],[-78.45933,38.022439],[-78.46163,38.022639],[-78.46208,38.02249],[-78.46356,38.020533],[-78.46693,38.01836],[-78.46923,38.014739],[-78.46843,38.01404],[-78.46973,38.01144],[-78.474634,38.01304],[-78.4751,38.013518],[-78.47473,38.01424],[-78.47563,38.014739],[-78.47804,38.01412],[-78.47942,38.013385],[-78.48026,38.01333],[-78.4815,38.011956],[-78.48316,38.011956],[-78.4833,38.014471],[-78.48453,38.0157],[-78.48666,38.016138],[-78.48727,38.016555],[-78.48895,38.01667],[-78.49033,38.017257],[-78.491351,38.016922],[-78.49197,38.01624],[-78.49351,38.01502],[-78.49486,38.01443],[-78.495661,38.014409],[-78.498837,38.012904],[-78.49988,38.01286],[-78.50079,38.01214],[-78.50172,38.01105],[-78.5033,38.0102],[-78.50443,38.010118],[-78.50724,38.01086],[-78.50828,38.01128],[-78.50929,38.011082],[-78.510179,38.009923],[-78.51156,38.009589],[-78.51285,38.0096],[-78.51475,38.00994],[-78.51738,38.010245],[-78.51915,38.01083],[-78.51882,38.011865],[-78.51875,38.013211],[-78.51911,38.0146],[-78.51904,38.015308],[-78.51954,38.017252],[-78.52046,38.01773],[-78.52037,38.01835],[-78.5213,38.018884],[-78.5221,38.018423],[-78.52343,38.019539],[-78.52364,38.022739]]
        ]
      }
    }';
    
    # Create business index, with mapping
    curl -XPOST "$ES/business?pretty=true" -d '
    {
      "mappings": {
        "place": {
          "properties": {
            "name": {
              "type": "string"
            },
            "location": {
              "type": "geo_shape"
            }
          }
        }
      }
    }';
    
    # Add business documents to the business index
    curl -XPOST "$ES/business/place/1?pretty=true" -d '
    {
      "name": "outside-charlottesville",
      "location": {
        "type": "point",
        "coordinates": [ "-78.45680236816406", "38.06039161923183" ]
      }
    }';
    
    curl -XPOST "$ES/business/place/2?pretty=true" -d '
    {
      "name": "inside-charlottesville",
      "location": {
        "type": "point",
        "coordinates": [ "-78.45216751098633", "38.050862251267816" ]
      }
    }';
    
    # Refresh indices
    curl -XPOST "$ES/business/_refresh?pretty=true";
    curl -XPOST "$ES/shapes/_refresh?pretty=true";
    
    # Run our search
    curl -XPOST "$ES/business/place/_search?pretty=true" -d '
    {
      "query": {
        "filtered": {
          "query": {
            "match_all": {}
          },
          "filter": {
            "geo_shape": {
              "location": {
                "indexed_shape": {
                  "id": "1",
                  "type": "municipalities",
                  "index": "shapes",
                  "path": "poly"
                }
              }
            }
          }
        }
      }
    }';
    
    

    public by missinglink  210  0  3  0

    Simplify shapefiles .shp

    Simplify shapefiles .shp: simplify.sh
    #!/bin/bash
    
    ogr2ogr output-0001.shp input.shp -simplify 0.0001 -lco ENCODING=UTF-8
    
    

    public by Geometry  1362  1  4  1

    Random: Generates a random vector of observations from the Weibull distribution with the given parameters.

    Generates a random vector of observations from the Weibull distribution with the given parameters. The scale parameter lambda. The shape parameter k. The number of samples to generate. The location where to store the samples. An array of double values sampled from the specified Weibull distribution.
    /// <summary>
    ///   Generates a random vector of observations from the 
    ///   Weibull distribution with the given parameters.
    /// </summary>
    /// 
    /// <param name="scale">The scale parameter lambda.</param>
    /// <param name="shape">The shape parameter k.</param>
    /// <param name="samples">The number of samples to generate.</param>
    /// <param name="result">The location where to store the samples.</param>
    ///
    /// <returns>An array of double values sampled from the specified Weibull distribution.</returns>
    /// 
    public static double[] Random(double shape, double scale, int samples, double[] result)
    {
        var random = Accord.Math.Random.Generator.Random;
        for (int i = 0; i < samples; i++)
            result[i] = scale * Math.Pow(-Math.Log(random.NextDouble()), 1 / shape);
        return result;
    }

    public by Geometry  1443  0  4  1

    Random: Generates a random observation from the Weibull distribution with the given parameters.

    Generates a random observation from the Weibull distribution with the given parameters. The scale parameter lambda. The shape parameter k. A random double value sampled from the specified Weibull distribution.
    /// <summary>
    ///   Generates a random observation from the 
    ///   Weibull distribution with the given parameters.
    /// </summary>
    /// 
    /// <param name="scale">The scale parameter lambda.</param>
    /// <param name="shape">The shape parameter k.</param>
    /// 
    /// <returns>A random double value sampled from the specified Weibull distribution.</returns>
    /// 
    public static double Random(double shape, double scale)
    {
        double u = Accord.Math.Random.Generator.Random.NextDouble();
        return scale * Math.Pow(-Math.Log(u), 1 / shape);
    }
    • Public Snippets
    • Channels Snippets