Avoid alpha summation in Line that overlap itself in Carto Mobile SDK - carto-mobile

Disclaimer: I posted this question originally in gis.stackexchange. Apparently it may fit better in here according to carto support. I'll keep both questions updated, and remove one of them if the moderators tell me to.
I need to draw a big line that can overlap itself. I am using this doc:
https://carto.com/docs/carto-engine/mobile-sdk/getting-started/#add-a-line
And I need the line to have a opacity of 0.3. So far so good; I have a line that is almost transparent. The problem is that when the line overlaps itself, the alpha in the overlapping area is 0.6 (because you see the line over itself)
In this link you can find an image of the problem:
https://i.imgur.com/87ouwc8.png
Is it possible to keep the alpha consistent, even if the line cross with itself?

Mobile SDK latest version (4.1.3) added feature that instead of opacity of individual lines you set alpha for whole layer. This is exactly for cases like yorus.

Related

Moving a graphic over a background image

I have a new project but I'm really not sure where to start, other than I think GNAT Ada would be good. I taught myself Ada three years ago and I have managed some static graphics with GNAT but this is different.
Please bear with me, all I need is a pointer or two towards where I might start, I'm not asking for a solution. My history is in back-end languages that are now mostly obsolete, so graphics is still a bit of a challenge.
So, the project:
With a static background image (a photograph) - and a moveable line with an adjustable cursor somewhere between the ends of the line. I need to rotate the line and adjust the length, as well as to move it around the screen and slide the cursor along the line; I have no problem calculating the positions of each element of the line. Once in place, I need to report on the position of the cursor relative to the overall length of the line. I can probably handle the reporting with what I already know but I have no clue as to how to create a graphic that I can slide around over another image. In the past I have failed to detect mouse events in GNAT Ada and I am sure I will need to get on top of that - in fact if I could, I would probably manage to control the line but doing it over an existing image is beyond me.
If I am wrong to choose GNAT Ada for this, please suggest an alternative.
I have looked in Stackoverflow for anything similar but have found answers only for Blackberry and Java, neither of which seems relevant.
For background, this will be a useful means of measuring relative lengths of the features of insect bodies from photographs, hopefully to set up some definitive identification guides for closely-related species.
With a static background image (a photograph)
So first you need a window to put your interface in. You can get this from any GUI framework (link as given by trashgod in the comments).
and a moveable line with an adjustable cursor somewhere between the ends of the line. I need to rotate the line and adjust the length, as well as to move it around the screen and slide the cursor along the line; I have no problem calculating the positions of each element of the line.
These are affine transformations. They are commonly employed in low-level graphics rendering. You can, like Zerte suggested, employ OpenGL – however modern OpenGL has a steep learning curve for beginners.
GtkAda includes a binding to the Cairo graphics library which supports such transformations, so you can create a window with GtkAda with a Cairo surface and then render your image & line on it. Cairo does have a learning curve and I never used the Ada binding, so I cannot really give an opinion about how complex this will be.
Another library that fully supports what you want to do is SDL which has Ada bindings here. The difference to GtkAda is that SDL is a pure graphics drawing library so you need to „draw“ any interactive controls yourself. On the other hand, setting up a window via SDL and drawing things will be somewhat simpler than doing it via GtkAda & Cairo.
SFML which has also been mentioned in comments is on the same level as SDL. I do not know it well enough to give a more informed opinion but what I said about SDL will most probably also apply to SFML.
In the past I have failed to detect mouse events in GNAT Ada and I am sure I will need to get on top of that - in fact if I could, I would probably manage to control the line but doing it over an existing image is beyond me.
HID event processing is handled by whatever GUI library you use. If you use SDL, you'll get mouse events from SDL; if you use GTK, you'll get mouse events from GTK, and so on.

Struggling with 2d platforms physics

Im making a game in Rust(Im a beginner) for my son and am somehow struggling with platforms - specifically modifying their length. I can get the platforms if i use certain numbers but if i try to modify the platform width I run into problems.
If i use the const PLATFORM_WIDTH=400 then everything works fine (i seemingly can make any number of them and it all works), but I don't want to have platforms of a fixed width (length), I want each platform to be of variable width. If I try to make the platform width say 100.0 then it is rendered correctly but I can walk over empty space as if there was a platform there. If I make them greater than 400 they are rendered but the sprite will fall through solid floor at some points.
Really don't know where Im going wrong and this annoying issue is preventing me from making progress on my game.
Id really appreciate if someone could take a look at my code and tell me where im going wrong.
My code is here:
https://github.com/country-bumpkin-software/rusty-miner/blob/main/src/main.rs
Also can someone explain to me why the Rect function seems to take negative numbers for the x, y coords?
The problem is that you sometimes use the width from the platform struct (e.g. when checking for intersections on line 264) and sometimes use the PLATFORM_WIDTH and PLATFORM_WIDTH_HALF constants (e.g. when drawing the platform on line 346).

