Hide labels when are covered from a polygon - label

I need to mask all labels from a layer when they are outside a covering vector. On the image below there are contours; the lines are visible only if they intersects a polygon from a mask layer that is excluded with a filter.
I'm be able to hide the lines that doesn't intersects the polygon, but I can't do the same with the labels.
I'm using QGIS 3.22, below the filter managed from atlas.

You should to clip your polygon by mask before show the labels.
You can do that using this tools:
clip vector by mask layer
enter image description here

Related

MapLibre GL JS with terrain layer: How to pin a horizontal plane to a specific altitude?

I based some code on the "Add a 3D model" example at maplibre.org in order to draw only a horizontal plane on a map which uses setTerrain to add a terrain layer.
My intention is to draw a couple of semitransparent layers at a given heights above sea level and have them intersect with mountains, somewhat similar to contour lines.
In my first test I just created a 1km-wide square at altitude 0.
I am somewhat confused by the behavior, since altitude 0 turns out to be the height of the terrain in the center of the visible map area. When I then drag the map and release the mouse, altitude 0 gets somehow reset again to the new altitude 0 of the terrain at the center, making the plane change its relative altitude.
The following animated GIF illustrates the problem:
The GIF has a mountain range to the right and the elevation is greatly exaggerated, in order to better illustrate the issue.
What do I need to do in order to be able to specify the height of the plane in meters above sea level and have it appear to be fixed at that height when dragging the map?
I think I need to get the height of the terrain at the center and then add/substract it from the plane's z-position in order for it to stay put at the height relative to given landmarks, but I have got no idea on how to do this inside of a custom layer's render function.

Clipping or Erasing area in threejs

First I am explaining the above image. Image is marking with 1, 2 and 3.
1 - This is the rectangle shape.
2 - This is the rectangle shape.
3 - This is the circle shape (draw with destination-in global composite operation).
Every shape draw using HTML5 canvas.
Now I want to same draw using threejs with WebGLRenderer. So is it possible to draw? If yes then how?
3rd shape can be anything (for ex - circle, rectangle, polygon).
Any suggestion?
We can erase an area in threejs by set the blending property. In threejs different types of blending property available. For example THREE.SubtractiveBlending which is use to subtract the area.
For details -
1) http://threejs.org/docs/#Reference/Constants/Materials
2) http://threejs.org/examples/#webgl_materials_blending
3) http://threejs.org/examples/#webgl_materials_blending_custom
To draw using WebGLRenderer, is basically changing the canvas by:
renderer = new THREE.WebGLRenderer();
Just beware of the methods of Canvas that do not exist in WebGLRenderer.
If you show as part of the code, it would be good to give more precision. But anything, just comment here!

BitmapData pattern fill in actionscript 3.0

How do i fill some BitmapData image with other image pattern in as 3.0? For example, i have an white image with black square at the center which would be "square:BitmapData" and the other image with little(2x2) blue circle which i would call "circle:BitmapData". I want to fill that square with this blue circles, is there any way to do this?
UPDATE
Here i found the example of what i need to do:
This is two images (left is like my square, right is like the blue circle)
http://pix.samoucka.ru/img/content/graphics/thewebschedule/8/466.gif
And this is how it would look after filling
http://pix.samoucka.ru/img/content/graphics/thewebschedule/8/467.gif
You can try using copyPixels() and iterating though x and y to tile the whole thing, copyPixels() is very fast.
Or
It might be simpler to create a Sprite and use graphics.beginBitmapFill() then graphics.drawRect() with the correct size, then draw() to the BitmapData in the correct position.
If you need to determine the size and position of the black square, getColorBoundsRect() should do the job.

OpenGl Blending

i want to blend two rects, but i want to draw only blended area (area where rects are intersecting), How to do it
If you don't want to compute the intersection you can probably use the stencil buffer to achieve that. read about it here:
http://bluevoid.com/opengl/sig00/advanced00/notes/node118.html
You can draw the two rects and with increment on the stencil buffer and then mask only the pixels that have value > 2, i.e. the pixels where 2 or more rects were drawn.
The intersection of two convex rects is always a rect. so why not just compute the intersection and draw only the that?
GLES20.glEnable( GLES20.GL_BLEND );
GLES20.glBlendFunc( GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA );
But you should set behavior of your blend function yourown.
And in the shader I set alpha channel. You can see the result:
blending post.
the source of android project

Does a given rect intersect a rotated view?

I have an NSView that is rotated using -setFrameRotation. (This is necessary because the view responds to mouse events, and you don't get correct behavior if you merely draw the view with a rotated NSAffineTransform.)
Given a rect in the rotated view's superview coordinates, how can I determine what portion of the rect intersects the rotated view's frame?
Use case: the Cocoa text system proposes to draw text in a line fragment rectangle. I need to determine how much of that rectangle may be filled with text without overlapping the rotated view.
Take the point, use an affine transform to rotate into the coordinate system of the bounds of the rect and then rect-test that.

Resources