Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name = "MiniFB"
uuid = "cc649173-1898-4bb8-8a16-ca5f88bd87d9"
authors = ["Avik Sengupta"]
version = "0.1.1"
version = "0.2.0"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
MiniFB_jll = "b93afbca-07d8-5443-9979-bb4221978155"

[compat]
Colors = "0.10, 0.11, 0.12"
CEnum = "0.4"
julia = "1.3"

[extras]
Expand Down
3 changes: 1 addition & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ makedocs(;
"Image" => "example/Image.md",
"Guilloche" => "example/Guilloche.md"
],
"API" => "api.md",
"Generated Code" => "gen.md"
"API" => "api.md"
],
sitename="MiniFB",
authors="Avik Sengupta"
Expand Down
27 changes: 0 additions & 27 deletions docs/src/gen.md

This file was deleted.

26 changes: 13 additions & 13 deletions example/Guilloche.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This code shows how visualisations created with [Luxor.jl](https://github.com/JuliaGraphics/Luxor.jl) can be
# rendered easily with MiniFB.
# This code shows how visualisations created with [Luxor.jl](https://github.com/JuliaGraphics/Luxor.jl) can be
# rendered easily with MiniFB.

# Add the Luxor, Colors and MiniFB packages to your environment before running this code.
using Luxor, MiniFB, Colors
using MiniFB.LibMiniFB


# [Guilloché](https://en.wikipedia.org/wiki/Guilloch%C3%A9) is a decorative technique in which a very precise, intricate and repetitive pattern is mechanically
# engraved into an underlying material via engine turning. The following struct contains the metadata used to render the pattern.
# [Guilloché](https://en.wikipedia.org/wiki/Guilloch%C3%A9) is a decorative technique in which a very precise, intricate and repetitive pattern is mechanically
# engraved into an underlying material via engine turning. The following struct contains the metadata used to render the pattern.
mutable struct Guilloche
f1::Float64
f2::Float64
Expand Down Expand Up @@ -48,13 +48,13 @@ function drawguilloche(g::Guilloche, radius=20;
strokepath()
end

# The main method sets up the Guilloche struct, opens the window for display, and animates the frames using a while loop.
# The main method sets up the Guilloche struct, opens the window for display, and animates the frames using a while loop.
function main()
WIDTH = 600
HEIGHT = 600
window = mfb_open_ex("Luxor -> MiniFB", WIDTH, HEIGHT, MiniFB.WF_RESIZABLE)
y = 0.1
g2 = Guilloche(2, 1.5, 3, 1,
g2 = Guilloche(2, 1.5, 3, 1,
0.0005, 0.0005, 0.0005, 0.0005,
.1, .1, .1, .1)
t1 = time_ns()
Expand All @@ -78,27 +78,27 @@ function main()
limit=10,
colorfunction = (t) -> sethue(HSL(rescale(t, 0, 300, 0, 359), 0.9, 0.7)))
t2 = time_ns()
text(string("fps: ", round(1E9/(t2-t1), digits=2)),
text(string("fps: ", round(1E9/(t2-t1), digits=2)),
boxtopleft(BoundingBox() * 0.9))
end 600 600
y = y + 0.001
(y > 1) && (y = 0.1)
# The image matrix created by Luxor is, in standard Julia convention, column first. The buffer
# expected by MiniFB is row first. The call to `permutedims` makes that change.
# expected by MiniFB is row first. The call to `permutedims` makes that change.
state = mfb_update(window, permutedims(buffer, (2, 1)))
t1 = t2
# Exit when the user closes the window.
# Exit when the user closes the window.
if state != MiniFB.STATE_OK
break
end
end
mfb_close(window)
end

# Call the main function. This produces really attractive animations -- I highly reccomend you run this yourself!
# The static image below shows you one frame, but does not do justice to the whole animation.
# Call the main function. This produces really attractive animations -- I highly reccomend you run this yourself!
# The static image below shows you one frame, but does not do justice to the whole animation.
main()

# ![](../assets/guilloche.png)

# _Thanks to [`@Cormullion`](https://github.com/cormullion) for this example_
# _Thanks to [`@Cormullion`](https://github.com/cormullion) for this example_
1 change: 1 addition & 0 deletions example/Image.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Images
using ImageTransformations
using MiniFB
using MiniFB.LibMiniFB

# Set the size of the window
global const WIDTH = 600
Expand Down
6 changes: 4 additions & 2 deletions example/Noise.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@


using MiniFB
using MiniFB.LibMiniFB

# A simple function that renders some noise to a window. Demonstrates how to create a window and render a buffer into it using MiniFB
function noise()
WIDTH = 800
Expand All @@ -18,7 +20,7 @@ function noise()
seed = seed >> 1;
seed = seed | (carry << 30);
noise = noise & 0xFF;
g_buffer[i] = mfb_rgb(noise, noise, noise);
g_buffer[i] = mfb_rgb(noise, noise, noise);
end
state = mfb_update(window, g_buffer);
if state != MiniFB.STATE_OK
Expand All @@ -31,4 +33,4 @@ end
# Call the function
noise()

# ![](../assets/noise.png)
# ![](../assets/noise.png)
9 changes: 5 additions & 4 deletions example/Plasma.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

using MiniFB
using MiniFB.LibMiniFB

# This function displays a time-varying mix of colors on screen. Demonstrates how to create a buffer and render it to a window.
# This function displays a time-varying mix of colors on screen. Demonstrates how to create a buffer and render it to a window.
function plasma()
pallete = zeros(UInt32, 512)
WIDTH = 320
Expand All @@ -27,9 +28,9 @@ function plasma()
time_y = cos(time * π / 180);
i = 1;
for y in 1:HEIGHT
dy = cos((y * time_y) * π / 180);
dy = cos((y * time_y) * π / 180);
for x in 1:WIDTH
dx = sin((x * time_x) * π / 180);
dx = sin((x * time_x) * π / 180);
idx = round(Int, ((2 + dx + dy) * 0.25 * 511) + 1)
g_buffer[i] = pallete[idx];
i += 1
Expand All @@ -47,4 +48,4 @@ end
# Call the function
plasma()

# ![](../assets/plasma.png)
# ![](../assets/plasma.png)
4 changes: 4 additions & 0 deletions gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MiniFB.h
MiniFB_enums.h
MiniFB_cpp.h
MiniFB_ios.h
Loading