This commit is contained in:
Niles Rogoff 2017-03-20 13:45:48 -04:00
parent 86941c6bdb
commit 0497db9698
No known key found for this signature in database
GPG Key ID: B78B908F23430F80
23 changed files with 20 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

View File

@ -8,7 +8,7 @@ operations = {
"*": lambda x, y: x * y,
"+": lambda x, y: x + y,
"-": lambda x, y: x - y,
"%": lambda x, y: x % y,
"%?": lambda x, y: x if y == 0 else x % y,
"÷?": lambda x, y: x if y == 0 else x / y, # don't want division by zero errors, and filenames can't have / in them.
"log? base": lambda x, y: x if abs(x) <= 1 or abs(y) <= 1 else math.log(abs(x), abs(y)),
#"~": lambda x, y: ~(getop()(x, y)), # todo
@ -111,6 +111,13 @@ def generate(arg = "default", ops = False, syms = False):
ops = [random.choice([x for x, y in operations.items()]) for k in range(random.randint(2, 6))]
if not syms:
syms = [gensym() for i in range(len(ops) + 1)]
literals = [f("x", "y") for f in syms]
if "y" not in literals or "x" not in literals:
print("DEBUG! " + sbuilder(syms, 1, False, ops) + " does not contain both x and y. Trying another")
generate(arg)
return
# uncomment to use the sample data. I used this to test the builder function.
# ops = [">>", "*", "-", "^"]
# ops.reverse()

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

View File

@ -52,9 +52,20 @@ and for ((((x) & y) - x) + y) + 11
Support for unary operators, like bitwise not (~)
Support for detecting if the generated function only depends on one or zero of the position expressions
Support for detecting if the generated function only depends on one or zero of the position expressions - added in 1.2
#### Optimization
Right now, if it generates an expression that starts with a bunch of constants (like ((12) log base? 3) ** 5) it will run those potentially-expensive calculations for each pixel, even though that part of the expression never changes.
That could be optimized
### Changelog
#### 1.2
- Added the % operator and the `modulo` argument.
- Added detection of some useless patterns
#### 1.1
- Added `greyscale` argument

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B