Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Reversi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
Reversi
Commits
d61c2811
Commit
d61c2811
authored
Feb 23, 2019
by
Arnaud B.
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a texture.
parent
d1b061d5
Pipeline
#62032
passed with stages
in 1 minute and 9 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
3 deletions
+57
-3
data/iagno.gresource.xml
data/iagno.gresource.xml
+1
-0
data/noise.png
data/noise.png
+0
-0
data/noise.xcf
data/noise.xcf
+0
-0
data/themes/adwaita.theme.desktop.in
data/themes/adwaita.theme.desktop.in
+1
-0
data/themes/classic.theme.desktop.in
data/themes/classic.theme.desktop.in
+1
-0
data/themes/high_contrast.theme.desktop.in
data/themes/high_contrast.theme.desktop.in
+1
-0
data/themes/sun_and_star.theme.desktop.in
data/themes/sun_and_star.theme.desktop.in
+1
-0
src/game-view.vala
src/game-view.vala
+52
-3
No files found.
data/iagno.gresource.xml
View file @
d61c2811
...
...
@@ -5,5 +5,6 @@
<file
preprocess=
"xml-stripblanks"
compressed=
"true"
alias=
"themes.ui"
>
ui/iagno-themes.ui
</file>
<file
preprocess=
"xml-stripblanks"
compressed=
"true"
alias=
"iagno-screens.ui"
>
ui/iagno-screens.ui
</file>
<file
compressed=
"true"
>
iagno.css
</file>
<file>
noise.png
</file>
</gresource>
</gresources>
data/noise.png
0 → 100644
View file @
d61c2811
11.2 KB
data/noise.xcf
0 → 100644
View file @
d61c2811
File added
data/themes/adwaita.theme.desktop.in
View file @
d61c2811
...
...
@@ -14,6 +14,7 @@ Green=0.4
Blue=0.6
# Radius=9
Radius=2
TextureAlpha=0.25
[Mark]
Red=0.2
...
...
data/themes/classic.theme.desktop.in
View file @
d61c2811
...
...
@@ -13,6 +13,7 @@ Red=0.2
Green=0.6
Blue=0.4
Radius=2
TextureAlpha=0.25
[Mark]
Red=0.5
...
...
data/themes/high_contrast.theme.desktop.in
View file @
d61c2811
...
...
@@ -14,6 +14,7 @@ Green=1.0
Blue=1.0
# Radius=9
Radius=0
TextureAlpha=0.0
[Mark]
Red=0.4
...
...
data/themes/sun_and_star.theme.desktop.in
View file @
d61c2811
...
...
@@ -13,6 +13,7 @@ Red=0.2
Green=0.6
Blue=0.4
Radius=2
TextureAlpha=0.25
[Mark]
Red=0.2
...
...
src/game-view.vala
View file @
d61c2811
...
...
@@ -38,6 +38,9 @@ private class GameView : Gtk.DrawingArea
private
double
background_blue
=
0.4
;
private
int
background_radius
=
0
;
private
double
texture_alpha
=
0.25
;
private
bool
apply_texture
=
false
;
private
double
mark_red
=
0.2
;
private
double
mark_green
=
0.6
;
private
double
mark_blue
=
0.4
;
...
...
@@ -82,6 +85,10 @@ private class GameView : Gtk.DrawingArea
private
Cairo
.
Pattern
?
tiles_pattern
=
null
;
private
Cairo
.
Pattern
?
scoreboard_tiles_pattern
=
null
;
private
bool
noise_pixbuf_loaded
=
false
;
private
Gdk
.
Pixbuf
?
noise_pixbuf
=
null
;
private
Cairo
.
Pattern
?
noise_pattern
=
null
;
/* The images being showed on each location */
private
int
[,]
pixmaps
;
...
...
@@ -212,6 +219,9 @@ private class GameView : Gtk.DrawingArea
background_blue
=
key
.
get_double
(
"Background"
,
"Blue"
);
background_radius
=
key
.
get_integer
(
"Background"
,
"Radius"
);
texture_alpha
=
key
.
get_double
(
"Background"
,
"TextureAlpha"
);
apply_texture
=
(
texture_alpha
>
0.0
)
&&
(
texture_alpha
<=
1.0
);
mark_red
=
key
.
get_double
(
"Mark"
,
"Red"
);
mark_green
=
key
.
get_double
(
"Mark"
,
"Green"
);
mark_blue
=
key
.
get_double
(
"Mark"
,
"Blue"
);
...
...
@@ -271,10 +281,40 @@ private class GameView : Gtk.DrawingArea
if
(
tiles_pattern
==
null
||
render_size
!=
tile_size
)
{
render_size
=
tile_size
;
var
surface
=
new
Cairo
.
Surface
.
similar
(
cr
.
get_target
(),
Cairo
.
Content
.
COLOR_ALPHA
,
tile_size
*
8
,
tile_size
*
4
);
var
c
=
new
Cairo
.
Context
(
surface
);
load_image
(
c
,
tile_size
*
8
,
tile_size
*
4
);
Cairo
.
Surface
surface
;
Cairo
.
Context
context
;
surface
=
new
Cairo
.
Surface
.
similar
(
cr
.
get_target
(),
Cairo
.
Content
.
COLOR_ALPHA
,
tile_size
*
8
,
tile_size
*
4
);
context
=
new
Cairo
.
Context
(
surface
);
load_image
(
context
,
tile_size
*
8
,
tile_size
*
4
);
tiles_pattern
=
new
Cairo
.
Pattern
.
for_surface
(
surface
);
if
(
apply_texture
)
{
try
{
noise_pixbuf
=
new
Gdk
.
Pixbuf
.
from_resource_at_scale
(
"/org/gnome/Reversi/ui/noise.png"
,
/* x */
tile_size
,
/* y */
tile_size
,
/* preserve aspect ratio */
false
);
}
catch
(
Error
e
)
{
warning
(
e
.
message
);
}
noise_pixbuf_loaded
=
noise_pixbuf
!=
null
;
if
(
noise_pixbuf_loaded
)
{
surface
=
new
Cairo
.
Surface
.
similar
(
cr
.
get_target
(),
Cairo
.
Content
.
COLOR_ALPHA
,
tile_size
,
tile_size
);
context
=
new
Cairo
.
Context
(
surface
);
Gdk
.
cairo_set_source_pixbuf
(
context
,
(!)
noise_pixbuf
,
0
,
0
);
context
.
paint_with_alpha
(
texture_alpha
);
// or surface = Gdk.cairo_surface_create_from_pixbuf ((!) noise_pixbuf, 0, null); ?
noise_pattern
=
new
Cairo
.
Pattern
.
for_surface
(
surface
);
// ((!) noise_pattern).set_extend (Cairo.Extend.REPEAT);
}
}
}
cr
.
translate
(
board_x
,
board_y
);
...
...
@@ -298,6 +338,15 @@ private class GameView : Gtk.DrawingArea
/* draw background */
cr
.
set_source_rgba
(
background_red
,
background_green
,
background_blue
,
1.0
);
rounded_square
(
cr
,
tile_x
,
tile_y
,
tile_size
,
0
,
background_radius
);
if
(
apply_texture
&&
noise_pixbuf_loaded
)
{
cr
.
fill_preserve
();
var
matrix
=
Cairo
.
Matrix
.
identity
();
matrix
.
translate
(-
tile_x
,
-
tile_y
);
((!)
noise_pattern
).
set_matrix
(
matrix
);
cr
.
set_source
((!)
noise_pattern
);
}
cr
.
fill
();
if
((
highlight_x
==
x
&&
highlight_y
==
y
)
...
...
Arnaud B.
@arnaudb
mentioned in issue
#4 (closed)
·
Feb 23, 2019
mentioned in issue
#4 (closed)
mentioned in issue #4
Toggle commit list
Write
Preview
Markdown
is supported
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