-
Mar 1st, 2013, 09:08 AM
#1
Thread Starter
Junior Member
Difference between two shapes?
Hey,
Is there any way I can 'filter' a kind of difference between two shapes, kind of like this:
Thanks!
-
Mar 1st, 2013, 09:30 AM
#2
Re: Difference between two shapes?
For circle and 2nd square.
MsgBox Square2.Left - (Circle1.Left + Circle1.Width)
-
Mar 1st, 2013, 09:41 AM
#3
Thread Starter
Junior Member
Re: Difference between two shapes?
Originally Posted by Max187Boucher
For circle and 2nd square.
MsgBox Square2.Left - (Circle1.Left + Circle1.Width)
I don't know if you understand my question. What I was asking is how to replicate the effect shown in the image. How would just using a messagebox let me change the way a shape looks? I'm not looking for the difference in distance, I'm looking for a way to actually make the effect shown in the image happen.
-
Mar 1st, 2013, 01:41 PM
#4
Re: Difference between two shapes?
http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
do some research before asking easy questions
also describe your problem more clearly next time
-
Mar 1st, 2013, 02:36 PM
#5
Re: Difference between two shapes?
Now I am going to post this simple solution (hopefully I won't get too much flack for it's simplicity from the REAL VB-coders out there).
But what I did for you is simply put four shapes on a form, along with a command button. First I brought shape1 (circle) 'forward' of shape 2 (green square) using the Format option in the IDE. Then, I did the same thing with both shapes 3 and 4 (these are SOLID backgrounds/no border).
I set the visible property for shapes 3 and 4 to false in the IDE.
I loaded the form and you will see your green rectangle with the red circle (both with black borders) in the bottom right of the rectangle. Then, when you click the command button, it changes the fillcolor of shape1 to the same color as the form (and shapes 3 and 4), and turns the visibility of shapes 3 and 4 to true. This essentially HIDES 3/4 of the circle's border, leaving 1/4 shown 'in' the green square.
I don't play with shapes much (which will be obvious to the experts), so I had no other clue how to put a black border around the resulting green 'shape' without doing it this way.
Well, anyway, here is the code:
Code:
Private Sub Form_Load()
Shape1.Top = 700 'circle
Shape1.Left = 700
Shape1.Height = 1200
Shape1.Width = 1200
Shape1.Shape = vbShapeCircle
Shape1.BorderColor = vbBlack
Shape1.FillColor = vbRed
Shape1.FillStyle = vbSolid
Shape2.Top = 0 'rectangle
Shape2.Left = 0
Shape2.FillColor = vbGreen
Shape2.FillStyle = vbSolid
Shape2.BorderColor = vbBlack
Shape2.Height = 1400
Shape2.Width = 1400
'next two shapes simply to hide the border of the circle outside the square
Shape3.BackColor = Form1.BackColor
Shape3.Left = Shape2.Left + Shape2.Width
Shape3.Top = Shape2.Top
Shape3.Height = Shape2.Height + Shape1.Height
Shape3.BorderStyle = vbTransparent
Shape4.BackColor = Form1.BackColor
Shape4.Top = Shape2.Top + Shape2.Height
Shape4.Left = Shape2.Left
Shape4.BorderStyle = vbTransparent
Shape4.Height = Shape1.Height
Shape4.Left = Shape4.Left
Shape4.Width = Shape2.Width + Shape1.Width
End Sub
-
Mar 1st, 2013, 02:44 PM
#6
Re: Difference between two shapes?
Originally Posted by bowiz2
Hey,
Is there any way I can 'filter' a kind of difference between two shapes, kind of like this:
Thanks!
I do not understand the question. You need to do a better job of explaining what you want to do. Your second picture shows only the area of the square that is not overlapped by the circle which I certainly would not describe as the difference between two objects. Or are you trying to say that the red and green is one object and the green is another meaning that the difference is the circle?
Whatever the case may be you have to give a clear description before anyone can give you the answer you seek.
-
Mar 1st, 2013, 02:51 PM
#7
Re: Difference between two shapes?
Hey DM....in post #3, he kinda did, I think:
What I was asking is how to replicate the effect shown in the image.
And using a simplistic approach, I did that. Working with shapes, lines, pixels, etc, is not my bag of tea....don't see too much use for that stuff in what I do. So what I posted may seem like a VB beginner's approach.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|