opengl – Stencil not working processing

With jogamp I can create the following stencil:

enter image description here

package help;

import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.awt.GLCanvas;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.glu.GLU;

public class Mask_Jogamp {


static class Rect {
    float x, y, w, h;
    ArrayList<Rect> children = new ArrayList<Rect>();
    Rect parent;
    int mask_depth;
    Rect(Rect parent, float x, float y, float w, float h) {
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        if (parent != null) {
            this.parent = parent;
            this.mask_depth = parent.mask_depth + 1;
            parent.children.add(this);
        }
    }
}    


Rect current_rect;

GL2 gl;

public static void main(String() args) {
    Mask_Jogamp app = new Mask_Jogamp();
    app.start();
}


void start() {

    // will have a depth of 0, equal to the stencil buffer after a clear
    current_rect = new Rect(null, 0, 0, 640, 480);

    GLProfile glprofile = GLProfile.getDefault();
    GLCapabilities glcapabilities = new GLCapabilities(glprofile);
    glcapabilities.setStencilBits(8);

    final GLCanvas glcanvas = new GLCanvas(glcapabilities);

    glcanvas.addGLEventListener( new GLEventListener() {
        
        @Override
        public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) {

            gl = glautodrawable.getGL().getGL2();

            gl.glMatrixMode( GL2.GL_PROJECTION );
            gl.glLoadIdentity();
    
            // coordinate system origin at lower left with width and height same as the window
            GLU glu = new GLU();
            glu.gluOrtho2D( 0.0f, width, 0.0f, height );
    
            gl.glMatrixMode( GL2.GL_MODELVIEW );
            gl.glLoadIdentity();
    
            gl.glViewport( 0, 0, width, height );
        }
        
        @Override
        public void init( GLAutoDrawable glautodrawable ) {
        }
        
        @Override
        public void dispose( GLAutoDrawable glautodrawable ) {
        }
        
        @Override
        public void display( GLAutoDrawable glautodrawable ) {

            int width = glautodrawable.getSurfaceWidth();
            int height = glautodrawable.getSurfaceHeight();
            
            gl.glEnable(GL.GL_STENCIL_TEST);
            gl.glClearStencil(0x0);

            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            gl.glLoadIdentity();


            begin_mask(100, 100, 400, 400); // A
            gl.glColor3f(1, 0, 0);
            rect(100, 100, 400, 400);

                begin_mask(50, 150, 500, 100); // B
                gl.glColor3f(0, 1, 0);
                rect(50, 150, 500, 100);

                    begin_mask(200, 50, 100, 500); // C
                    gl.glColor3f(0, 0, 1);
                    rect(200, 50, 100, 500);
                    end_mask(); // C

                end_mask(); // B

            end_mask(); // A

        }
    });

    final Frame frame = new Frame( "One Triangle AWT" );
    frame.add( glcanvas );
    frame.addWindowListener( new WindowAdapter() {
        public void windowClosing( WindowEvent windowevent ) {
            frame.remove( glcanvas );
            frame.dispose();
            System.exit( 0 );
        }
    });

    frame.setSize( 640, 480 );
    frame.setVisible( true );
}



void rect(float x1, float y1, float w, float h) {

    float x2 = x1 + w;
    float y2 = y1 + h;

    gl.glBegin(GL2.GL_QUADS);
    gl.glVertex2f(x1, y1);
    gl.glVertex2f(x2, y1);
    gl.glVertex2f(x2, y2);
    gl.glVertex2f(x1, y2);
    gl.glEnd();
}


void begin_mask(float x, float y, float w, float h) {
    current_rect = new Rect(current_rect, x, y, w, h);
    gl.glColorMask(false, false, false, false);
    gl.glDepthMask(false);
    // we want to write to the stencil buffer
    gl.glStencilMask(0xff);
    // we pass if the value in the stencil buffer is equal to the depth of the
    // parent of the current_rect
    gl.glStencilFunc(GL2.GL_EQUAL, current_rect.parent.mask_depth, 0xFF);
    int action_if_stencil_test_fails = GL2.GL_KEEP;
    int action_if_stencil_test_passes_but_depth_pass_fails = GL2.GL_KEEP;
    // we increment, so the stencil value in the buffer get's equal
    // to the mask_depth of the current_rect
    int action_if_both_the_stencil_and_depth_pass_succeed = GL2.GL_INCR;

    gl.glStencilOp(
        action_if_stencil_test_fails,
        action_if_stencil_test_passes_but_depth_pass_fails,
        action_if_both_the_stencil_and_depth_pass_succeed
    );

    // now it should increment the value by one for only the part that is inside the part
    // of current_rect.parent
    rect(x, y, w, h);
    enable_normal_draw_mode();
}


void end_mask() {
    // decrement stencil mask as if we never existed
    gl.glStencilMask(0xff);
    gl.glStencilFunc(GL2.GL_EQUAL, current_rect.mask_depth, 0xff);
    gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_DECR);
    gl.glColorMask(false, false, false, false);
    gl.glDepthMask(false);
    rect(current_rect.x, current_rect.y, current_rect.w, current_rect.h);
    current_rect = current_rect.parent;
    enable_normal_draw_mode();
}


void enable_normal_draw_mode() {
    gl.glStencilMask(0x00);

    // for normal drawing, we only wan't to be able to draw where
    // the stencil value in the buffer is equal to the mask_depth
    // of the current_rect
    gl.glStencilFunc(GL2.GL_EQUAL, current_rect.mask_depth, 0xff);
    gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_KEEP);
    gl.glColorMask(true, true, true, true);
    gl.glDepthMask(true);
}


}

Using processing I get this:

enter image description here

package help;

import java.util.ArrayList;
import com.jogamp.opengl.*;
import processing.core.PApplet;
import processing.opengl.PGL;

public class Mask_P5 extends PApplet {

public static void main(String() args) {
    PApplet.main(Mask_P5.class, args);
}


PGL pgl;
GL2 gl;


Rect current_rect;

public void settings() {
    size(600, 600, P3D);
}


public void setup() {

    println(PGL.GEQUAL);
    
    noStroke();
    
    // will have a depth of 0, equal to the stencil buffer after a clear
    current_rect = new Rect(null, 0, 0, 640, 480);
}

static class Rect {
    float x, y, w, h;
    ArrayList<Rect> children = new ArrayList<Rect>();
    Rect parent;
    int mask_depth;
    Rect(Rect parent, float x, float y, float w, float h) {
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
        if (parent != null) {
            this.parent = parent;
            this.mask_depth = parent.mask_depth + 1;
            parent.children.add(this);
        }
    }
}    



public void draw() {
    
    
    pgl = beginPGL();

    // gl = ((PJOGL)pgl).gl.getGL2(); // Not a GL2 implementation
    // gl = ((PJOGL)pgl).gl.getGL3bc(); // Not a GL3bc implementation
    // gl = ((PJOGL)pgl).gl.getGL4bc(); // Not a GL4bc implementation
    // etc. I tried all, either an error, or a grey screen and opengl silently failing


    pgl.enable(PGL.STENCIL_TEST);
    pgl.clearStencil(0x0);
    pgl.clear(PGL.STENCIL_BUFFER_BIT);

    background(0);
    
    begin_mask(100, 100, 400, 400); // A
    fill(255,0,0);
    rect(100, 100, 400, 400);

        begin_mask(50, 150, 500, 100); // B
        fill(0,255,0);
        rect(50, 150, 500, 100);

            begin_mask(200, 50, 100, 500); // C
            fill(0,0,255);
            rect(200, 50, 100, 500);
            end_mask(); // C

        end_mask(); // B

    end_mask(); // A
    
    endPGL();
}



void begin_mask(float x, float y, float w, float h) {
    current_rect = new Rect(current_rect, x, y, w, h);
    pgl.colorMask(false, false, false, false);
    pgl.depthMask(false);
    // we want to write to the stencil buffer
    pgl.stencilMask(0xff);
    // we pass if the value in the stencil buffer is equal to the depth of the
    // parent of the current_rect
    pgl.stencilFunc(PGL.EQUAL, current_rect.parent.mask_depth, 0xFF);
    int action_if_stencil_test_fails = PGL.KEEP;
    int action_if_stencil_test_passes_but_depth_pass_fails = PGL.KEEP;
    // we increment, so the stencil value in the buffer get's equal
    // to the mask_depth of the current_rect
    int action_if_both_the_stencil_and_depth_pass_succeed = PGL.INCR;

    pgl.stencilOp(
        action_if_stencil_test_fails,
        action_if_stencil_test_passes_but_depth_pass_fails,
        action_if_both_the_stencil_and_depth_pass_succeed
    );

    // now it should increment the value by one for only the part that is inside the part
    // of current_rect.parent
    // gl_rect(x, y, w, h);
    rect(x, y, w, h);
    enable_normal_draw_mode();
}


void end_mask() {
    // decrement stencil mask as if we never existed
    pgl.stencilMask(0xff);
    pgl.stencilFunc(PGL.EQUAL, current_rect.mask_depth, 0xff);
    pgl.stencilOp(PGL.KEEP, PGL.KEEP, PGL.DECR);
    pgl.colorMask(false, false, false, false);
    pgl.depthMask(false);
    // gl_rect(current_rect.x, current_rect.y, current_rect.w, current_rect.h);
    rect(current_rect.x, current_rect.y, current_rect.w, current_rect.h);
    current_rect = current_rect.parent;
    enable_normal_draw_mode();
}


void enable_normal_draw_mode() {
    pgl.stencilMask(0x00);

    // for normal drawing, we only wan't to be able to draw where
    // the stencil value in the buffer is equal to the mask_depth
    // of the current_rect
    pgl.stencilFunc(PGL.EQUAL, current_rect.mask_depth, 0xff);
    pgl.stencilOp(PGL.KEEP, PGL.KEEP, PGL.KEEP);
    pgl.colorMask(true, true, true, true);
    pgl.depthMask(true);
}



void gl_rect(float x1, float y1, float w, float h) {

    float x2 = x1 + w;
    float y2 = y1 + h;

    gl.glBegin(GL2.GL_QUADS);
    gl.glVertex2f(x1, y1);
    gl.glVertex2f(x2, y1);
    gl.glVertex2f(x2, y2);
    gl.glVertex2f(x1, y2);
    gl.glEnd();
}

}

