Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jenny
pixelspammer
Commits
225affda
Verified
Commit
225affda
authored
Nov 01, 2021
by
Jenny
Browse files
unified draw_area methods
parent
e4153567
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/circle.rs
View file @
225affda
use
std
::
io
::
prelude
::
Write
;
use
std
::
net
::
TcpStream
;
use
std
::
thread
;
use
std
::
thread
::
JoinHandle
;
use
rand
::
thread_rng
;
use
rand
::
seq
::
SliceRandom
;
fn
draw_circle_slice
(
host
:
String
,
area
:
Vec
<
String
>
)
{
let
mut
stream
=
TcpStream
::
connect
(
host
)
.expect
(
"Failed to connect!"
);
let
area_string
:
String
=
area
.into_iter
()
.collect
();
loop
{
stream
.write
(
area_string
.as_bytes
())
.expect
(
"Failed to send message!"
);
}
}
use
crate
::
utils
;
pub
fn
draw_circle
(
host
:
&
str
,
color
:
&
str
,
slices
:
u8
,
radius
:
u16
,
center_x
:
u16
,
center_y
:
u16
,
shuffle
:
bool
)
{
let
center_x
=
center_x
as
i32
;
...
...
@@ -90,7 +79,7 @@ pub fn draw_circle(host: &str, color: &str, slices: u8, radius: u16, center_x: u
}
let
t
=
thread
::
spawn
(
move
||
{
draw_circle_slice
(
host_string
,
slice_area
);
utils
::
draw_area
(
host_string
,
slice_area
);
});
threads
.push
(
t
);
...
...
src/image.rs
View file @
225affda
use
std
::
io
::
prelude
::
Write
;
use
std
::
net
::
TcpStream
;
use
std
::
path
::
Path
;
use
std
::
thread
;
...
...
@@ -8,17 +6,9 @@ use std::thread::JoinHandle;
use
rand
::
thread_rng
;
use
rand
::
seq
::
SliceRandom
;
use
image
::
GenericImageView
;
fn
draw_image_slice
(
host
:
String
,
area
:
Vec
<
String
>
)
{
let
mut
stream
=
TcpStream
::
connect
(
host
)
.expect
(
"Failed to connect!"
);
let
area_string
:
String
=
area
.into_iter
()
.collect
();
use
crate
::
utils
;
loop
{
stream
.write
(
area_string
.as_bytes
())
.expect
(
"Failed to send message!"
);
}
}
use
image
::
GenericImageView
;
pub
fn
draw_image
(
image_path
:
&
str
,
host
:
&
str
,
slices
:
u8
,
offset_x
:
u32
,
offset_y
:
u32
,
shuffle
:
bool
,
skip_alpha
:
u8
)
{
let
img
=
image
::
open
(
Path
::
new
(
image_path
))
.expect
(
"Failed to open image!"
);
...
...
@@ -68,7 +58,7 @@ pub fn draw_image(image_path: &str, host: &str, slices: u8, offset_x: u32, offse
}
let
t
=
thread
::
spawn
(
move
||
{
draw_image_slice
(
host_string
,
slice_area
);
utils
::
draw_area
(
host_string
,
slice_area
);
});
threads
.push
(
t
);
...
...
src/main.rs
View file @
225affda
...
...
@@ -3,6 +3,7 @@ use clap::{Arg, App};
mod
image
;
mod
rect
;
mod
circle
;
mod
utils
;
const
VERSION
:
&
str
=
"1.4.0"
;
const
AUTHOR
:
&
str
=
"Netali <me@netali.de>"
;
...
...
src/rect.rs
View file @
225affda
use
std
::
io
::
prelude
::
Write
;
use
std
::
net
::
TcpStream
;
use
std
::
thread
;
use
std
::
thread
::
JoinHandle
;
use
rand
::
thread_rng
;
use
rand
::
seq
::
SliceRandom
;
fn
draw_rect_slice
(
host
:
String
,
area
:
Vec
<
String
>
)
{
let
mut
stream
=
TcpStream
::
connect
(
host
)
.expect
(
"Failed to connect!"
);
let
area_string
:
String
=
area
.into_iter
()
.collect
();
loop
{
stream
.write
(
area_string
.as_bytes
())
.expect
(
"Failed to send message!"
);
}
}
use
crate
::
utils
;
pub
fn
draw_rect
(
host
:
&
str
,
color
:
&
str
,
slices
:
u8
,
height
:
u32
,
width
:
u32
,
offset_x
:
u32
,
offset_y
:
u32
,
shuffle
:
bool
)
{
let
mut
area
:
Vec
<
String
>
=
Vec
::
new
();
...
...
@@ -57,7 +45,7 @@ pub fn draw_rect(host: &str, color: &str, slices: u8, height: u32, width: u32, o
}
let
t
=
thread
::
spawn
(
move
||
{
draw_re
ct_slice
(
host_string
,
slice_area
);
utils
::
draw_
a
re
a
(
host_string
,
slice_area
);
});
threads
.push
(
t
);
...
...
src/utils.rs
0 → 100644
View file @
225affda
use
std
::
io
::
prelude
::
Write
;
use
std
::
net
::
TcpStream
;
pub
fn
draw_area
(
host
:
String
,
area
:
Vec
<
String
>
)
{
let
mut
stream
=
TcpStream
::
connect
(
host
)
.expect
(
"Failed to connect!"
);
let
area_string
:
String
=
area
.into_iter
()
.collect
();
loop
{
stream
.write
(
area_string
.as_bytes
())
.expect
(
"Failed to send message!"
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment