add more commands
This commit is contained in:
parent
e375726ae8
commit
03266963bc
1 changed files with 31 additions and 14 deletions
45
pattern.py
45
pattern.py
|
@ -21,21 +21,23 @@ def constant(target, arg):
|
|||
|
||||
|
||||
def add(target, arg):
|
||||
res = target + arg
|
||||
if res > 255:
|
||||
res = 255
|
||||
elif res < 0:
|
||||
res = 0
|
||||
return res
|
||||
return target + arg
|
||||
|
||||
|
||||
def sub(target, arg):
|
||||
res = target - arg
|
||||
if res > 255:
|
||||
res = 255
|
||||
elif res < 0:
|
||||
res = 0
|
||||
return res
|
||||
return target - arg
|
||||
|
||||
|
||||
def mult(target, arg):
|
||||
return target * arg
|
||||
|
||||
|
||||
def div(target, arg):
|
||||
return target / arg
|
||||
|
||||
|
||||
def mod(target, arg):
|
||||
return target % arg
|
||||
|
||||
|
||||
def rand(target, arg):
|
||||
|
@ -63,8 +65,11 @@ def apply(targets, args, func):
|
|||
this.instructions = {
|
||||
"CONSTANT": constant,
|
||||
"ADD": add,
|
||||
"SUB": sub,
|
||||
"RAND": rand
|
||||
"SUBTRACT": sub,
|
||||
"MULTIPLY": mult,
|
||||
"DIVIDE": div,
|
||||
"MODULO": mod,
|
||||
"RANDOM": rand
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,6 +94,18 @@ def pat(index, tick, previous_values):
|
|||
this.values["g"] = 0
|
||||
this.values["b"] = 0
|
||||
this.values["stack"] = 0
|
||||
if r > 255:
|
||||
r = 255
|
||||
elif r < 0:
|
||||
r = 0
|
||||
if g > 255:
|
||||
g = 255
|
||||
elif g < 0:
|
||||
g = 0
|
||||
if b > 255:
|
||||
b = 255
|
||||
elif b < 0:
|
||||
b = 0
|
||||
return (r, g, b)
|
||||
else:
|
||||
return default(index, tick)
|
||||
|
|
Loading…
Reference in a new issue