-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86a8260
commit 057870d
Showing
6 changed files
with
73 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
push: | ||
branches: | ||
- master | ||
- dev | ||
pull_request: | ||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/br/nullexcept/mux/graphics/drawable/NinePathDrawable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package br.nullexcept.mux.graphics.drawable; | ||
|
||
import br.nullexcept.mux.graphics.Bitmap; | ||
import br.nullexcept.mux.graphics.Canvas; | ||
import br.nullexcept.mux.graphics.Drawable; | ||
import br.nullexcept.mux.graphics.Rect; | ||
|
||
public class NinePathDrawable extends Drawable { | ||
private Bitmap bitmap; | ||
private int size = 4; | ||
|
||
public void setBorder(int size) { | ||
this.size = size; | ||
} | ||
|
||
public void setBitmap(Bitmap bitmap) { | ||
this.bitmap = bitmap; | ||
} | ||
|
||
@Override | ||
public void draw(Canvas canvas) { | ||
if (bitmap != null && bitmap.isValid()) { | ||
Rect bounds = getBounds(); | ||
canvas.drawBitmap(bounds.left, bounds.top, size,size, 0,0, size,size, bitmap, paint); // LEFT TOP | ||
canvas.drawBitmap(bounds.right-size, bounds.top, size,size, bitmap.getWidth()-size,0, size,size, bitmap, paint); // RIGHT TOP | ||
canvas.drawBitmap(bounds.left, bounds.bottom-size, size,size, 0,bitmap.getHeight()-size, size,size, bitmap, paint); // LEFT BOTTOM | ||
canvas.drawBitmap(bounds.right-size, bounds.bottom-size, size,size, bitmap.getWidth()-size,bitmap.getHeight()-size, size,size, bitmap, paint); // RIGHT BOTTOM | ||
|
||
canvas.drawBitmap(bounds.left+size,bounds.top,bounds.width()-size-size,size,size,0,bitmap.getWidth()-(size*2),size,bitmap,paint); // CENTER TOP | ||
canvas.drawBitmap(bounds.left+size,bounds.bottom-size,bounds.width()-size-size,size,size,bitmap.getHeight()-size,bitmap.getWidth()-(size*2),size,bitmap,paint); // CENTER BOTTOM | ||
canvas.drawBitmap(bounds.left,bounds.top+size,size,bounds.height()-size-size,0,size,size,bitmap.getHeight()-(size*2),bitmap,paint); // CENTER LEFT | ||
canvas.drawBitmap(bounds.right-size,bounds.top+size,size,bounds.height()-size-size,bitmap.getWidth()-size,size,size,bitmap.getHeight()-(size*2),bitmap,paint); // CENTER RIGHT | ||
canvas.drawBitmap(bounds.left+size,bounds.top+size,bounds.width()-(size*2),bounds.height()-(size*2),size,size,bitmap.getWidth()-(size*2),bitmap.getHeight()-(size*2),bitmap,paint); // CENTER INNER | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters