-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from vinaygaba/dev
- 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
Showing
8 changed files
with
364 additions
and
159 deletions.
There are no files selected for viewing
8 changes: 0 additions & 8 deletions
8
library/src/main/java/com/vinaygaba/rubberstamp/Position.java
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
library/src/main/java/com/vinaygaba/rubberstamp/PositionCalculator.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,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); | ||
} | ||
} | ||
} |
Oops, something went wrong.