Previous Document Next Document

Object Model Reference : Classes : S : Shape : Methods : Shape.Intersect


Shape.Intersect

Function Intersect(TargetShape As Shape, [LeaveSource As Boolean = True], [LeaveTarget As Boolean = True]) As Shape

Description

Member of Shape

The Intersect method creates a shape consisting of an intersection of two shapes.

Parameter
Description
TargetShape
Specifies the shape with which to intersect
LeaveSource
Specifies whether to keep the intersected shape after the intersection is complete. This parameter is optional, and its default value is True.
LeaveTarget
Specifies whether to keep the intersecting shape after the intersection is complete. This parameter is optional, and its default value is True.

VBA example

The following VBA example creates a color diagram for the additive color model (RGB). Three circles are filled, each with red, green, and blue. At the intersections of the circles, the resulting color blend fills the areas: white in the middle, and cyan, magenta, and yellow in the areas between each pair of circles.

Sub Test()
 Dim s(0 To 2) As Shape
 Dim si(0 To 2) As Shape
 Dim sm As Shape
 Dim x As Double, y As Double
 Dim i As Long, n As Long
 Dim r As Long, g As Long, b As Long
 Dim c1 As Color, c2 As Color
 For i = 0 To 2
  x = ActivePage.SizeWidth / 2 + 1 * Cos(i * 2.09439507)
  y = ActivePage.SizeHeight / 2 + 1 * Sin(i * 2.09439507)
  Set s(i) = ActiveLayer.CreateEllipse2(x, y, 1.5)
  r = -255 * (i = 0)
  g = -255 * (i = 1)
  b = -255 * (i = 2)
  s(i).Fill.UniformColor.RGBAssign r, g, b
 Next i
 For i = 0 To 2
  n = (i + 1) Mod 3
  Set si(i) = s(i).Intersect(s(n))
  Set c1 = s(i).Fill.UniformColor
  Set c2 = s(n).Fill.UniformColor
  r = c1.RGBRed + c2.RGBRed
  g = c1.RGBGreen + c2.RGBGreen
  b = c1.RGBBlue + c2.RGBBlue
  si(i).Fill.UniformColor.RGBAssign r, g, b
 Next i
 Set sm = si(1).Intersect(si(2))
 sm.Fill.UniformColor.RGBAssign 255, 255, 255
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.