I'm trying to create polygons with an inner border in Konva.
I found this example of doing this with globalCompositeOperation which works well in Konva, as long as there is only one shape. As soon as I try to add a second shape, this obviously doesn't work anymore and the first shape disappears.
It would work if I were to use a different layer for every shape, but of course that's not a solution that scales well.
I tried using a temporary layer as is done in the example but couldn't get it to work.
So I found this example of using group.cache(), which works fine ... until I try to scale the stage, at which point I would have to refresh the cache, otherwise I only get the scaled up cache, which looks bad.
This codesandbox illustrates the problem. (Please note that this uses simple triangles, in reality I work with arbitray polygons)
So is there a way to use cache with scaling? Or alternatively a better way to use globalCompositeOperation with multiple shapes in the same layer? Or some alternative solution?
I found a solution: calling group.cache({pixelRatio: scaleFactor}). I updated the sandbox.
No idea, if this is the best solution, but it works.
Related
I am making a relatively simple isometric map using SpriteKit. I've tried both using the editor as well as creating it through code, and each time, it seems to have some "weighting" between the various tiles even though they should overlap gracefully given that I'm just setting the styling of a tile.
Here is an example of me using the tiles from https://kenney.nl. The green is just a standard grass patch and the road is the same exact size as it.
When I create this map in the XCode UI or if i iterate through in code and paint them, this continues to occur.
However, if I was to do something like flip the tiles around and paint it all with roads with grass in the middle, it then seems to sort whichever tile there are "more of" like in this example:
If i go and make more of one tile group over another, it seems to overpower it.
So my question is, how can I keep them from using this behavior? I've tried different tilemaps together, nested them inside of eachother etc... But at the end of the day, I cant get different tiles to exist at the same "plane". I've tried with code, the UI, etc. I'd like to use the SKTileMap if possible to use the downstream features as opposed to doing all of the math myself, like in the approach in this article (http://bigspritegames.com/isometric-tile-based-game-part-1/)
After creating absoluteLayout object what is the easiest way to draw line between two objects in that?
I would recommend not to use absoluteLayout for drawing lines, but instead one of the Canvas addons:
https://vaadin.com/directory#!addon/canvas
https://vaadin.com/directory#!addon/canvas-plus
Depending of your use-case you also want to draw whatever you are drawing directly in the client and not from the server.
For your question is very limited I can't give you more guidance.
If you still want to use absoluteLayout and drawing lines, you should go with a simple div-element (you could for example add an empty Label or whatever) and style it via CSS so it looks like a line. You won't be able to "connect" your two objects easily, though - use a canvas for that purpose.
How would I go abouts getting an effect in a view controller like the wonderful work of art attached in the following link?
Circles
I do have some idea, ranging from actually using ASCII text (I know, super wrong way) to a collection view of pictures, to what I suspect is the "right" way, done with core graphics. But I am asking in case there is a super easy/right methodology I will one day discover and facepalm.
You are correct that there are two primary ways for you to draw a grid of circles.
The primary way is to draw them using UIBezierPath or by using a collection view of images of circles.
For simple shapes, it is recommended that you choose the first option simply because your choices of circles aren't restricted by your images.
Here is a link for you to get started.
I'm trying to rotate multiple elements using CATransform3d, the problem is that each one is assigned an individual vanishing point. Since they are dynamic elements I cannot use an image to simulate all of them moving together. And I know no way to move them as a group.
Here is an image that clearly shows the issue and the expected outcome. Visual Description
Already tried every solution I could find and nothing is working for me.
Cheers.
I don't understand why you can't put all of them into one view, and then just use the CATransform3d on the containing view? I've done this before with exactly the result you are looking for. Just a simple add them all as subviews of a view and then perform your CATransform3D on the view.
I have worked through the examples of turning on ScissorTestEnable and ScissorRectangle. It works fine. However, when I apply a ScaleMatrix the clipping no longer seems to work. Are these supposed to work together?
You're probably using SpriteBatch, correct? It seems to me that Shawn Hargreaves' comment on this page is probably the answer you're looking for. Have you tried moving the call that sets the scissor rectangle around to see if it starts working? I tried looking at the decompiled sources of Microsoft.Xna.Framework.Graphics - but I couldn't find any relation between GraphicsDevice.set_ScissorRectangle and SpriteBatch's flushing methods. :S
If it doesn't work, you could also try to replace the scale and scissor with a modified projection and viewport call and then render the objects in each player's screen.