Circular draggable UI element in Unity canvas

I am trying to implement my own runtime color picker that’s easy to use for touch interfaces. I want the hue slider to be a ring, along these lines, except the whole ring texture would rotate when dragged.

I have scavenged enough code to get a raw image object rotating when dragged in a UI canvas in the manner I’m looking for:

    private float baseAngle;     private Vector2 pos;          public void OnBeginDrag(PointerEventData eventData)     {         pos = transform.position;         pos = eventData.pressPosition - pos;         baseAngle = Mathf.Atan2(pos.y, pos.x) * Mathf.Rad2Deg;         baseAngle -= Mathf.Atan2(transform.right.y, transform.right.x) * Mathf.Rad2Deg;     }      public void OnDrag(PointerEventData eventData)     {         pos = transform.position;         pos = eventData.position - pos;         float ang = Mathf.Atan2(pos.y, pos.x) * Mathf.Rad2Deg - baseAngle;         transform.rotation = Quaternion.AngleAxis(ang, Vector3.forward);     } 

Since it doesn’t use colliders, how can I limit the draggable region to a circle within the square bounds of the texture? Even better, also limit it to a ring rather than a whole circle. Will I have to implement my own check based on some pure math or is there a built in way?


add another html tag after li element in wp_nav_menu

I have a nav menu in footer. I just want to display it side by a <p> tag, I mean something like this

<ul> <li> <p>copyright C 2021</p> </li> <li> contact </li> <li> blog </li> </ul> 

this is my menu function

