Skip to main content

Posts

OpenGL clear sprite

I created 10 sprites on the window and now I want to clear only one sprite out of 10 sprites. Now the function glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) clears the entire window of sprites, but I don't want to clear the entire window of drawn sprites. What function should I use to clear just one sprite and not clear the whole window and redraw 9 sprites in the window? by Evil JuniorCplusplus in StackOverflow on July 05, 2022 . Answer There is no such feature. Clear the screen, and redraw 9 sprites. Most computer games with moving objects clear the screen every single frame. by user253751 on July 05, 2022 .

Calling a common method of tuple elements

Say I have a tuple of types T1,...,TN that implement some method, apply() . How do I define a function that takes this tuple and some initial element, and returns the chained call of apply() on this element? For example: template <typename... Args, typename Input> auto apply(std::tuple<Args...> const &tpl, Input x) { // return ??? } // simple example struct Sqr { static int apply(int x) { return x * x; } }; enum class Choice { One, Two, }; struct Choose { static int apply(Choice choice) { switch (choice) { case Choice::One: return 1; case Choice::Two: return 2; } } }; void test() { auto tpl = std::tuple(Sqr{}, Choose{}); assert(apply(tpl, Choice::One) == 1); assert(apply(tpl, Choice::Two) == 4); } I tried to use fold expressions , and variations of answers from: Template tuple - calling a function on each element but couldn't get anything to compile. The main difference is that I need each invocation...

Convert jquery ajax to fetch

Does someone knows jquery and can help me convert this ajax to js fetch ? Unfortunately, I don't know jquery and I need to convert this into js fetch. function ajaxLogoutDetailsApi() { $.ajax({ type: "GET", url: "OIDCGetLogoutDetails", async: false, cache: false, data: "json", success: function (data, status, xhr) { data = data.replace('\/\*', ''); data = data.replace('\*\/', ''); var dataJson = JSON.parse(data); if (dataJson.logoutUrl != null) { document.location.href = dataJson.logoutUrl; } }, error: function (xhr, status, err) { console.log("error in ajaxLogoutDetailsApi"); } }); } Appreciate every hint. by Christian10 in StackOverflow on July 04, 2022 . Answer I was going to use async/await but since there's that odd replacing before the JSON gets parsed I've reve...

How do I multiply values within id and display answer?

How do multiply each value in the div with class="crtTotal" and have a div output that displays the answer: for example 1.75 x 3.65 x 2.10 = 13.41 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="box" class="boxlit"> <div class="box" data-id="75">Weston Bears - Cooks Hill United <br>Home <div class="crtTotal">1.75</div> </div> <div class="box" data-id="79">Logan Lightning - Brisbane City <br>Draw <div class="crtTotal">3.65</div> </div>...

svg clipPath using absolute points instead of percentages

I want to use clipPath for an image I'm trying to display on my webpage, and I want to be able to use percentages instead of absolute points with polygon . I've tried adding the viewBox attribute to my svg element to do so (suggested here SVG polygon points with percentage units support ), but when the image renders, it looks like absolute points are still being used. I have my html setup like this: <img class="clip-svg" src="{% static 'myApp/images/random.png' %}"> <div id="svg-container" style="width:100%; height:100%;"> <svg width='100%' height='100%' viewBox="0 0 100 100"> <defs> <clipPath id="myClip"> <polygon points="89,0 100,50 89,100 71,100 83,50 69,0"/> <polygon points="53,0 75,50 59,100 48,100 64,50 41,0" /> </clipPath> </defs> </svg> </div> With the CSS being: ...

Remove specific tag with its contents using sed

I would like to remove following tag from HTML including its constantly varying contents: <span class="the_class_name">li4tuq734g23r74r7Whatever</span> A following BASH script .... | sed -e :a -re 's/<span class="the_class_name"/>.*</span>//g' > "$NewFile" ends with error sed: -e expression #2, char XX: unknown option to `s' I tried to escape quotes, slashes and "less than" symbols in various combinations and still get this error. by Paul in StackOverflow on July 05, 2022 . Answer I suggest using a different sed separator than / when / is contained within the thing you want to match on. Also, prefer -E instead of -r for extended regex to be Posix compatible. Also note that you have a / in your first span in your regex that doesn't belong there. Also, .* will make it overly greedy and eat up any </span> that follows the first </...

Incorrect RectF On Canvas Created From Composable

I'm trying to highlight a view by grabbing the layoutCoordinate from a Box using .onGloballyPositioned . I receive the following coordinates: val viewLeft = layoutCoordinates.boundsInWindow().left val viewTop = layoutCoordinates.boundsInWindow().top val viewRight = layoutCoordinates.boundsInWindow().right val viewBottom = layoutCoordinates.boundsInWindow().bottom When I try to create a highlight with this code, it is always off by a bit: canvas.drawRoundRect( viewLeft, viewTop, viewRight, viewBottom, cornerRadius, cornerRadius, paint) This is the result that I am getting: Any idea what I may be doing incorrect? Thanks! by Ilyas Saleem Khurshid in StackOverflow on July 05, 2022 . Answer layoutCoordinates.boundsInWindow() adds status bar height to coordinate. You should use layoutCoordinates.boundsInParent() to get a Composable coordinates relative to its parent's top left corner. For instance this example Column(mod...