The image seems no so clear in openseadragon as its origin

I use openseadragon show arts in my web site, but they seem not so clear as its origin. (I do not have so much reputation to post snapshots):
The original one is sharper, and the one rendered by openseadragonone is blurred.
I was thought that it caused by Deep Zoom Composer, which decreased quality when creating DZI image parts, but i was wrong. The part image in DZI directory and the original one are exactly same, and all of them are readered by a browser(IE 10).
Now the reasonable explaination is the randering type of openseadragon cause the difference, is this a bug? or is there an option / argument which can improve rendering effect in openseadragon?
Two possible issues here. Are you on an HDPI (i.e. "retina") screen? If so, there is a bug fix in master that's not on the latest release yet.
Otherwise, it's probably the minPixelRatio. By default OpenSeadragon allows the image to not be entirely full resolution at some zoom levels, to save on bandwidth. You can modify this value by passing minPixelRatio: 1 as one of the options when you create your viewer (the default value is 0.5).
We can continue the discussion in the issue here: https://github.com/openseadragon/openseadragon/issues/646

How do I alter the stroke width along a path/line?

Having read the SVG2 draft, I am slightly disappointed to learn that there will be no new line caps than the standard 3. The new arc line join is brilliant however, but not what this question is about (I just wanted to mention that).
I had been hoping for a cap that ends in a triangle. But given my use case, that might not be ideal either.
As far as I can gather, Adobe Illustrator - which I do not use myself - allows the width of a stroke to be variable. This is useful when drawing from a drawing tablet, to highlight the pressure of the lines. It's true, this functionality exists in many bitmap drawing programs, but is there a way to achieve this effect in SVG, without having to draw multiple lines?
The idea is that each node should have a width, and the lines should then 'smoothly' scale the width between each node that had a different width.
Is this possible? And if not, could it be considered?
P.S. I should point out, that this is more a thought experiment and an idea than something that hinders my process. More of a nice to have than need to have.
While this may not be a true answer (SVG standard wise at least), it turns out that in the current trunk version of Inkscape, this feature called PowerStroke already exists. There are some screenshots of PowerStroke.
This should satisfy my quest for the time being.
It turns out - as well - that the arc line joins was actually suggested by Inkscape as well, they are just called extrapolate in Inkscape.

Advanced gnuplot terminals and softwares

I am definitely puzzled by the capabilities of the existing terminals for gnuplot (wxt, ...). It's quite impossible to edit quickly the chart on the interface (change color of one curve, hide one curve, export in eps with the current rendering (without switching terminals) etc...).
The "windows" term has some nice feature (linestyle editing, etc...) but I am still waiting for something more "complete".
Some operations like "hiding a line" are non-intuitive for the gnuplot command language (actually the only solution that I know is to rewrite the plot command) and that's why I am looking for a terminal that will leverage some specific intermediate representation of the plotted object to allow the user to change quickly the design.
Do you have any information about this kind of tools ?
Note: I can't post more than two links because I'm a new-ish user here...
A quick search reveals several (probably abandoned) projects with similar parity to what you're asking for:
UniGNUPlot -Graphic GNUPlot front-end, last update in 2009-07-17
JAVA gnuplot GUI, last update in 2010-04-19
XGFE, last known update in 1999-01-01 and probably best avoided due to its age...
Honestly, I'd recommend something like QtiPlot (which also has the advantage of being cross platform) which is your typical "data analysis and scientific visualisation solution". I know it's not of the same paradigm as gnuplot, but it's easy to use.
If you would insist on using gnuplot as the backend, then an interesting perl wrapper called gplot (search sourceforge) exists that you can call from the command line. From the website, the syntax seems straightforward
# plot 3 sets of data, specify colors and points
gplot.pl -color green -point uptriangle 1a.data \
-color blue -point box 2a.data \
-color green -point circle 3a.data
but again, this is quite dated (last update 2009-07-17).
The major issue for these older gnuplot front ends is that gnuplot had a change of syntax for a few features (such as line color and style) a few years ago. I can't seem to find the precise version at which it changed at the moment, but the change did happen. Depending on how willing you are to change the source code of these wrappers, I do not imagine much tweaking would be needed.

Resources