if ( function_exists( 'register_nav_menus' ) ) {     register_nav_menus(         array(           'top_nav_menu' => 'My Footer Menu'         )     ); 

and I’m calling it in footer

<?php if ( has_nav_menu( 'top_nav_menu' ) ) { ?>             <?php wp_nav_menu( array(                 'menu' => 'Footer Navigation Menu',                  'theme_location' => 'top_nav_menu',                  'menu_class' => 'footer-links'                 ));              ?>             <?php } else {?>             <ul class="sf-menu">                 <?php wp_list_pages( array('title_li' => '','sort_column' => 'menu_order')); ?>             </ul>             <?php } ?> 

How can I insert an extra <li> element just before its first <li> and add a <p> tag between that later added <li> element?

What element would Genasi children of mixed element parentage have?

Two of the players in my campaign are Genasi, who are expecting a child. I’m doing research into Genasi’s for this new side plot. Although I’m not sure what element(s) they would have.

One parent is a water genasi, while the other is an air genasi. So would the child have both air and water, only one, or some combination of both?

I’ve researched but I haven’t been able to find a solid answer, most I’m getting is linked back to para and quasi-genasi, but that doesn’t answer the question either.

Any information would be useful and very helpful.

I’m running a 5th Edition campaign, that uses older lore as well as current lore.

insert an HTML element if there is a submenu only

I am trying to insert an HTML element "an arrow or a checkbox" to make use of the "checkbox technique" so I can use it to expand the submenu "only if submenu is there" when checked. my question is: how to insert this HTML element if there is a "sub-menu" class only or only when the list < li> has a class "menu-item-has-children" then insert this HTML element.

I have tried to hook on 2 filters: nav_menu_css_class and wp_nav_menu_items but didn’t succeed.

I have also tried to add this element when calling the menu:

wp_nav_menu(array(  'theme_location' => 'main-menu',  'depth'          => 0,  'menu_class'     => 'topNav-List',  'menu_id'        => 'topNL',  'after'          => ' <label for="dropDown" class="btn-dropdown"></label>                        <input class="dropdown-open" type="checkbox" id="dropDown"/>                        <label for="dropDown" class="dropdown-overlay"></label>' )); 

but it will add this checkbox to all list items, which I don’t want at all.

Difference between shader input element classification between D3D12 and Vulkan

I’m confused about the difference between the shader input element classifications in D3D12 and Vulkan. For example, in Vulkan I could have the following declarations:

struct vertex {     glm::vec3 pos;     glm::vec3 col; };  VkVertexInputBindingDescription input_binding_description {     .binding = 0,     .stride = sizeof(vertex),     .inputRate = VK_VERTEX_INPUT_RATE_VERTEX };  std::array<VkVertexInputAttributeDescription, 2> input_attribute_descriptions {     VkVertexInputAttributeDescription{         .location = 0,         .format = VK_FORMAT_R32G32B32_SFLOAT,         .offset = offsetof(vertex, pos)     },         VkVertexInputAttributeDescription{         .location = 1,         .format = VK_FORMAT_R32G32B32_SFLOAT,         .offset = offsetof(vertex, col)     } }; 

Here the input rate is specified per vertex and not per attribute. On the other hand, in D3D12, we would have

struct Vertex {     XMFLOAT3 pos;     XMFLOAT3 col; };  std::array<D3D12_INPUT_ELEMENT_DESC, 2> input_element_descs = {     { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,     D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },     { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12,     D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } }; 

And as you can see, the input rate is specified per attribute. Why is that? Is there a difference between the meaning of the input classification in D3d12 and Vulkan that I’m missing? I’m not familiar with D3D12, but at first glance, it doesn’t make sense to me to have different input classifications for the attributes of a vertex.

How do I add a div class to the posts in a filter and not the entire filter element?

I am having some troubles with the Isotope filter gallery, as discussed in my Stackoverflow question here.

As per the first point of the accepted answer, I need to add the class .isotope, to the parent (the .row element) to make it work with URL hashes. Otherwise, it only works when you click on the filter links, as you can try on the live webpage.

Here is the element to which the user told me to add the class:

<div class="isotope row masonry" data-masonry-id="d2546a5a8aed79adf8c0b3b78a16b29f" style="position: relative; height: 969.6px;">

Notice the <div class ="isotope before row masonry bit? That is what I need to add.

However, I can only apply a custom class to the entire Posts element in Elementor. If I do that, it causes the JS to think that it needs to sort the whole grid itself and makes it disappear.

How do I target this specific row element?

Finding the most frequent element, given that it’s Theta(n)-frequent?

We know [Ben-Or 1983] that deciding whether all elements in an array are distinct requires $ \Theta(n \log(n))$ time; and this problem reduces to finding the most frequent element, so it takes $ \Theta(n \log(n))$ time to find the most frequent element (assuming the domain of the array elements is not small).

But what happens when you know that there’s an element with frequency at least $ \alpha \cdot n$ ? Can you then decide the problem, or determine what the element is, in linear time (in $ n$ , not necessarily in $ 1/\alpha$ ) and deterministically?

Randomly assign n elements to n agents such that each agent only knows its own element


I’m working on an app that involves shuffling and distributing playing cards to players. As a challenge, I tried to solve this problem in a way that doesn’t require a trusted intermediary.

In other terms, the task is to find a distributed algorithm that

  • uniquely assigns $ n$ agents numbers $ 1..n$
  • allows each agent to know nothing about the assignment but its own
  • when revealing the assignment, allows other players to verify the assignment

We also assume that knowing other’s assignment is an advantage for each agent, and revealing its own prematurely a disadvantage. Agents are also assumed to be able to talk with each other in a way hidden from all other agents.

Partial solution

The solution I came up with works only under the assumption that adversaries do not collaborate.

The idea is to create a set of $ n$ nonces, and assign each agent exactly one nonce. The set is then passed from agent to agent in an agreed upon order, hidden from all others, until each agent received the set exactly once. Each time an agent receives the set, it swaps its nonce with a new one, memorizes the new nonce, and confirms receival of the set to the others. This entire procedure is done twice, at which point, all agents have received the set at least once after all other agents swapped their nonces, making it impossible to recognize and hence map the nonces to the other agents.

When the last agent receives the set the second time, it shares it with everyone, and all agents confirm to the others that their nonce is contained in the set. The agents then assign a number to each nonce in the set based on an agreed upon random seed, giving us the required unique assignment.

To allow ownership verification, instead of the nonces, agents put the hash value of their nonce on the set, revealing the actual nonce only when verification is required.

The problem with this solution is that if adversaries are allowed to collaborate, each time an adversary receives the set, they can compare their versions, identify changes and potentially derive which nonce belongs to other agents, allowing them to know what number got assigned to them.

All ideas are appreciated!