Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
acdca5da
Commit
acdca5da
authored
May 16, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the AColor type to a gfx/ header, so other code can use it.
parent
77881a72
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
118 additions
and
81 deletions
+118
-81
src/gfx/color.cpp
src/gfx/color.cpp
+48
-1
src/gfx/color.hpp
src/gfx/color.hpp
+62
-0
src/gfx/gfx.hpp
src/gfx/gfx.hpp
+1
-21
src/gui/control/keyword_list.cpp
src/gui/control/keyword_list.cpp
+1
-1
src/gui/set/cards_panel.cpp
src/gui/set/cards_panel.cpp
+1
-3
src/mse.vcproj
src/mse.vcproj
+3
-0
src/render/symbol/filter.cpp
src/render/symbol/filter.cpp
+0
-28
src/render/symbol/filter.hpp
src/render/symbol/filter.hpp
+1
-11
src/render/text/element.cpp
src/render/text/element.cpp
+1
-0
src/util/io/reader.cpp
src/util/io/reader.cpp
+0
-13
src/util/io/reader.hpp
src/util/io/reader.hpp
+0
-3
No files found.
src/gfx/color.cpp
View file @
acdca5da
...
...
@@ -7,7 +7,54 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gfx/gfx.hpp>
#include <gfx/color.hpp>
// ----------------------------------------------------------------------------- : Parsing etc.
template
<>
void
Reader
::
handle
(
Color
&
col
)
{
col
=
parse_color
(
getValue
());
if
(
!
col
.
Ok
())
col
=
*
wxBLACK
;
}
template
<>
void
GetDefaultMember
::
handle
(
const
AColor
&
col
)
{
handle
((
const
Color
&
)
col
);
}
template
<>
void
Reader
::
handle
(
AColor
&
col
)
{
col
=
parse_acolor
(
getValue
());
if
(
!
col
.
Ok
())
col
=
AColor
(
0
,
0
,
0
,
0
);
}
template
<>
void
Writer
::
handle
(
const
AColor
&
col
)
{
if
(
col
.
alpha
==
255
)
{
handle
(
String
::
Format
(
_
(
"rgb(%u,%u,%u)"
),
col
.
Red
(),
col
.
Green
(),
col
.
Blue
()));
}
else
if
(
col
.
alpha
==
0
)
{
handle
(
_
(
"transparent"
));
}
else
{
handle
(
String
::
Format
(
_
(
"rgba(%u,%u,%u,%u)"
),
col
.
Red
(),
col
.
Green
(),
col
.
Blue
(),
col
.
alpha
));
}
}
Color
parse_color
(
const
String
&
v
)
{
UInt
r
,
g
,
b
;
if
(
wxSscanf
(
v
.
c_str
(),
_
(
"rgb(%u,%u,%u)"
),
&
r
,
&
g
,
&
b
))
{
return
Color
(
r
,
g
,
b
);
}
else
{
return
Color
(
v
);
}
}
AColor
parse_acolor
(
const
String
&
v
)
{
UInt
r
,
g
,
b
,
a
;
if
(
wxSscanf
(
v
.
c_str
(),
_
(
"rgb(%u,%u,%u)"
),
&
r
,
&
g
,
&
b
))
{
return
AColor
(
r
,
g
,
b
);
}
else
if
(
wxSscanf
(
v
.
c_str
(),
_
(
"rgba(%u,%u,%u,%u)"
),
&
r
,
&
g
,
&
b
,
&
a
))
{
return
AColor
(
r
,
g
,
b
,
a
);
}
else
if
(
v
==
_
(
"transparent"
))
{
return
AColor
(
0
,
0
,
0
,
0
);
}
else
{
return
Color
(
v
);
}
}
// ----------------------------------------------------------------------------- : Color utility functions
...
...
src/gfx/color.hpp
0 → 100644
View file @
acdca5da
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GFX_COLOR
#define HEADER_GFX_COLOR
/** @file gfx/color.hpp
*
* Color related functions and types.
*/
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
// ----------------------------------------------------------------------------- : Color with alpha
/// Color with alpha channel
class
AColor
:
public
Color
{
public:
Byte
alpha
;
///< The alpha value, in the range [0..255]
inline
AColor
()
:
alpha
(
0
)
{}
inline
AColor
(
Byte
r
,
Byte
g
,
Byte
b
,
Byte
a
=
255
)
:
Color
(
r
,
g
,
b
),
alpha
(
a
)
{}
inline
AColor
(
const
Color
&
color
,
Byte
a
=
255
)
:
Color
(
color
),
alpha
(
a
)
{}
};
// ----------------------------------------------------------------------------- : Parsing
/// Parse a color
Color
parse_color
(
const
String
&
value
);
/// Parse a color with alpha
AColor
parse_acolor
(
const
String
&
value
);
// ----------------------------------------------------------------------------- : Color utility functions
inline
int
bot
(
int
x
)
{
return
max
(
0
,
x
);
}
///< bottom range check for color values
inline
int
top
(
int
x
)
{
return
min
(
255
,
x
);
}
///< top range check for color values
inline
int
col
(
int
x
)
{
return
top
(
bot
(
x
));
}
///< top and bottom range check for color values
/// Linear interpolation between colors
Color
lerp
(
const
Color
&
a
,
const
Color
&
b
,
double
t
);
/// Linear interpolation between colors
AColor
lerp
(
const
AColor
&
a
,
const
AColor
&
b
,
double
t
);
/// convert HSL to RGB, h,s,l must be in range [0...1)
Color
hsl2rgb
(
double
h
,
double
s
,
double
l
);
/// A darker version of a color
Color
darken
(
const
Color
&
c
);
/// A saturated version of a color
Color
saturate
(
const
Color
&
c
,
double
amount
);
/// Fills an image with the specified color
void
fill_image
(
Image
&
image
,
const
Color
&
color
);
// ----------------------------------------------------------------------------- : EOF
#endif
src/gfx/gfx.hpp
View file @
acdca5da
...
...
@@ -16,6 +16,7 @@
#include <util/prec.hpp>
#include <util/real_point.hpp>
#include <gfx/color.hpp>
// ----------------------------------------------------------------------------- : Resampling
...
...
@@ -198,26 +199,5 @@ class ContourMask {
int
*
lefts
,
*
rights
;
};
// ----------------------------------------------------------------------------- : Color utility functions
inline
int
bot
(
int
x
)
{
return
max
(
0
,
x
);
}
///< bottom range check for color values
inline
int
top
(
int
x
)
{
return
min
(
255
,
x
);
}
///< top range check for color values
inline
int
col
(
int
x
)
{
return
top
(
bot
(
x
));
}
///< top and bottom range check for color values
/// Linear interpolation between colors
Color
lerp
(
const
Color
&
a
,
const
Color
&
b
,
double
t
);
/// convert HSL to RGB, h,s,l must be in range [0...1)
Color
hsl2rgb
(
double
h
,
double
s
,
double
l
);
/// A darker version of a color
Color
darken
(
const
Color
&
c
);
/// A saturated version of a color
Color
saturate
(
const
Color
&
c
,
double
amount
);
/// Fills an image with the specified color
void
fill_image
(
Image
&
image
,
const
Color
&
color
);
// ----------------------------------------------------------------------------- : EOF
#endif
src/gui/control/keyword_list.cpp
View file @
acdca5da
...
...
@@ -18,7 +18,7 @@
#include <data/format/clipboard.hpp>
#include <util/tagged_string.hpp>
#include <util/window_id.hpp>
#include <gfx/
gfx
.hpp>
#include <gfx/
color
.hpp>
#include <wx/clipbrd.h>
DECLARE_TYPEOF_COLLECTION
(
KeywordP
);
...
...
src/gui/set/cards_panel.cpp
View file @
acdca5da
...
...
@@ -209,9 +209,7 @@ void CardsPanel::onCommand(int id) {
set
->
actions
.
add
(
new
AddCardAction
(
*
set
));
break
;
case
ID_CARD_REMOVE
:
if
(
card_list
->
getCard
()
!=
nullptr
&&
set
->
cards
.
size
()
!=
1
)
//Don't delete the last card, and certainly don't delete a card if none exists.
set
->
actions
.
add
(
new
RemoveCardAction
(
*
set
,
card_list
->
getCard
()));
card_list
->
doDelete
();
break
;
case
ID_CARD_ROTATE
:
case
ID_CARD_ROTATE_0
:
case
ID_CARD_ROTATE_90
:
case
ID_CARD_ROTATE_180
:
case
ID_CARD_ROTATE_270
:
{
...
...
src/mse.vcproj
View file @
acdca5da
...
...
@@ -2399,6 +2399,9 @@
ObjectFile=
"$(IntDir)/$(InputName)3.obj"
/>
</FileConfiguration>
</File>
<File
RelativePath=
".\gfx\color.hpp"
>
</File>
<File
RelativePath=
".\gfx\combine_image.cpp"
>
<FileConfiguration
...
...
src/render/symbol/filter.cpp
View file @
acdca5da
...
...
@@ -11,34 +11,6 @@
#include <render/symbol/viewer.hpp>
#include <gfx/gfx.hpp>
#include <util/error.hpp>
#include <script/value.hpp> // for some strange reason the profile build needs this :(
// ----------------------------------------------------------------------------- : Color
template
<>
void
GetDefaultMember
::
handle
(
const
AColor
&
col
)
{
handle
((
const
Color
&
)
col
);
}
template
<>
void
Reader
::
handle
(
AColor
&
col
)
{
UInt
r
,
g
,
b
,
a
;
String
v
=
getValue
();
if
(
wxSscanf
(
v
.
c_str
(),
_
(
"rgb(%u,%u,%u)"
),
&
r
,
&
g
,
&
b
))
{
col
.
Set
(
r
,
g
,
b
);
col
.
alpha
=
255
;
}
else
if
(
wxSscanf
(
v
.
c_str
(),
_
(
"rgba(%u,%u,%u,%u)"
),
&
r
,
&
g
,
&
b
,
&
a
))
{
col
.
Set
(
r
,
g
,
b
);
col
.
alpha
=
a
;
}
else
{
col
=
Color
(
v
);
if
(
!
col
.
Ok
())
col
=
*
wxBLACK
;
}
}
template
<>
void
Writer
::
handle
(
const
AColor
&
col
)
{
if
(
col
.
alpha
==
255
)
{
handle
(
String
::
Format
(
_
(
"rgb(%u,%u,%u)"
),
col
.
Red
(),
col
.
Green
(),
col
.
Blue
()));
}
else
{
handle
(
String
::
Format
(
_
(
"rgba(%u,%u,%u,%u)"
),
col
.
Red
(),
col
.
Green
(),
col
.
Blue
(),
col
.
alpha
));
}
}
// ----------------------------------------------------------------------------- : Symbol filtering
...
...
src/render/symbol/filter.hpp
View file @
acdca5da
...
...
@@ -11,21 +11,11 @@
#include <util/prec.hpp>
#include <util/reflect.hpp>
#include <gfx/color.hpp>
DECLARE_POINTER_TYPE
(
Symbol
);
class
SymbolFilter
;
// ----------------------------------------------------------------------------- : Color
/// Color with alpha channel
class
AColor
:
public
Color
{
public:
Byte
alpha
;
///< The alpha value, in the range [0..255]
inline
AColor
()
:
alpha
(
0
)
{}
inline
AColor
(
Byte
r
,
Byte
g
,
Byte
b
,
Byte
a
=
255
)
:
Color
(
r
,
g
,
b
),
alpha
(
a
)
{}
inline
AColor
(
const
Color
&
color
,
Byte
a
=
255
)
:
Color
(
color
),
alpha
(
a
)
{}
};
// ----------------------------------------------------------------------------- : Symbol filtering
/// Filter a symbol-image.
...
...
src/render/text/element.cpp
View file @
acdca5da
...
...
@@ -10,6 +10,7 @@
#include <render/text/element.hpp>
#include <util/tagged_string.hpp>
#include <data/field/text.hpp>
#include <gfx/color.hpp>
DECLARE_TYPEOF_COLLECTION
(
TextElementP
);
DECLARE_POINTER_TYPE
(
FontTextElement
);
...
...
src/util/io/reader.cpp
View file @
acdca5da
...
...
@@ -367,19 +367,6 @@ template <> void Reader::handle(Vector2D& vec) {
}
}
template
<>
void
Reader
::
handle
(
Color
&
col
)
{
col
=
parse_color
(
getValue
());
if
(
!
col
.
Ok
())
col
=
*
wxBLACK
;
}
Color
parse_color
(
const
String
&
v
)
{
UInt
r
,
g
,
b
;
if
(
wxSscanf
(
v
.
c_str
(),
_
(
"rgb(%u,%u,%u)"
),
&
r
,
&
g
,
&
b
))
{
return
Color
(
r
,
g
,
b
);
}
else
{
return
Color
(
v
);
}
}
template
<>
void
Reader
::
handle
(
FileName
&
f
)
{
if
(
clipboard_package
())
{
String
str
=
getValue
();
...
...
src/util/io/reader.hpp
View file @
acdca5da
...
...
@@ -251,9 +251,6 @@ void Reader::handle(IndexMap<K,V>& m) {
// ----------------------------------------------------------------------------- : Reflection for enumerations
/// Parse a color
Color
parse_color
(
const
String
&
value
);
/// Implement enum reflection as used by Reader
#define REFLECT_ENUM_READER(Enum) \
template
<>
void
Reader
::
handle
<
Enum
>
(
Enum
&
enum_
)
{
\
...
...
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