Skip to content

Instantly share code, notes, and snippets.

@chikien276
chikien276 / blend.h
Created November 7, 2016 04:58
How photoshop blend work
// source http://stackoverflow.com/questions/5919663/how-does-photoshop-blend-two-images-together
#define ChannelBlend_Normal(A,B) ((uint8)(A))
#define ChannelBlend_Lighten(A,B) ((uint8)((B > A) ? B:A))
#define ChannelBlend_Darken(A,B) ((uint8)((B > A) ? A:B))
#define ChannelBlend_Multiply(A,B) ((uint8)((A * B) / 255))
#define ChannelBlend_Average(A,B) ((uint8)((A + B) / 2))
#define ChannelBlend_Add(A,B) ((uint8)(min(255, (A + B))))
#define ChannelBlend_Subtract(A,B) ((uint8)((A + B < 255) ? 0:(A + B - 255)))
#define ChannelBlend_Difference(A,B) ((uint8)(abs(A - B)))
#define ChannelBlend_Negation(A,B) ((uint8)(255 - abs(255 - A - B)))
class plant{
id: string;
damage: int;
hp: int;
attack: int;
attkSpeed: int;
static final int maxHp = 10;
int getSpeed(){
return attkSpeed;
class plant{
id: string;
damage: int;
hp: int;
attack: int;
attkSpeed: int;
static final int maxHp = 10;
boolean getSpeed(){
return attkSpeed;
class plant{
id: string;
damage: int;
hp: int;
attack: int;
attkSpeed: int;
static final int maxHp = 10;
}
class zoombie{
id: string;
@chikien276
chikien276 / mem_used.sh
Last active January 1, 2023 10:42
Human readable memory usage in Linux per process
ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
@chikien276
chikien276 / RGBtoCMYK.java
Created March 19, 2016 16:34
Convert jpeg image RGB colorspace to CMYK colospace
import java.awt.color.ColorSpace;
import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.io.File;
import javax.imageio.ImageIO;
/**
*