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
8d02875e
Commit
8d02875e
authored
1 month ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
jess duck
parent
946ed8d2
Branches
duck
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
build.rs
+1
-2
1 addition, 2 deletions
build.rs
src/assets/duck.png
+0
-0
0 additions, 0 deletions
src/assets/duck.png
src/lib.rs
+3
-40
3 additions, 40 deletions
src/lib.rs
with
4 additions
and
42 deletions
build.rs
+
1
−
2
View file @
8d02875e
...
...
@@ -7,8 +7,7 @@ use image::{GenericImageView, ImageReader};
fn
main
()
{
println!
(
"cargo::rerun-if-changed=build.rs"
);
handle_image
(
"cat"
);
handle_image
(
"meow"
);
handle_image
(
"duck"
);
}
fn
handle_image
(
name
:
&
str
)
{
...
...
This diff is collapsed.
Click to expand it.
src/assets/duck.png
0 → 100644
+
0
−
0
View file @
8d02875e
1.05 KiB
This diff is collapsed.
Click to expand it.
src/lib.rs
+
3
−
40
View file @
8d02875e
use
bitvec
::{
order
::
Msb0
,
view
::
BitView
};
const
WIDTH
:
i32
=
96
;
const
HEIGHT
:
i32
=
38
;
#[no_mangle]
pub
extern
"C"
fn
next_frame
(
frame
:
u16
,
ptr
:
*
mut
u8
)
->
u8
{
let
out
=
unsafe
{
std
::
slice
::
from_raw_parts_mut
(
ptr
,
456
)
}
.view_bits_mut
::
<
Msb0
>
()
;
let
out
=
unsafe
{
std
::
slice
::
from_raw_parts_mut
(
ptr
,
456
)
};
if
frame
>
100
{
return
1
;
}
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
y
in
0
..
38
{
let
out_idx
=
index
(
x
,
y
);
let
in_idx
=
index
(
x
-
dx
,
y
);
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
);
let
duck
=
include_bytes!
(
concat!
(
env!
(
"OUT_DIR"
),
"/duck.bin"
));
out
.set
(
idx
,
meow
[
idx
]
||
out
[
idx
]);
}
}
}
out
.copy_from_slice
(
duck
);
0
}
fn
index
(
x
:
i32
,
y
:
i32
)
->
usize
{
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