Skip to content

Instantly share code, notes, and snippets.

View payne911's full-sized avatar

payne911

  • Montréal (Canada)
  • 06:24 (UTC -04:00)
View GitHub Profile
@ImMichey
ImMichey / gist:87cf6643691c1d892e261c266b3d8850
Created October 7, 2020 22:51
LibGDX 2D shadows with affines
/*
* Creates a custom Affine2 for shadows with rotation
*
* x, y --> position in world (usually the entity position)
* rotation --> angle in degrees
* offsetX, offsetY --> if the original sprite is drawn with an offset
* originX, originY --> center of the sprite
* shearX, shearY --> shear amount (usually day/night cycle shear values)
* scaleX, scaleY --> scale amount (usually day/night cycle scale values)
*/
@payne911
payne911 / image_integral.py
Last active June 25, 2020 18:50
Convex test on binary images (Image integral for Pattern Matching)
import cv2 as cv
def integral_test(X): # returns True if X is convex
img_t = np.reshape(X, (28, 28)) # preprocess: reshaping
int_result = cv.integral(img_t.astype(np.uint8)) # calculating the integral-image
patterns_to_test = [block_patterns, big_block_patterns, horizontal_patterns, vertical_patterns,
horizontal_patterns2, vertical_patterns2, bigger_block_patterns, horizontal_patterns3,
vertical_patterns3, bbigger_block_patterns, bbbigger_block_patterns, bbbbigger_block_patterns]
for p in range(len(patterns_to_test)): # run test on all patterns until a match is found