Skip to content

Commit

Permalink
Merge pull request #14 from vinaygaba/dev
Browse files Browse the repository at this point in the history
- Added features like rubberstamp rotation, alpha, shader, etc
- Refactored code to be more modular
- Added functionality to define rubberstamp as a bitmap
- Corrected faulty position calculation
- Modified .gitignore
- Update gradle plugin
  • Loading branch information
vinaygaba authored Apr 28, 2017
2 parents 871bd08 + a0d972b commit aa055d1
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 159 deletions.
8 changes: 0 additions & 8 deletions library/src/main/java/com/vinaygaba/rubberstamp/Position.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.vinaygaba.rubberstamp;

import android.util.Pair;

import static com.vinaygaba.rubberstamp.RubberStamp.BOTTOMCENTER;
import static com.vinaygaba.rubberstamp.RubberStamp.BOTTOMLEFT;
import static com.vinaygaba.rubberstamp.RubberStamp.BOTTOMRIGHT;
import static com.vinaygaba.rubberstamp.RubberStamp.CENTER;
import static com.vinaygaba.rubberstamp.RubberStamp.CENTERLEFT;
import static com.vinaygaba.rubberstamp.RubberStamp.CENTERRIGHT;
import static com.vinaygaba.rubberstamp.RubberStamp.TOPCENTER;
import static com.vinaygaba.rubberstamp.RubberStamp.TOPLEFT;
import static com.vinaygaba.rubberstamp.RubberStamp.TOPRIGHT;

public class PositionCalculator {


public static Pair<Integer, Integer> getCoordinates(@RubberStamp.RubberStampPosition int location,
int bitmapWidth, int bitmapHeight,
int rubberstampWidth, int rubberstampHeight) {
switch(location){

case TOPLEFT:
return new Pair<>(0, rubberstampHeight);

case TOPCENTER:
return new Pair<>((bitmapWidth / 2) - (rubberstampWidth / 2),
rubberstampHeight);
case TOPRIGHT:
return new Pair<>(bitmapWidth - rubberstampWidth, rubberstampHeight);

case CENTERLEFT:
return new Pair<>(0, (bitmapHeight / 2) + (rubberstampHeight / 2));

case CENTER:
return new Pair<>((bitmapWidth / 2) - (rubberstampWidth / 2),
(bitmapHeight / 2) + (rubberstampHeight / 2));
case CENTERRIGHT:
return new Pair<>(bitmapWidth - rubberstampWidth,
(bitmapHeight / 2) + (rubberstampHeight / 2));

case BOTTOMLEFT:
return new Pair<>(0, bitmapHeight);

case BOTTOMCENTER:
return new Pair<>((bitmapWidth / 2) - (rubberstampWidth / 2),
bitmapHeight);
case BOTTOMRIGHT:
return new Pair<>(bitmapWidth - rubberstampWidth, bitmapHeight);

default:
return new Pair<>(0,0);
}
}
}
Loading

0 comments on commit aa055d1

Please sign in to comment.