Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rapidriter-cat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephen D
rapidriter-cat
Commits
946ed8d2
Commit
946ed8d2
authored
1 month ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
working
parent
cce9659a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
build.rs
+9
-3
9 additions, 3 deletions
build.rs
src/assets/cat.png
+0
-0
0 additions, 0 deletions
src/assets/cat.png
src/assets/meow.png
+0
-0
0 additions, 0 deletions
src/assets/meow.png
src/lib.rs
+26
-5
26 additions, 5 deletions
src/lib.rs
with
35 additions
and
8 deletions
build.rs
+
9
−
3
View file @
946ed8d2
...
@@ -5,10 +5,16 @@ use image::{GenericImageView, ImageReader};
...
@@ -5,10 +5,16 @@ use image::{GenericImageView, ImageReader};
// Example custom build script.
// Example custom build script.
fn
main
()
{
fn
main
()
{
println!
(
"cargo::rerun-if-changed=assets/*"
);
println!
(
"cargo::rerun-if-changed=build.rs"
);
println!
(
"cargo::rerun-if-changed=build.rs"
);
let
img
=
ImageReader
::
open
(
"src/assets/cat.png"
)
handle_image
(
"cat"
);
handle_image
(
"meow"
);
}
fn
handle_image
(
name
:
&
str
)
{
println!
(
"cargo::rerun-if-changed=src/assets/{name}.png"
);
let
img
=
ImageReader
::
open
(
format!
(
"src/assets/{name}.png"
))
.unwrap
()
.unwrap
()
.decode
()
.decode
()
.unwrap
();
.unwrap
();
...
@@ -33,6 +39,6 @@ fn main() {
...
@@ -33,6 +39,6 @@ fn main() {
let
out_dir
=
env
::
var
(
"OUT_DIR"
)
.unwrap
();
let
out_dir
=
env
::
var
(
"OUT_DIR"
)
.unwrap
();
let
mut
f
=
File
::
create
(
Path
::
new
(
&
out_dir
)
.join
(
"cat
.bin"
))
.unwrap
();
let
mut
f
=
File
::
create
(
Path
::
new
(
&
out_dir
)
.join
(
format!
(
"{name}
.bin"
))
)
.unwrap
();
f
.write_all
(
&
out
.as_raw_slice
())
.unwrap
();
f
.write_all
(
&
out
.as_raw_slice
())
.unwrap
();
}
}
This diff is collapsed.
Click to expand it.
src/assets/cat.png
+
0
−
0
View replaced file @
cce9659a
View file @
946ed8d2
737 B
|
W:
|
H:
4.41 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
src/assets/meow.png
0 → 100644
+
0
−
0
View file @
946ed8d2
4.69 KiB
This diff is collapsed.
Click to expand it.
src/lib.rs
+
26
−
5
View file @
946ed8d2
use
bitvec
::{
order
::
Msb0
,
view
::
BitView
};
use
bitvec
::{
order
::
Msb0
,
view
::
BitView
};
const
WIDTH
:
usize
=
96
;
const
WIDTH
:
i32
=
96
;
//
const HEIGHT:
usize
= 38;
const
HEIGHT
:
i32
=
38
;
#[no_mangle]
#[no_mangle]
pub
extern
"C"
fn
next_frame
(
frame
:
u16
,
ptr
:
*
mut
u8
)
->
u8
{
pub
extern
"C"
fn
next_frame
(
frame
:
u16
,
ptr
:
*
mut
u8
)
->
u8
{
...
@@ -12,19 +12,40 @@ pub extern "C" fn next_frame(frame: u16, ptr: *mut u8) -> u8 {
...
@@ -12,19 +12,40 @@ pub extern "C" fn next_frame(frame: u16, ptr: *mut u8) -> u8 {
}
}
let
cat
=
include_bytes!
(
concat!
(
env!
(
"OUT_DIR"
),
"/cat.bin"
))
.view_bits
::
<
Msb0
>
();
let
cat
=
include_bytes!
(
concat!
(
env!
(
"OUT_DIR"
),
"/cat.bin"
))
.view_bits
::
<
Msb0
>
();
let
meow
=
include_bytes!
(
concat!
(
env!
(
"OUT_DIR"
),
"/meow.bin"
))
.view_bits
::
<
Msb0
>
();
let
thres
=
WIDTH
/
4
;
let
dx
=
(
frame
as
i32
*
4
-
thres
)
.min
(
thres
);
for
x
in
0
..
96
{
for
x
in
0
..
96
{
for
y
in
0
..
38
{
for
y
in
0
..
38
{
let
out_idx
=
index
(
x
,
y
);
let
out_idx
=
index
(
x
,
y
);
let
in_idx
=
index
(
(
x
-
frame
as
usize
*
4
)
%
WIDTH
,
y
);
let
in_idx
=
index
(
x
-
dx
,
y
);
out
.set
(
out_idx
,
cat
[
in_idx
]);
out
.set
(
out_idx
,
cat
[
in_idx
]);
}
}
}
}
if
dx
==
thres
&&
frame
/
7
%
2
==
0
{
// make meow flash on and off every 4 frames for the remaining time
for
x
in
0
..
96
{
for
y
in
0
..
38
{
let
idx
=
index
(
x
,
y
);
out
.set
(
idx
,
meow
[
idx
]
||
out
[
idx
]);
}
}
}
0
0
}
}
fn
index
(
x
:
usize
,
y
:
usize
)
->
usize
{
fn
index
(
x
:
i32
,
y
:
i32
)
->
usize
{
x
+
y
*
WIDTH
if
x
<
0
||
y
<
0
||
x
>=
WIDTH
||
y
>=
HEIGHT
{
return
0
;
}
x
as
usize
+
y
as
usize
*
WIDTH
as
usize
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment