# Using the "matrix" controler from the ControlP5 library

**URL:** <https://discourse.processing.org/t/using-the-matrix-controler-from-the-controlp5-library/5572>\
**Category:** Libraries\
**Created:** [November 15, 2018, 9:11pm UTC](https://discourse.processing.org/t/using-the-matrix-controler-from-the-controlp5-library/5572 "2018-11-15T21:11:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [November 15, 2018, 9:11pm UTC](https://discourse.processing.org/t/using-the-matrix-controler-from-the-controlp5-library/5572/1 "2018-11-15T21:11:20Z")

</div>

Hi,

Does anyone know how to remove the “moving line” (don’t know how to call it) embeded in the matrix controller from the ControlP5 library ?

By default the matrix is displayed as a (music) sequencer but I’d like to use it for other purposes if possible.

[[Album] Imgur ![](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2bf81895cc9e52e9203679220356afe370aca0d2.jpeg "Imgur") ](https://imgur.com/a/XiL6DNR)

```auto
import controlP5.*;

ControlP5 cp5;

int nx = 7;
int ny = 5;

void setup() {
  size(700, 400);

  cp5 = new ControlP5(this);

  cp5.addMatrix("myMatrix")
     .setPosition(50, 100)
     .setSize(200, 100)
     .setGrid(nx, ny)
     .setGap(1, 1)
     //.setInterval(200)
     .setMode(ControlP5.MULTIPLES)
     ;
  
  cp5.getController("myMatrix").getCaptionLabel().alignX(CENTER);
  

}

void draw() {
  background(0);
  fill(255, 100);
  
  
}

```

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 17, 2018, 3:18pm UTC](https://discourse.processing.org/t/using-the-matrix-controler-from-the-controlp5-library/5572/2 "2018-11-17T15:18:39Z")

</div>

Hey,

I am trying to find the piece of code where it draws the line in the controlP5 library source code and I think it’s here :

(`C:\Users\username\Documents\Processing\libraries\controlP5\src\controlP5\` on Windows)

```auto
theGraphics.rect( cnt * stepX , 0 , 1 , getHeight( ) - gapY );

```

```auto
class MatrixView implements ControllerView< Matrix > {

		public void display( PGraphics theGraphics , Matrix theController ) {
			theGraphics.noStroke( );
			theGraphics.fill( bg );
			theGraphics.rect( 0 , 0 , getWidth( ) , getHeight( ) );

			float gx = gapX / 2;
			float gy = gapY / 2;
			for ( int x = 0 ; x < _myCellX ; x++ ) {
				for ( int y = 0 ; y < _myCellY ; y++ ) {

					theGraphics.fill( _myCells[x][y] == 1 ? color.getActive( ) : color.getBackground( ) );
					theGraphics.rect( x * stepX + gx , y * stepY + gy , stepX - gapX , stepY - gapY );
				}
			}
			if ( isInside( ) ) {
				//TODO
				int x = (int) ((theGraphics.mouseX - position.x) / stepX);
				int y = (int) ((theGraphics.mouseY - position.y) / stepY);
				if (x >= 0 && x < _myCellX && y >= 0 && y < _myCellY) {
				theGraphics.fill(_myCells[x][y] == 1 ? color.getActive() :
				color.getForeground());
				theGraphics.rect(x * stepX, y * stepY, stepX - gapX, stepY - gapY);
				}
			}
			theGraphics.fill( color.getActive( ) );
			theGraphics.rect( cnt * stepX , 0 , 1 , getHeight( ) - gapY );
			if ( isLabelVisible ) {
				_myCaptionLabel.draw( theGraphics , 0 , 0 , theController );
			}
		}
	}

```

---

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [November 17, 2018, 3:38pm UTC](https://discourse.processing.org/t/using-the-matrix-controler-from-the-controlp5-library/5572/3 "2018-11-17T15:38:52Z")

</div>

Thank you @josephh.

I ended up building my own matrix controler and would actually suggest people to avoid using the controlp5 `addMatrix` method as well because it’s buggy and not well integrated in the library.