I made a repository as well that contains a jar compiled with the sources so It’s more easy to step threw using a debugger.

https://github.com/clankill3r/opengl_stencil_not_working_in_p5

networking – Ubuntu 16.04 wired internet stopped working

I’m having a dual boot machine, with windows and ubuntu 16.04. Today I switched back to ubuntu after few days. I saw that I can’t connect to wired internet anymore. I was using static connection (dhcp was never working for me). I have exactly the same address, gate and mask as in windows (the connection works smoothly on windows). It shows that I’m connected to the network but I can’t ping the gate (router). Any idea where to look for the problem? I’m a beginner with linux. Thanks!

macos – pyglet not working in macbook

I have installed pyglet using terminal in my mac for python 3.8
Bt it isn’t working
By that i mean when i type pyglet.font.add_file('DIN Next W01 Light.ttf')
to add that font into my file it shows an error

No idea what the error is about

It runs perfectly in windows bt in mac it shows error

2020-08-13 03:35:27.643 Python(15910:1241698) -(NSApplication _setup:): unrecognized selector sent to instance 0x7f89a069bca0
2020-08-13 03:35:27.646 Python(15910:1241698) *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-(NSApplication _setup:): unrecognized selector sent to instance 0x7f89a069bca0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff362dbb57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff6ef895bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3635abe7 -(NSObject(NSObject) __retain_OA) + 0
    3   CoreFoundation                      0x00007fff362403bb ___forwarding___ + 1427
    4   CoreFoundation                      0x00007fff3623fd98 _CF_forwarding_prep_0 + 120
    5   libtk8.6.dylib                      0x0000000109e461f2 TkpInit + 408
    6   libtk8.6.dylib                      0x0000000109db5aac Initialize + 2454
    7   _tkinter.cpython-37m-darwin.so      0x0000000109c17dc4 Tcl_AppInit + 84
    8   _tkinter.cpython-37m-darwin.so      0x0000000109c17a98 _tkinter_create + 1144
    9   Python                              0x00000001098ef4ee _PyMethodDef_RawFastCallKeywords + 430
    10  Python                              0x00000001098eea5a _PyCFunction_FastCallKeywords + 42
    11  Python                              0x00000001099ad5a4 call_function + 724
    12  Python                              0x00000001099aa576 _PyEval_EvalFrameDefault + 25190
    13  Python                              0x00000001099ae0d6 _PyEval_EvalCodeWithName + 2422
    14  Python                              0x00000001098ee5fb _PyFunction_FastCallDict + 523
    15  Python                              0x00000001098ef8cf _PyObject_Call_Prepend + 143
    16  Python                              0x000000010993dd51 slot_tp_init + 145
    17  Python                              0x00000001099396a9 type_call + 297
    18  Python                              0x00000001098ee871 _PyObject_FastCallKeywords + 433
    19  Python                              0x00000001099ad474 call_function + 420
    20  Python                              0x00000001099aa617 _PyEval_EvalFrameDefault + 25351
    21  Python                              0x00000001099ae0d6 _PyEval_EvalCodeWithName + 2422
    22  Python                              0x00000001099a4234 PyEval_EvalCode + 100
    23  Python                              0x00000001099e18f1 PyRun_FileExFlags + 209
    24  Python                              0x00000001099e116a PyRun_SimpleFileExFlags + 890
    25  Python                              0x0000000109a009db pymain_main + 6875
    26  Python                              0x0000000109a00f2a _Py_UnixMain + 58
    27  libdyld.dylib                       0x00007fff70131cc9 start + 1
    28  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
