-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General refactor: Important performance improvements (#2)
* Update Color.jl to work with Base functions * Add comment in PerlinBroadcasting.jl * Rename CustomExpr to GeneticExpr, refactor the internal * Refactor custom math functions to work with new internals * Refactor ExprEvaluation.jl code, now much more performant * Refactor render functions to work with new internals * Update Genetic.jl, change CustomExpr to GeneticExpr * Refactor DynamicalSystems.jl with new internals, enhance code * Update with new exports * Add meshgrid function to function utils * Add WIP code in ExprGenerators.jl * Update tests with new internals * Replace trunc with round to fix small precision problems * Add adjust_brightness function * Minor fixes in Renderer.jl * Minor fixes in DynamicalSystems.jl * Minor fixes in Colors.jl * Minor fix in Colors.jl * Add fixes in ExprEvaluation.jl * Fix generate_image_vectorized * Add f function * Extend Base simple functions for proper Expr evaluation * Optimize core math functions by using @inbounds and removing merge * Update color functions * Update DynamicalSystems.jl * update Expr functions * Update boolean functions * Update UI.jl * Update Project.toml * Add some garbage examples -- to be cleaned * Update README.md
- Loading branch information
1 parent
c361266
commit c2fbf77
Showing
65 changed files
with
8,006 additions
and
690 deletions.
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
using GeneticTextures | ||
F_A0 = :(Complex(x, y)) | ||
F_dA = :(x_grad(A) + y_grad(A) + 0.1 * laplacian(A)) | ||
|
||
|
||
color_expr = :((a) -> RGB(abs(a.r), abs(a.g), abs(a.b))) | ||
complex_expr = :((c) -> abs(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
# B = VariableDynamics(:B, F_B0, F_dB) | ||
# ds = DynamicalSystem([A,B]) | ||
|
||
ds = DynamicalSystem([A]) | ||
w = h = 64 | ||
animate_system_2(ds, w, h, 100.0, 0.2; color_expr, complex_expr) |
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,15 @@ | ||
using GeneticTextures | ||
F_A0 = :(Complex(x, y)) | ||
F_dA = :((x_grad(A) + y_grad(A)) * A + 0.1 * laplacian(A)) | ||
|
||
|
||
color_expr = :((a) -> RGB(abs(a.r), abs(a.g), abs(a.b))) | ||
complex_expr = :((c) -> abs(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
# B = VariableDynamics(:B, F_B0, F_dB) | ||
# ds = DynamicalSystem([A,B]) | ||
|
||
ds = DynamicalSystem([A]) | ||
w = h = 64 | ||
animate_system_2(ds, w, h, 100.0, 0.5; color_expr, complex_expr) |
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,16 @@ | ||
using GeneticTextures | ||
F_A0 = :(Complex(x, y)) | ||
# F_dA = :(A^2 + Complex(0.355, 0.355)) | ||
F_dA = :(A^2 + Complex(0.14, 0.13)) | ||
|
||
|
||
color_expr = :((a) -> RGB(abs(a.r), abs(a.g), abs(a.b))) | ||
complex_expr = :((c) -> real(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
# B = VariableDynamics(:B, F_B0, F_dB) | ||
# ds = DynamicalSystem([A,B]) | ||
|
||
ds = DynamicalSystem([A]) | ||
w = h = 512 | ||
animate_system_2(ds, w, h, 200.0, 0.04; color_expr, complex_expr) |
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,21 @@ | ||
using GeneticTextures | ||
F_A0 = :(y) | ||
F_dA = :(C) | ||
|
||
F_B0 = :(1.0) | ||
F_dB = :(x_grad(C)) | ||
|
||
F_C = :(1 - ifs(rand_scalar() > 0.97, 0.0, 1.0) * y) | ||
F_dC = :(neighbor_ave(grad_direction(B * 0.25))) | ||
|
||
|
||
color_expr = :((a, b, c) -> RGB(abs(a.r), abs(b.g), abs(c.b))) | ||
complex_expr = :((c) -> real(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
B = VariableDynamics(:B, F_B0, F_dB) | ||
C = VariableDynamics(:C, F_C, F_dC) | ||
|
||
ds = DynamicalSystem([A, B, C]) | ||
w = h = 32 | ||
animate_system_2(ds, w, h, 10.0, 0.01; color_expr, complex_expr) |
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,19 @@ | ||
using GeneticTextures | ||
|
||
F_A0 = :(Complex(4*x, 4*y)) | ||
F_dA = :(A^2 + Complex(0.355, 0.355)) | ||
# F_dA = :(A^2 + Complex(0.14, 0.13)) | ||
|
||
F_B0 = :(0) | ||
F_dB = :(ifs(abs(A) > 2, B + 0.1, B)) | ||
|
||
|
||
color_expr = :((a, b) -> RGB(abs(b.r), abs(b.g), abs(b.b))) | ||
complex_expr = :((c) -> real(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
B = VariableDynamics(:B, F_B0, F_dB) | ||
ds = DynamicalSystem([A,B]) | ||
|
||
w = h = 512 | ||
animate_system_2(ds, w, h, 200.0, 0.02; color_expr, complex_expr) |
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,40 @@ | ||
using GeneticTextures | ||
using Colors | ||
|
||
# Define a colormap | ||
colormap_ = colormap("RdBu", 100) # Choose any available colormap | ||
|
||
# Color mapping function | ||
function map_to_color(b, colormap) | ||
idx = min(floor(Int, abs(b) * length(colormap)) + 1, length(colormap)) | ||
return colormap[idx] | ||
end | ||
|
||
F_A0 = :(Complex(4*x, 4*y)) | ||
# F_dA = :(A^2 + Complex(0.355, 0.355)) | ||
F_da = :(A^2 + Complex(0.74543, 0.11301)) | ||
|
||
F_B0 = :(0) | ||
F_dB = :(ifs(abs(A) > 2, B + 0.1, B)) | ||
|
||
color_expr = :(begin | ||
using ColorSchemes | ||
|
||
# Access the viridis color scheme | ||
color_scheme = ColorSchemes.viridis | ||
|
||
# Function to map a value between 0 and 1 to a color in the viridis scheme | ||
function map_to_color(value) | ||
return get(color_scheme, value) | ||
end | ||
|
||
(a, b) -> map_to_color(b.r) | ||
end) | ||
complex_expr = :((c) -> real(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
B = VariableDynamics(:B, F_B0, F_dB) | ||
ds = DynamicalSystem([A,B]) | ||
|
||
w = h = 128 | ||
animate_system_2(ds, w, h, 200.0, 0.02; color_expr, complex_expr) |
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,34 @@ | ||
using GeneticTextures | ||
|
||
F_A0 = :(Complex(4*x, 4*y)) | ||
# F_dA = :(A^2 + Complex(0.355, 0.355)) | ||
F_da = :(A^2 + Complex(0.74543, 0.11301)) | ||
|
||
F_B0 = :(0) | ||
F_dB = :(ifs(abs(A) > 2, B + 1, B)) | ||
|
||
F_C0 = :(0) # C will be used as a counter | ||
F_dC = :(C + 1) | ||
|
||
color_expr = :(begin | ||
using ColorSchemes | ||
|
||
# Access the viridis color scheme | ||
color_scheme = ColorSchemes.viridis | ||
|
||
# Function to map a value between 0 and 1 to a color in the viridis scheme | ||
function map_to_color(value) | ||
return get(color_scheme, value) | ||
end | ||
|
||
(a, b, c) -> map_to_color(b.r/c.r) | ||
end) | ||
complex_expr = :((c) -> real(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
B = VariableDynamics(:B, F_B0, F_dB) | ||
C = VariableDynamics(:C, F_C0, F_dC) | ||
ds = DynamicalSystem([A,B,C]) | ||
|
||
w = h = 128 | ||
animate_system_2(ds, w, h, 200.0, 0.3; color_expr, complex_expr) |
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,51 @@ | ||
using GeneticTextures | ||
|
||
F_A0 = :(Complex(4*x, 4*y)) | ||
F_dA = :(A^2 + Complex(0.355, 0.355)) | ||
# F_dA = :(A^2 + Complex(0.74543, 0.11301)) | ||
|
||
F_B0 = :(0) | ||
F_dB = :(ifs(abs(A) > 2, B + 0.1, B)) | ||
|
||
F_C0 = :(0) # C will be used as a counter | ||
F_dC = :(C + 0.1) | ||
|
||
|
||
# Define the color expression | ||
color_expr = :(begin | ||
using ColorSchemes | ||
smooth_modifier(k, z) = abs(z) > 2 ? k - log2(log2(abs(z))) : k | ||
|
||
angle_modifier(k, z) = abs(z) > 2 ? angle(z)/2 * pi : k | ||
# Access the viridis color scheme | ||
color_scheme = ColorSchemes.viridis | ||
|
||
# Function to map a value between 0 and 1 to a color in the viridis scheme | ||
function map_to_color(value) | ||
return get(color_scheme, value) | ||
end | ||
|
||
(a, b, c) -> begin | ||
# Calculate the modified iteration count | ||
modified_k = smooth_modifier(c.r, a.r) | ||
|
||
# Normalize using the counter C | ||
normalized_k = modified_k / c.r | ||
|
||
# Map to color | ||
map_to_color(normalized_k) | ||
end | ||
end) | ||
|
||
complex_expr = :((c) -> real(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
B = VariableDynamics(:B, F_B0, F_dB) | ||
C = VariableDynamics(:C, F_C0, F_dC) | ||
ds = DynamicalSystem([A,B,C]) | ||
|
||
w = h = 1024 | ||
animate_system_2(ds, w, h, 2.0, 0.01; | ||
color_expr, | ||
complex_expr) | ||
|
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,37 @@ | ||
using GeneticTextures | ||
F_A0 = :(Complex(4*x, y)) | ||
# F_dA = :(A^2 + Complex(0.355, 0.355)) | ||
F_dA = :(A^2 + Complex(0.74543, 0.11301)) | ||
|
||
F_B0 = :(0) | ||
F_dB = :(ifs(abs(A) > 2, B + 1, B)) | ||
|
||
F_C0 = :(0) # C will be used as a counter | ||
F_dC = :(C + 1) | ||
|
||
|
||
# Define the value expression | ||
value_expr = :(begin | ||
smooth_modifier(k, z) = abs(z) > 2 ? k - log2(log2(abs(z))) : k | ||
|
||
angle_modifier(k, z) = abs(z) > 2 ? angle(z)/2 * pi : k | ||
|
||
(a, b, c) -> begin | ||
# Calculate the modified iteration count | ||
modified_k = angle_modifier(c.r, a.r) | ||
end | ||
end) | ||
|
||
complex_expr = :((c) -> real(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
B = VariableDynamics(:B, F_B0, F_dB) | ||
C = VariableDynamics(:C, F_C0, F_dC) | ||
ds = DynamicalSystem([A,B,C]) | ||
|
||
w = h = 32 | ||
GeneticTextures.animate_system_3(ds, w, h, 200.0, 0.01; | ||
cmap = :viridis, | ||
value_expr, | ||
complex_expr) | ||
|
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,39 @@ | ||
using GeneticTextures | ||
|
||
F_A0 = :(Complex(4*x, 4*y)) | ||
# F_dA = :(A^2 + Complex(0.355, 0.355)) | ||
# F_dA = :(A^2 + Complex(0.74543, 0.11301)) | ||
F_dA = :(min(A, 1.0) / A + laplacian(A) * max(A, Complex(0.74543,0.11301))^2) | ||
|
||
F_B0 = :(00.0+0.0) | ||
F_dB = :(ifs(abs(A) > 2, B + 1, B)) | ||
|
||
F_C0 = :(0.0+0.0) # C will be used as a counter | ||
F_dC = :(C + 1) | ||
|
||
|
||
# Define the value expression | ||
value_expr = :(begin | ||
smooth_modifier(k, z) = abs(z) > 2 ? k - log2(log2(abs(z))) : k | ||
|
||
angle_modifier(k, z) = abs(z) > 2 ? angle(z)/2 * pi : k | ||
|
||
(a, b, c) -> begin | ||
# Calculate the modified iteration count | ||
modified_k = smooth_modifier(c.r, a.r) | ||
end | ||
end) | ||
|
||
complex_expr = :((c) -> abs(c)) | ||
|
||
A = VariableDynamics(:A, F_A0, F_dA) | ||
B = VariableDynamics(:B, F_B0, F_dB) | ||
C = VariableDynamics(:C, F_C0, F_dC) | ||
ds = DynamicalSystem([A,B,C]) | ||
|
||
w = h = 1024 | ||
GeneticTextures.animate_system_3(ds, w, h, 200.0, 0.01; | ||
cmap = :viridis, | ||
value_expr, | ||
complex_expr) | ||
|
Oops, something went wrong.