Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generator redesign #99

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions docs/src/examples/smear.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Now we define the ball:
```
# define ball parameters
position = [-2.0, -2.0]
ball = define_circle(; position = position,
ball = create_circle(; position = position,
radius = 1.0,
color = (1,1,1))
```
Expand Down Expand Up @@ -212,7 +212,7 @@ function smear_example(num_particles, num_iterations, total_frames;

# define ball parameters
object_position = fi("object_position", [-2.0, -2.0])
ball = define_circle(; position = object_position,
ball = create_circle(; position = object_position,
radius = 1.0,
color = (1,1,1))

Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/swirled_square.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ In this case, each row of the array will define the color of a different quadran
Now we can define our fractal executable...

```
H = define_square(; position = [0.0, 0.0], rotation = pi/4, color = colors)
H = create_square(; position = [0.0, 0.0], rotation = pi/4, color = colors)
```

Here, `ArrayType` can be either an `Array` or `CuArray` depending whether you would like to run the code on the CPU or (CUDA / AMD) GPU.
Expand Down Expand Up @@ -159,7 +159,7 @@ function square_example(num_particles, num_iterations;
[0.25, 0.25, 1.0, 1],
[1.0, 0.25, 1.0, 1]]

H = define_square(; position = [0.0, 0.0], rotation = pi/4, color = colors)
H = create_square(; position = [0.0, 0.0], rotation = pi/4, color = colors)
swirl_operator = fo(Flames.swirl)
H_post = nothing
if transform_type == :outer_swirl
Expand Down
2 changes: 1 addition & 1 deletion docs/src/layering.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function layering_example(num_particles, num_iterations; ArrayType = Array)
world_size = (9*0.15, 16*0.15)
ppu = 1920/world_size[2]

square = define_rectangle(position = [0.0,0.0],
square = create_rectangle(position = [0.0,0.0],
rotation = pi/4,
color = RGBA(1,0,1))
flayer = FableLayer(; ArrayType = ArrayType, H1 = square,
Expand Down
10 changes: 5 additions & 5 deletions docs/src/postprocessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For the following examples, we will be performing post processing on a simple ci
```
function quick_circle(num_particles, num_iterations; ArrayType = Array,
filename = "out.png")
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

fl = FableLayer(; H1 = circle, ArrayType = ArrayType)

Expand Down Expand Up @@ -75,7 +75,7 @@ Here is a quick example:
function clip_example(num_particles, num_iterations; ArrayType = Array,
filename = "clip_out.png")

circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

clip = Clip(; threshold = 0.5, color = RGBA(1, 1, 0, 1))

Expand Down Expand Up @@ -165,7 +165,7 @@ Finally, here is a quick example using the Gaussian `Blur` post process (note yo
```
function blur_example(num_particles, num_iterations; ArrayType = Array,
filter_size = 3, filename = "blur_out.png")
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

blur = Blur(; filter_size = filter_size)

Expand Down Expand Up @@ -197,7 +197,7 @@ Here is a quick example using the Sobel operator:
```
function sobel_example(num_particles, num_iterations; ArrayType = Array,
filename = "sobel_out.png")
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

sobel = Sobel()

Expand Down Expand Up @@ -244,7 +244,7 @@ Here is a quick example using the Outline post process:
function outline_example(num_particles, num_iterations; ArrayType = Array,
filename = "outline_out.png", linewidth = 1,
object_outline = false)
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

outline = Outline(; linewidth = linewidth, object_outline = object_outline)

Expand Down
2 changes: 1 addition & 1 deletion examples/barnsley.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function barnsley_example(num_particles, num_iterations;
color_3 = [0.,1,0,1]
color_4 = [0.,0,1,1]

H = define_barnsley(; color = [color_1, color_2, color_3, color_4])
H = create_barnsley(; color = [color_1, color_2, color_3, color_4])

fo_1 = fo(Flames.identity, Shaders.previous, 1)
fo_2 = fo(scale_and_translate(translation = (0.5, 0.5), scale = 0.5),
Expand Down
2 changes: 1 addition & 1 deletion examples/layering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function layering_example(num_particles, num_iterations; ArrayType = Array)
world_size = (9*0.15, 16*0.15)
ppu = 1920/world_size[2]

square = define_rectangle(position = [0.0,0.0],
square = create_rectangle(position = [0.0,0.0],
rotation = pi/4,
color = RGBA(1,0,1))
flayer = FableLayer(; ArrayType = ArrayType, H = square,
Expand Down
2 changes: 1 addition & 1 deletion examples/logscale.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function logscale_example(num_particles, num_iterations; ArrayType = Array)
world_size = (9*0.15, 16*0.15)
ppu = 1920/world_size[2]

circle = define_circle(chosen_fx = :naive_disk, color = Shaders.white)
circle = create_circle(chosen_fx = :naive_disk, color = Shaders.white)

flayer = FableLayer(; ArrayType = ArrayType, H = circle,
world_size = world_size, ppu = ppu,
Expand Down
6 changes: 3 additions & 3 deletions examples/multi-object.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ function multi_example(num_particles, num_iterations;

ppu = 1920/world_size[2]

square = define_square(; position = [-0.25, -0.25], scale = 0.25,
square = create_square(; position = [-0.25, -0.25], scale = 0.25,
color = Shaders.blue)
square_2 = define_square(; position = [-0.25, 0.25], scale = 0.25,
square_2 = create_square(; position = [-0.25, 0.25], scale = 0.25,
color = Shaders.magenta)
circle = define_circle(; position = [0.25, 0.0], radius = 0.5,
circle = create_circle(; position = [0.25, 0.0], radius = 0.5,
color = Shaders.red)

final_H = Hutchinson([square_2, circle, square])
Expand Down
12 changes: 6 additions & 6 deletions examples/postprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Fable, Colors

function quick_circle(num_particles, num_iterations; ArrayType = Array,
filename = "out.png")
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

fl = FableLayer(; H = circle, ArrayType = ArrayType)

Expand All @@ -13,7 +13,7 @@ end
function clip_example(num_particles, num_iterations; ArrayType = Array,
filename = "clip_out.png")

circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

clip = Clip(; threshold = 0.5, color = RGBA(1, 1, 0, 1))

Expand All @@ -26,7 +26,7 @@ end

function identity_example(num_particles, num_iterations; ArrayType = Array,
filename = "identity_out.png")
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

identity = Identity()

Expand All @@ -39,7 +39,7 @@ end

function blur_example(num_particles, num_iterations; ArrayType = Array,
filter_size = 3, filename = "blur_out.png")
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

blur = Blur(; filter_size = filter_size)

Expand All @@ -52,7 +52,7 @@ end

function sobel_example(num_particles, num_iterations; ArrayType = Array,
filename = "sobel_out.png")
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

sobel = Sobel()

Expand All @@ -66,7 +66,7 @@ end
function outline_example(num_particles, num_iterations; ArrayType = Array,
filename = "outline_out.png", linewidth = 1,
object_outline = false)
circle = define_circle(; radius = 0.1, color = [1, 0, 1, 1])
circle = create_circle(; radius = 0.1, color = [1, 0, 1, 1])

outline = Outline(; linewidth = linewidth, object_outline = object_outline)

Expand Down
4 changes: 2 additions & 2 deletions examples/sierpinski.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function sierpinski_example(num_particles, num_iterations, num_frames;
B_2 = fi(:B_2, [r*cos(-theta + 2*pi/3), r*sin(-theta + 2*pi/3)])
C_2 = fi(:C_2, [r*cos(-theta + 4*pi/3), r*sin(-theta + 4*pi/3)])

H = define_triangle(; A = A_1, B = B_1, C = C_1,
H = create_triangle(; A = A_1, B = B_1, C = C_1,
color = [[1.0, 0.0, 0.0, 1.0],
[0.0, 1.0, 0.0, 1.0],
[0.0, 0.0, 1.0, 1.0]],
chosen_fx = :sierpinski)
H_2 = define_triangle(A = A_2, B = B_2, C = C_2,
H_2 = create_triangle(A = A_2, B = B_2, C = C_2,
color = [[0.0, 1.0, 1.0, 1.0],
[1.0, 0.0, 1.0, 1.0],
[1.0, 1.0, 0.0, 1.0]],
Expand Down
2 changes: 1 addition & 1 deletion examples/smear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function smear_example(num_particles, num_iterations, total_frames;

# define ball parameters
object_position = fi("object_position", [-2.0, -2.0])
ball = define_circle(; position = object_position,
ball = create_circle(; position = object_position,
radius = 1.0,
color = (1,1,1))

Expand Down
2 changes: 1 addition & 1 deletion examples/square.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function square_example(num_particles, num_iterations;
[1.0, 0.25, 1.0, 1]]

rot_fi = fi("rotation", pi/4)
square = define_square(; position = [0.0, 0.0], rotation = rot_fi,
square = create_square(; position = [0.0, 0.0], rotation = rot_fi,
color = colors)
swirl_operator = fo(Flames.swirl)
H_post = nothing
Expand Down
63 changes: 32 additions & 31 deletions src/Fable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,57 @@ set_output(tf) = (global OUTPUT = tf)
# Interfaces
include("structs/time.jl")
include("structs/point.jl")
include("structs/colors.jl")

# Utilities
include("utils/extras.jl")

# Geometries
include("utils/geometries.jl")

# KA kernels
include("utils/histogram.jl")

# Fable flame structures
include("structs/fable_buffer.jl")
include("structs/fable_input.jl")
include("structs/fable_user_methods.jl")
include("fums/shaders.jl")
include("structs/fable_operators.jl")
include("structs/fable_executable/fable_executable.jl")
include("structs/fable_executable/hutchinson.jl")
include("structs/fable_executable/shader.jl")
include("io/splat.jl")
#include("structs/fable_operators/generators.jl")
#include("structs/fable_operators/fable_operators.jl")
#include("structs/fable_executable/fable_executable.jl")
#include("structs/fable_executable/hutchinson.jl")
#include("structs/fable_executable/shader.jl")

# Operations
include("utils/simple_rng.jl")
include("fums/flames.jl")
include("fums/smears.jl")
#include("utils/simple_rng.jl")
#include("fums/flames.jl")
#include("fums/smears.jl")

# Shapes
include("objects/rectangle.jl")
include("objects/circle.jl")
include("objects/triangle.jl")
include("objects/barnsley.jl")
#include("objects/rectangle.jl")
#include("objects/circle.jl")
#include("objects/triangle.jl")
#include("objects/barnsley.jl")

# IO
include("structs/layers/layers.jl")
include("io/postprocess/postprocess.jl")
include("structs/layers/fractal_layer.jl")
include("structs/layers/color_layer.jl")
include("structs/layers/image_layer.jl")
include("structs/layers/shader_layer.jl")
include("structs/video_params.jl")
include("io/io_tools.jl")
## IO
#include("structs/layers/layers.jl")
#include("io/postprocess/postprocess.jl")
#include("structs/layers/fractal_layer.jl")
#include("structs/layers/color_layer.jl")
#include("structs/layers/image_layer.jl")
#include("structs/layers/shader_layer.jl")
#include("structs/video_params.jl")
#include("io/io_tools.jl")

# PostProcessing
include("io/postprocess/clip.jl")
include("io/postprocess/filter.jl")
include("io/postprocess/sobel.jl")
include("io/postprocess/outline.jl")
#include("io/postprocess/clip.jl")
#include("io/postprocess/filter.jl")
#include("io/postprocess/sobel.jl")
#include("io/postprocess/outline.jl")

# Main file
include("run/run.jl")
include("run/fractal_flame.jl")
include("run/shader.jl")
include("run/color.jl")
#include("run/run.jl")
#include("run/fractal_flame.jl")
#include("run/shader.jl")
#include("run/color.jl")

end # module
4 changes: 2 additions & 2 deletions src/fums/shaders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function create_color(a::RGBA)
return Shaders.custom(r = a.r, g = a.g, b = a.b, a = a.alpha)
end

function define_color_operators(color::Union{RGBA, RGB, FableUserMethod};
function create_color_operators(color::Union{RGBA, RGB, FableUserMethod};
fnum = 4)
color = create_color(color)
return [color for i = 1:fnum]
end

function define_color_operators(t_color::Union{Tuple, Vector}; fnum = 4)
function create_color_operators(t_color::Union{Tuple, Vector}; fnum = 4)
if eltype(t_color) <: FableUserMethod
return [t_color for i = 1:fnum]
end
Expand Down
Loading