```/Users/mananvyas/PycharmProjects/pythonProject/venv/bin/python "/Users/mananvyas/PycharmProjects/pythonProject/QUIZ PROJECT/FINAL PROJECT.py"
2020-08-13 03:35:27.518 Python(15910:1241698) ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
2020-08-13 03:35:27.643 Python(15910:1241698) -(NSApplication _setup:): unrecognized selector sent to instance 0x7f89a069bca0
2020-08-13 03:35:27.646 Python(15910:1241698) *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-(NSApplication _setup:): unrecognized selector sent to instance 0x7f89a069bca0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff362dbb57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff6ef895bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3635abe7 -(NSObject(NSObject) __retain_OA) + 0
    3   CoreFoundation                      0x00007fff362403bb ___forwarding___ + 1427
    4   CoreFoundation                      0x00007fff3623fd98 _CF_forwarding_prep_0 + 120
    5   libtk8.6.dylib                      0x0000000109e461f2 TkpInit + 408
    6   libtk8.6.dylib                      0x0000000109db5aac Initialize + 2454
    7   _tkinter.cpython-37m-darwin.so      0x0000000109c17dc4 Tcl_AppInit + 84
    8   _tkinter.cpython-37m-darwin.so      0x0000000109c17a98 _tkinter_create + 1144
    9   Python                              0x00000001098ef4ee _PyMethodDef_RawFastCallKeywords + 430
    10  Python                              0x00000001098eea5a _PyCFunction_FastCallKeywords + 42
    11  Python                              0x00000001099ad5a4 call_function + 724
    12  Python                              0x00000001099aa576 _PyEval_EvalFrameDefault + 25190
    13  Python                              0x00000001099ae0d6 _PyEval_EvalCodeWithName + 2422
    14  Python                              0x00000001098ee5fb _PyFunction_FastCallDict + 523
    15  Python                              0x00000001098ef8cf _PyObject_Call_Prepend + 143
    16  Python                              0x000000010993dd51 slot_tp_init + 145
    17  Python                              0x00000001099396a9 type_call + 297
    18  Python                              0x00000001098ee871 _PyObject_FastCallKeywords + 433
    19  Python                              0x00000001099ad474 call_function + 420
    20  Python                              0x00000001099aa617 _PyEval_EvalFrameDefault + 25351
    21  Python                              0x00000001099ae0d6 _PyEval_EvalCodeWithName + 2422
    22  Python                              0x00000001099a4234 PyEval_EvalCode + 100
    23  Python                              0x00000001099e18f1 PyRun_FileExFlags + 209
    24  Python                              0x00000001099e116a PyRun_SimpleFileExFlags + 890
    25  Python                              0x0000000109a009db pymain_main + 6875
    26  Python                              0x0000000109a00f2a _Py_UnixMain + 58
    27  libdyld.dylib                       0x00007fff70131cc9 start + 1
    28  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

And if i try to run it in IDLE it just shows this
enter image description here

Plzz help me out in this

There is no syntax error as it runs perfectly in windows

Thanks in advance

plugins – Custom field widget with User Entity Reference – Not working

I have created a custom field and custom field widget. The field widget is to have an entity_reference to user field. Upon saving the value is never saved. I see the following error when I try to add a user.

The default_property has to be an entity object

Custom field:

    class BigEventSubscription extends FieldItemBase {

      /**
       * {@inheritdoc}
       */
      public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
      {
        // Prevent early t() calls by using the TranslatableMarkup.
        $properties('user_id') = DataDefinition::create('integer')
          ->setLabel(new TranslatableMarkup('Subscriber'))
    //      ->setSetting('unsigned', TRUE)
          ->setRequired(false);
    
        return $properties;
      }
    
      /**
       * {@inheritdoc}
       */
      public static function schema(FieldStorageDefinitionInterface $field_definition)
      {
        return (
          'columns' => (
            'user_id' => (
              'type' => 'int',
              'not null' => true,
              'unsigned' => true,
            ),
          ),
        );
      }
    
      /**
       * {@inheritdoc}
       */
      public function isEmpty()
      {
        $isEmpty =
          empty($this->get('user_id')->getValue());
    
        return $isEmpty;
      }
    
    }

Custom Field Widget:

class BigEventSubscriptionWidget extends WidgetBase {

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

   

    $element('subscriber') = (
      '#type' => 'entity_autocomplete',
      '#title' => 'Subscriber',
      '#target_type' => 'user',
      '#default_value' => isset($items($delta)->user_id) ?? $items($delta)->user_id,
      '#attributes' => ('class' => ('details-wrapper')),
      '#weight' => 1,
    );

   
  

    return $element;
  }

  
}

I would appreciate any help.

magento2 – Magento 2.3.5-p2 Image Uploader not Working

When I attempt to upload an image to Magento 2, I click the option in the toolbar and when I attempt to browse for the file I am taken to a blank white screen and do not see any browser information to choose my file. I recently attempted to upgrade from Magento 2.3.5-p1 to 2.4. However when I realized I needed ElasticSearch 7 I then downgraded to 2.3.5-p2. I am not sure if this is related to my problem or no.

google apps script – not working form submit Event Object

I have a Google form which I use to populate a Google docs from a certain template whenever a new response is submitted. In order to achieve this, I have written this script, but it is not working and showing this error TypeError: Cannot read property 'values' of undefined (line 3, file "Code"):

function createdocs(e) {

  var Contracttype = e.values(1);
  var Partnername = e.values(2);
  var Bankname = e.values(3);
  var Accountnumber = e.values(4);
  var TIN = e.values(5);
  var Bankcode = e.values(6);
  var Businesscode = e.values(7);
  var Phone = e.values(8);
  var Director = e.values(9);
  var Contractstartingdate = e.values(10);
  var Contractendingdate = e.values(11);
  var EmailAddress = e.values(12);

  var file = DriveApp.getFileById('10lZQhmbocTOmvGwklYnHNvXbdGXDmpbgFbvcnu67G7c'); 
  var folder = DriveApp.getFolderById('1O6QJZ5gRRoSUeolcVvKlMe65Wdb4rz9z')
  var copy = file.makeCopy(Partnername + ',' + Contractstartingdate, folder); 
  var doc = DocumentApp.openById(copy.getId()); 
  var body = doc.getBody(); 

  body.replaceText('{{Partner name}}', Partnername);  
  body.replaceText('{{Bank name}}', Bankname);
  body.replaceText('{{Account number}}', Accountnumber);
  body.replaceText('{{TIN}}', TIN);
  body.replaceText('{{Bank code}}', Bankcode);
  body.replaceText('{{Business code}}', Businesscode);
  body.replaceText('{{Phone}}', Phone);
  body.replaceText('{{Director}}', Director);
  body.replaceText('{{Contract starting date}}', Contractstartingdate);
  body.replaceText('{{Contract ending date}}', Contractendingdate);

  doc.saveAndClose(); 
}

I have used a youtube tutorial for this purpose and followed every step, But I am failing, how to define values in the script, I have installed the onformSubmit trigger. But there is something going wrong Please help me with this out

enter image description here

api – Any way to better this program and is this project too simple to be working on(first project in python)?

This program will ask for user to insert summoner and base from the last 20 games of said summoner, it will give avg stats and see if good or not by wins in last 20 games(a simple grading system).

import requests
from getId import idcollect
from games import GAME
from wins import win_calc

#Key for riot API
Key = '**********************'

#ASKING USER FOR SUMMONER NAME
summonerName = input('Enter summoner name:')

#Objects
ids=idcollect()
game=GAME()
wins=win_calc()

#Collecting the acc id of summoner name
accId=ids.ID_collected(summonerName,Key)

#Collecting game id lists
game_list=()
game_list=game.find_game_ids(accId,Key)

#Collecting wins list
win_list=()
win_list=game.game_data(game_list,Key,summonerName)

#Calcuate whether the summoner is good or not
wins.is_dis_mane_good(win_list)






import requests


class GAME:


    def find_game_ids(self,accId,key):
        
        i=0
        GAMEID = ()
        Idgame=20       
        url_match_list=('https://na1.api.riotgames.com/lol/match/v4/matchlists/by-account/'+(accId)+'?queue=420&endIndex=20&api_key='+(key))
        response2=requests.get(url_match_list)
        #Adding 20 games into the list
        while Idgame>0:
            GAMEID.append('https://na1.api.riotgames.com/lol/match/v4/matches/'+str(response2.json()('matches')(i)('gameId'))+'?api_key='+(key))
            i=i+1
            Idgame=Idgame-1

        return GAMEID


    def game_data(self,game_list,key,sumName):

        wins=()
        deaths=()
        deaths= ()
        kills=()
        assists=()
        visions=()
        csTotal=()
        
        
        #Finding the data of said summoner in each game id
        for urls in game_list:

            
            response=requests.get(urls)
            Loop=0
            index=0
            while Loop<=10:
                
                if response.json()('participantIdentities')(index)('player')('summonerName')!=sumName:
                    Loop= Loop+1
                    index=index+1
                elif response.json()('participantIdentities')(index)('player')('summonerName')==sumName:
                    
                    deaths.append(response.json()('participants')(index)('stats')('deaths'))
                    kills.append(response.json()('participants')(index)('stats')('kills'))
                    assists.append(response.json()('participants')(index)('stats')('assists'))
                    visions.append(response.json()('participants')(index)('stats')('visionScore'))
                    csTotal.append(response.json()('participants')(index)('stats')('totalMinionsKilled'))
                    wins.append(response.json()('participants')(index)('stats')('win'))
                
                    break
        #Finding avg of each stat
        deaths=sum(deaths)/20            
        kills=sum(kills)/20
        assists=sum(assists)/20
        visions=sum(visions)/20
        csTotal=sum(csTotal)/20

        print('The avg kills is '+str(kills)+'nThe avg deaths is '+str(deaths)+'nThe avg assists is '+str(assists)+'nThe avg visions is '+str(visions)+'nThe avg cs total is '+str(csTotal))

        return wins







import requests

class idcollect:
    
    def ID_collected(self,sumName,key):
        #COLLECTING DATA TO BE INSERTING FOR MATCHLIST DATABASE
        url=('https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/'+(sumName)+'?api_key='+(key))
        response=requests.get(url)
        accId=(response.json()('accountId'))
        return accId






import random

class win_calc:


    def is_dis_mane_good(self,winlist):
        
        winlist=sum(winlist)/20

        if (winlist<.33):
            trash=('DIS MANE STINKS','run while you can','I repeat, YOU ARE NOT WINNING THIS','I predict a fat L','Have fun trying to carry this person','He is a walking trash can','He needs to find a new game','BAD LUCK!!!')
            print (random.choice(trash))

        elif (winlist>.33 and winlist<=.5):
            notgood=('Losing a bit','Not very good','He needs lots of help','Your back might hurt a little','Does not win much') 
            print (random.choice(notgood))

        elif (winlist>.5 and winlist<=.65):
            ight=('He is ight','He can win a lil','You guys have a decent chance to win','Serviceable','Should be a dub')
            print (random.choice(ight))

        elif (winlist>.65):
            good=('DUB!','You getting carried','His back gonna hurt a bit','winner winner chicken dinner','Dude wins TOO MUCH','You aint even gotta try','GODLIKE')
            print (random.choice(good))

libgdx – setTransform() Box2D physics not working

It’s my first time posting here!

I’m working on a top-down shooter game in LibGDX and Box2D (so gravity is set to (0, 0)). At the moment, to move my character, I’m using the setTransform() method. I understand it can be a bit buggy, but in past experiences the method worked fine and collisions were detected and handled.

Here’s an image of my character (DynamicBody) colliding with a static obstacle. Even using setTransform(), it should try to push the character outside of the box’s bounds? Bodies do not seem to be colliding.

Here’s my Player code. The Vector2 set as linearVelocity is not being used.

public class Player extends BodyHolder implements Disposable {

    private float speed = 2.3f;

    private Sprite sprite;
    private Vector3 position;
    private Vector2 linearVelocity;
    private Vector3 mousePos;

    private static final Vector2 SIZE = new Vector2(93, 84);

    private int playerPhase = 0, prevPlayerPhase = 0;

    private int ID;
    private boolean isMain = false;

    public Player(final Vector2 position, final WorldManager world) {
        super(world, position, new Vector2(SIZE.x / 2, SIZE.y / 2), BodyDef.BodyType.DynamicBody, 0.8f, false, -1);
    }

    public Player(int id, Vector2 pos, WorldManager world, boolean main) {
        super(world, pos, new Vector2(SIZE.x / 2, SIZE.y / 2), BodyDef.BodyType.DynamicBody, 0.8f, false, id);

        this.ID = id;
        this.position = new Vector3(pos.x, pos.y, 0);
        this.mousePos = new Vector3();
        this.isMain = main;

        linearVelocity = new Vector2();

        getBody().setFixedRotation(true);

        sprite = new Sprite(new Texture(Gdx.files.internal("player/player_nogun.png")));
        playerPhase = 1;
    }

    public void update(SpriteBatch batch, ModifiedShapeRenderer renderer, CameraController cam) {

        sprite.setCenter(position.x, position.y);
        getBody().setTransform(position.x, position.y, 0);
//        getBody().setLinearVelocity(linearVelocity);
        if(isMain()) this.handleInput(cam);

        if(prevPlayerPhase != playerPhase) {
            prevPlayerPhase = playerPhase;
            if(playerPhase == 1) {
                sprite = new Sprite(new Texture(Gdx.files.internal("player/player_nogun.png")));
                sprite.setOrigin(sprite.getOriginX() + 5, sprite.getOriginY());
            } else if(playerPhase == 2) {
                sprite = new Sprite(new Texture(Gdx.files.internal("player/player.png")));
            }
        }

        for(Gun gun : GunSpawner.getGuns()) {
            if(gun.obtainObject().getBoundingRectangle().overlaps(this.sprite.getBoundingRectangle())) {
                gun.hoverOver(this);
            }
        }

        batch.setProjectionMatrix(cam.getCamera().combined);
        batch.begin();
        sprite.draw(batch);
        batch.end();
    }

    public void handleInput(CameraController cam) {
        mousePos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
        cam.getCamera().unproject(mousePos);
        sprite.setRotation((float) (MathUtils.radiansToDegrees * Math.atan2((position.y - mousePos.y) , (position.x - mousePos.x))));

        boolean keyPressed = false;

        if(Gdx.input.isKeyPressed(Input.Keys.W)) {
            position.y += speed;
            linearVelocity.y = 100;
            keyPressed = true;
        }
        if(Gdx.input.isKeyPressed(Input.Keys.S)) {
            position.y -= speed;
            linearVelocity.y = -100;
            keyPressed = true;
        }
        if(Gdx.input.isKeyPressed(Input.Keys.A)) {
            position.x -= speed;
            linearVelocity.x = -100;
            keyPressed = true;
        }
        if(Gdx.input.isKeyPressed(Input.Keys.D)) {
            position.x += speed;
            linearVelocity.x = 100;
            keyPressed = true;
        }

        if(keyPressed) {
            keyPressed = false;
        } else {
            linearVelocity.set(0, 0);
        }

        if (Gdx.input.isKeyJustPressed(Input.Keys.K)) {
            Gdx.app.log(position.x + "", position.y + "");
        }

    }

    public Vector2 get2DPosition() {
        return new Vector2(position.x, position.y);
    }

    public int getID() {
        return ID;
    }

    public boolean isMain() {
        return this.isMain;
    }

    public Sprite obtainObject() {
        return sprite;
    }

    @Override
    public void dispose() {

    }
}

If it’s any help, I’m stepping the world at 6 velocity iterations and 2 position iterations.

Sim cards aren’t working after flashing MOTOROLA NICKLAUS MTK (XT1770) to stock ROM. And TWRP isn’t working too!

After using custom ROMs on my Motorola E4 Plus (Nicklaus) I figured
out that there’s no such custom stable ROM to install so I recently
flashed my device with to stock ROM but ended up with no sim support.
Tried to reset the networks but nothing helped me at all.

Reformatted the device and flashed with region specific stock ROMs too
but nothing helped. Decided to use twrp recovery but flashed twrp too,
it showed OK while flshing using ADB but recovery mode showing “No
Command”.

The problem is currently I’m unable to use the stock ROM or to go back to those custom ROMs. Bootloader is unlocked, everything changes has been executed properly as expected but not working on phone.

customization – MultiLevel Drop down is not working in Divi Theme with click or enter technique

I wanted to change the hover menu dropdown to click or enter for accessibility reasons. I am able to make the dropdown buttons work on a single level but not on multilevel meaning a dropdown menu is not showing up when clicked inside dropdown.

Here is my jquery code:

jQuery(document).ready(function($){
$(‘.menu-item-has-children’).on(‘click’, function(e) {
e.preventDefault();

  if (!$(this).hasClass('active')) {
    $(this).children('.dropdown-menu').slideDown(100);
    $('.menu-item-has-children').toggleClass('active');
    $(this).addClass('active');
}
  else{
    $('.dropdown-menu').slideUp(100);
    $('.menu-item-has-children').toggleClass('active');
  } 
})


$('.menu-item-has-children').on('enter', function(e) {
e.preventDefault();
 
  if (!$(this).hasClass('active')) {
    $(this).children('.dropdown-menu').slideDown(100);
    $('.menu-item-has-children').toggleClass('active');
    $(this).addClass('active');
}
  else{
    $('.dropdown-menu').slideUp(100);
    $('.menu-item-has-children').toggleClass('active');
  }
})

});

Navigation Html code:

    <nav id="top-menu-nav">
                        <ul id="top-menu" class="navbar-nav">
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-103" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home menu-item-103 nav-item">
<a title="Home" href="http://megabot/leadscouncil/" class="nav-link">Home</a>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-107" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-has-children dropdown active menu-item-107 nav-item"><a title="About Us" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle nav-link" id="menu-item-dropdown-107">About Us</a>
<ul class="dropdown-menu" aria-labelledby="menu-item-dropdown-107" role="menu" style="display: none;">
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1044" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1044 nav-item">
<a title="About Us" href="http://megabot/leadscouncil/about-us/" class="dropdown-item">About Us</a>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-505" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-505 nav-item">
<a title="Board of Directors" href="http://megabot/leadscouncil/board-of-directors/" class="dropdown-item">Board of Directors</a>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-105" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-98 current_page_item current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-has-children dropdown active menu-item-105 nav-item">
<a title="Leadership Awards" href="http://megabot/leadscouncil/leadership-awards/" class="dropdown-item" aria-current="page">Leadership Awards</a>
    <ul class="dropdown-menu" aria-labelledby="menu-item-dropdown-107" role="menu" style="display: none;">
        <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1274" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-98 current_page_item menu-item-1274 nav-item">
<a title="Leadership Awards" href="http://megabot/leadscouncil/leadership-awards/" class="dropdown-item" aria-current="page">Leadership Awards</a>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1173" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1173 nav-item">
<a title="Executive Leadership Awards" href="http://megabot/leadscouncil/executive-leadership-awards/" class="dropdown-item">Executive Leadership Awards</a>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1172" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1172 nav-item">
<a title="Tim Burke Pioneer Award" href="http://megabot/leadscouncil/tim-burke-pioneer-award/" class="dropdown-item">Tim Burke Pioneer Award</a>
</li>
    </ul>
</li>
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1157" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1157 nav-item">
<a title="FAQ" href="http://megabot/leadscouncil/faq/" class="dropdown-item">FAQ</a>
</li>
</ul>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-108" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children dropdown menu-item-108 nav-item">
<a title="Membership" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle nav-link" id="menu-item-dropdown-108">Membership</a>
<ul class="dropdown-menu" aria-labelledby="menu-item-dropdown-108" role="menu" style="display: none;">
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1045" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1045 nav-item"><a title="Membership" href="http://megabot/leadscouncil/membership/" class="dropdown-item">Membership</a></li>
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1626" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1626 nav-item"><a title="Membership Directory" href="http://megabot/leadscouncil/membership-directory/" class="dropdown-item">Membership Directory</a></li>
</ul>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1717" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown menu-item-1717 nav-item"><a title="Resource Hub" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle nav-link" id="menu-item-dropdown-1717">Resource Hub</a>
<ul class="dropdown-menu" aria-labelledby="menu-item-dropdown-1717" role="menu" style="display: none;">
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1930" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1930 nav-item"><a title="Diversity Hub" href="http://hs.nxk.921.myftpupload.com/diversity-inclusion-hub" class="dropdown-item">Diversity Hub</a></li>
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1768" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children dropdown menu-item-1768 nav-item"><a title="Event Hub" href="http://hs.nxk.921.myftpupload.com/hs.events" class="dropdown-item">Event Hub</a>
    <ul class="dropdown-menu" aria-labelledby="menu-item-dropdown-1717" role="menu" style="display: none;">
        <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1863" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1863 nav-item"><a title="Webinar &amp; Speaker Submissions" href="http://hs.nxk.921.myftpupload.com/speaker-inquiry" class="dropdown-item">Webinar &amp; Speaker Submissions</a></li>
    </ul>
</li>
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1769" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1769 nav-item"><a title="News Hub" href="http://hs.nxk.921.myftpupload.com/hub" class="dropdown-item">News Hub</a></li>
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1729" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1729 nav-item"><a title="Legislative Hub" href="http://megabot/leadscouncil/legislative-map/" class="dropdown-item">Legislative Hub</a></li>
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1896" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1896 nav-item"><a title="Jobs Hub" href="http://megabot/leadscouncil/jobs/" class="dropdown-item">Jobs Hub</a></li>
</ul>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-106" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children dropdown menu-item-106 nav-item"><a title="LeadsCouncil Standards" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle nav-link" id="menu-item-dropdown-106">LeadsCouncil Standards</a>
<ul class="dropdown-menu" aria-labelledby="menu-item-dropdown-106" role="menu" style="display: none;">
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1799" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1799 nav-item"><a title="Lead Generation Standards" href="http://megabot/leadscouncil/leadscouncil-standards/" class="dropdown-item">Lead Generation Standards</a></li>
    <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1795" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-1795 nav-item"><a title="Due Diligence Checklist" href="http://megabot/leadscouncil/affiliate-due-diligence-checklist/" class="dropdown-item">Due Diligence Checklist</a></li>
</ul>
</li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-104" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-104 nav-item"><a title="Contact Us" href="http://megabot/leadscouncil/contact-us/" class="nav-link">Contact Us</a></li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1587" class="login_link menu-item menu-item-type-custom menu-item-object-custom menu-item-1587 nav-item"><a title="Login" href="http://megabot/leadscouncil/my-account/" class="nav-link">Login</a></li>
<li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-1594" class="logout_link menu-item menu-item-type-custom menu-item-object-custom menu-item-1594 nav-item"><a title="Logout" href="/wp-login.php?action=logout" class="nav-link">Logout</a></li>
</ul>                       </nav>