Previous Document Next Document

Object Model Reference : Classes : P : PatternCanvas : Methods : PatternCanvas.CopyArea


PatternCanvas.CopyArea

Sub CopyArea(x1 As Long, y1 As Long, x2 As Long, y2 As Long, x As Long, y As Long)

Description

Member of PatternCanvas

The CopyArea method copies an area of a pattern canvas, defined by two coordinates, and then moves that area to a new location on the canvas.

Parameter
Description
x1
Specifies the x-coordinate of the first point that defines the area to copy on the pattern canvas. This value is measured in document units.
y1
Specifies the y-coordinate of the first point that defines the area to copy on the pattern canvas. This value is measured in document units.
x2
Specifies the x-coordinate of the second point that defines the area to copy on the pattern canvas. This value is measured in document units.
y2
Specifies the y-coordinate of the second point that defines the area to copy on the pattern canvas. This value is measured in document units.
x
Specifies the horizontal position of the point on the pattern canvas that marks the new location of the copied area. This value is measured in document units.
y
Specifies the vertical position of a point on the pattern canvas that marks the new location of the copied area. This value is measured in document units.

VBA example

The following VBA example creates a “windmill” pattern by drawing a circle and rotating half of that circle by 90°. It then copies the resulting pattern and rotates the copy by 180°.

Sub Test()
 Dim c As New PatternCanvas
 Dim a As Double, x As Long, y As Long
 c.Size = cdrPatternCanvas64x64
 c.Clear
 DrawCircle c, 32, 16, 16, True
 c.CopyArea 0, 0, 31, 31, 32, 0
 c.RotateArea 32, 0, 63, 31, -90
 c.CopyArea 0, 0, 63, 31, 0, 32
 c.RotateArea 0, 32, 63, 63, 180
 With ActiveLayer.CreateRectangle(0, 0, 2, 2)
  .Fill.ApplyPatternFill cdrTwoColorPattern
  .Fill.Pattern.Canvas = c
 End With
End Sub
' ==== The following two subroutines draw a circle on a canvas
Private Sub DrawCircle(c As PatternCanvas, CenterX As Long, CenterY As Long, Radius As Long, Filled As Boolean)
 Dim p As Long, x As Long, y As Long
 x = 0
 y = Radius
 Plot c, x, y, CenterX, CenterY, Filled
 p = 1 - Radius
 While x < y
  If p < 0 Then
   x = x + 1
   p = p + 2 * x + 1
  Else
   x = x + 1
   y = y - 1
   p = p + 2 * (x - y) + 1
  End If
  Plot c, x, y, CenterX, CenterY, Filled
 Wend
End Sub
Private Sub Plot(c As PatternCanvas, x As Long, y As Long, cx As Long, cy As Long, Filled As Boolean)
 If Filled Then
  c.Line (cx + x, cy + y)-(cx - x, cy + y)
  c.Line (cx + x, cy - y)-(cx - x, cy - y)
  c.Line (cx + y, cy + x)-(cx - y, cy + x)
  c.Line (cx + y, cy - x)-(cx - y, cy - x)
 Else
  c.PSet (cx + x, cy + y)
  c.PSet (cx - x, cy + y)
  c.PSet (cx + x, cy - y)
  c.PSet (cx - x, cy - y)
  c.PSet (cx + y, cy + x)
  c.PSet (cx - y, cy + x)
  c.PSet (cx + y, cy - x)
  c.PSet (cx - y, cy - x)
 End If
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.