First of all, what I want to achieve is a shape node filled with two different, distinct colors (not blended), e.g. top part of a circle is white, bottom is black.
From what I've found, my only option is to manually create paths and color them. That's fine with me, but I first need to know the exact paths.
I'm trying to avoid complex calculations, so my question is - is there any way to get a path describing a common area of two overlapping nodes?
A simple example to illustrate the problem: when the circle collides with the black area, the part of the circle which overlaps black rectangle should change colour - how can I get that overlap area's path?
Related
I am making a isometric game using Swift and Sprite Kit.
I am rethinking my approach about coloring buildings before they are build.
Like in every game, before user builds an object, he has to move it to the free plot, and by moving it, node will change color from green to red, if the object can or cannot be placed.
Here are some pictures for clarification:
What I am doing right now, as i am prety new in Sprite Kit:
I make one SKNode - parent
I make 3 nodes and add them to a parent node. Those 3 nodes contain regular building image, red building image and green building image.
If building should be colored red, I hode nodes containing green and regular images. if it needs to be green, I hide other two and sme goes for regular.
My main question is this:
Can I have only regular node, with regular image, and somehow overlay it with green or red color (but only overlay non transparent image parts?
I was thinking abut using Pixel Shader but I'm not sure if it's the right tool.
If I cannot do that my next question is: Is this 3 nodes in a parent approach a good one or it's better to change the image of one node, depending if I need to show regular green or red object image?
I have several SKSpriteNodes that need to be semi-transparent when they intersect each other. If I set the node's color alpha = 0.5 this works as desired. But, I don't want the "background" to show through at all. So the nodes should never blend with the background (ie, the root node).
There is probably a simple technique to accomplish this, but I don't know what it is.
Update
Here is an example of what I'm trying to describe with two simple circle nodes. The circle border has alpha=1.0, the insides are alpha=0.5. As shown the circles blend when overlapped, which is what I want. But then of course they also blend with the background, which is not desired. For the portions that are not overlapped, the inside of the circles should look exactly like the borders.
I have two UIViews, each one has draw a car(vectorgraph), now if a car(A) behind another car(B), then I want the overlaps in A be dashed.
the car was drawn by UIBezierPath, I want the overlaps in A's path become dashed, how can I do this?
Thank you for your helping!
I don't think there is any way to do this automatically. You would need to calculate the bounding rectangle of the intersection of the 2 views, and then manually parse the path of car A into 2 parts, the part that's covered and the part that's not, and draw the covered part using dashed lines.
This is original development that you would have to do yourself.
Erica Sadun's outstanding "iOS Developer's Cookbook" series has a recipe that shows how to parse a bezier path segment by segment. Figuring out the portion of the path that is inside the intersection range will involve some tricky programming.
I am trying to create a little arrow in the middle of one of the sides of a rectangle. ( like twitter tweet button).
Any ideas how to do it in fireworks cs4 ?
Thanks.
There are two ways of doing this and unlike all the answers presented here, they are going to give you more freedom if you want to resize your shape and yes the triangle will be a part of your final shape not a superimposed two shapes.
Extending a shape with Pen tool
First, start with a rectangle. It can have rounded corner, however you like it. Then, you can either ungroup it or selecting the subselection tool (the white arrow in the tools panel) and clicking on one of the corners, you can make it editable for the Pen tool. Then, choosing the Pen tool, click three times on the left side of the rectangle, creating three points apart from each other along the edge. Back to subselection tool and select the middle one. Clicking a few times on the left arrow key on your keyboard will make it go to left. Since we are altering the base shape, your new shape can receive further filters, stroke colors etc.
Adding your shape to another shape
Create your rectangle and triangle shape anyway you want to see it. Position triangle so the right of it is just over the left edge of the rectangle. Give it 1-2 px of intersection area if you want, you'll most likely play with this approach to have best results. Both objects selected, go to Modify menu and select Union under Combine Paths. This option will merge both shapes. Since, FW is going to approximate both object styles, you can a blurred stroke if you already had strokes in your objects. You can adjust it but some people thing the method described above is better since they are editing the original image so it's more constructive than guessing the outcome of this merging operation. As usual, using the Pen tool, you can refine your shape.
Have fun.
This question really doesn't belong on Stack Overflow, but I'll answer anyway, since I'm not sure where it should go.
If this is what you mean:
then try this:
Create a small triangle.
Rotate the triangle 90 degrees to the left, so that it looks like the arrow.
Position the triangle on the side of the rectangle.
Change the triangle's color to the same color as the rectangle.
Imagine you are drawing a map of county borders. You are given a set of polygons, one for each boundary, and you draw each polygon.
In places where two counties share a border you just end up drawing the border twice. In the absence of partial transparency effects, and with a solid pen, this is no problem.
But, on maps, borders of this kind are customarily shown by dash-dotted lines. In this case, situations like the one depicted below can happen:
Notice how the dash pattern, which normally is dash-dot-dot, gets screwed up where the two areas share a border. In this case, it happened to become a longdash-dot pattern, but in general it could do anything from coincidentally looking normal to creating a solid line.
How does/should map rendering software prevent artifacts of this kind from occuring?
The artifact is due the fact that the piece of border is drawn twice. Instead of trying to supress such artifacts, you could try to not draw border sections twice, by keeping a list of segments already drawn in memory, and if you encounter a stretch that's already drawn, you don't draw it again.
Your brush pattern colors some pixels black and leaves some pixels alone. Instead of leaving the pixel alone, can you set up your brush pattern to color those pixels white (or whatever your background color is)?
Another possibility is to always draw your county borders twice -- once with a solid white pattern, and again with the brush pattern of your choice.
I suppose they break their border lines into segments, then remove the overlaps.
This is mostly a geometric problem, not a drawing problem.
Instead of going with a dashed line, you could do it Zip-a-tone style, like this:
Zip-a-tone was this graphic art stuff that was basically a sticky sheet of plastic with a regular (printable) pattern of dots on it. To use it, you would lay a big sheet of it over your drawing and cut it around the areas on your drawing that you wanted zip-a-toned, and then peel off the parts you didn't want.
For this image, I just went with an alternating checkerboard pattern, with the lines two pixels wide. Because all the lines are drawn from one big (virtual) block of this checkerboard pattern, you never have to worry about weird artifacts at the joints or any overlap effects.
Angled lines are a bit tricky, but basically you imagine the edges of the line sort of cutting through pixels, and thus you draw them at the appropriate shade of grade instead of full black (in the case of the 45 degree line here, the pixels are drawn with RGB(170, 170, 170), but any angle could be rendered with appropriate shades).
I'm not sure if GDI+ could do this easily using the textured brushes, but maybe. Otherwise you'd have to custom-code it. The advantage of this method over just solid gray lines would be that this would allow some of the background to show through.
This is an interesting question that I never really thought about. I think the only real solution is to render the entire complex figure as a series of lines or paths that do not overlap anywhere. I'm not surprised that GDI+ doesn't handle this situation in any automatic way.