Exemple #1
0
    def polylineShape(self):
        x = 0
        y = 0

        for steps in [Brushes.SteelBlue, Brushes.DarkOrange, Brushes.DarkSeaGreen, Brushes.Honeydew]:
            polyline = Polyline()                                           #New Polyline for each iteration 
            polyline.StrokeThickness = self.myCanvas.Height/4               #Calculate the width of the line 
                
            x = 0                                                           
            y = y + self.myCanvas.Height/4                                  #Move the y coordinate down
            polyline.Points.Add(Point(x,y))                                 #Add x,y start point
            
            x = self.myCanvas.Width                                         #Move x coordinate to the end of canvas
            polyline.Points.Add(Point(x,y))                                 #Add x,y end point

            polyline.Stroke = steps                                         #Set the brush colour based on the steps value
                        
            self.myCanvas.Children.Add(polyline)                            #Draw the line on the canvas
Exemple #2
0
    def polylineShape(self, sides):
        self.myCanvas.Children.Clear()
        h = self.myCanvas.Width/2
        k = self.myCanvas.Height/2              #Calculate the center of the canvas
        r = 100                                 #r is the radius from the center of the canvas
        step = 2 * math.pi/sides                #the location of each point around the circumference
        theta = 0                               #theta starts at 0' anticlockwise to 360'
        polyline = Polyline()
        polyline.StrokeThickness = 1
        polyline.Stroke = Brushes.Blue

        while theta <= 360:                     #While loop, terminates after one rotation
            _x  =  h + r * math.cos(theta)
            _y  =  k + r * math.sin(theta)
            polyline.Points.Add(Point(_x,_y))   #add the new x and y point to the line drawing
            theta = theta + step

        self.myCanvas.Children.Add(polyline)    #finaly add the line we've generated to the canvas
Exemple #3
0
    def polylineShape(self):
        x = 0
        y = 0

        for steps in [
                Brushes.SteelBlue, Brushes.DarkOrange, Brushes.DarkSeaGreen,
                Brushes.Honeydew
        ]:
            polyline = Polyline()  #New Polyline for each iteration
            polyline.StrokeThickness = self.myCanvas.Height / 4  #Calculate the width of the line

            x = 0
            y = y + self.myCanvas.Height / 4  #Move the y coordinate down
            polyline.Points.Add(Point(x, y))  #Add x,y start point

            x = self.myCanvas.Width  #Move x coordinate to the end of canvas
            polyline.Points.Add(Point(x, y))  #Add x,y end point

            polyline.Stroke = steps  #Set the brush colour based on the steps value

            self.myCanvas.Children.Add(polyline)  #Draw the line on the canvas