Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
90df1d67
Unverified
Commit
90df1d67
authored
Jul 18, 2019
by
Aaron Franke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Color with alpha constructor
parent
92d4a0cb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
7 deletions
+41
-7
color.h
core/color.h
+11
-1
variant.cpp
core/variant.cpp
+0
-5
variant_call.cpp
core/variant_call.cpp
+7
-0
Color.xml
doc/classes/Color.xml
+14
-0
Color.cs
modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
+9
-1
No files found.
core/color.h
View file @
90df1d67
...
...
@@ -205,7 +205,7 @@ struct Color {
operator
String
()
const
;
/**
* No construct parameters, r=0, g=0, b=0. a=
255
* No construct parameters, r=0, g=0, b=0. a=
1
*/
_FORCE_INLINE_
Color
()
{
r
=
0
;
...
...
@@ -223,6 +223,16 @@ struct Color {
b
=
p_b
;
a
=
p_a
;
}
/**
* Construct a Color from another Color, but with the specified alpha value.
*/
_FORCE_INLINE_
Color
(
const
Color
&
p_c
,
float
p_a
)
{
r
=
p_c
.
r
;
g
=
p_c
.
g
;
b
=
p_c
.
b
;
a
=
p_a
;
}
};
bool
Color
::
operator
<
(
const
Color
&
p_color
)
const
{
...
...
core/variant.cpp
View file @
90df1d67
...
...
@@ -102,11 +102,6 @@ String Variant::get_type_name(Variant::Type p_type) {
return
"Plane"
;
}
break
;
/*
case QUAT: {
} break;*/
case
AABB
:
{
return
"AABB"
;
...
...
core/variant_call.cpp
View file @
90df1d67
...
...
@@ -1075,6 +1075,11 @@ struct _VariantCall {
r_ret
=
Color
::
hex
(
*
p_args
[
0
]);
}
static
void
Color_init5
(
Variant
&
r_ret
,
const
Variant
**
p_args
)
{
r_ret
=
Color
(((
Color
)(
*
p_args
[
0
])),
*
p_args
[
1
]);
}
static
void
AABB_init1
(
Variant
&
r_ret
,
const
Variant
**
p_args
)
{
r_ret
=
::
AABB
(
*
p_args
[
0
],
*
p_args
[
1
]);
...
...
@@ -2209,6 +2214,8 @@ void register_variant_methods() {
_VariantCall
::
add_constructor
(
_VariantCall
::
Color_init1
,
Variant
::
COLOR
,
"r"
,
Variant
::
FLOAT
,
"g"
,
Variant
::
FLOAT
,
"b"
,
Variant
::
FLOAT
,
"a"
,
Variant
::
FLOAT
);
_VariantCall
::
add_constructor
(
_VariantCall
::
Color_init2
,
Variant
::
COLOR
,
"r"
,
Variant
::
FLOAT
,
"g"
,
Variant
::
FLOAT
,
"b"
,
Variant
::
FLOAT
);
// init3 and init4 are the constructors for HTML hex strings and integers respectively which don't need binding here, so we skip to init5.
_VariantCall
::
add_constructor
(
_VariantCall
::
Color_init5
,
Variant
::
COLOR
,
"c"
,
Variant
::
COLOR
,
"a"
,
Variant
::
FLOAT
);
_VariantCall
::
add_constructor
(
_VariantCall
::
AABB_init1
,
Variant
::
AABB
,
"position"
,
Variant
::
VECTOR3
,
"size"
,
Variant
::
VECTOR3
);
...
...
doc/classes/Color.xml
View file @
90df1d67
...
...
@@ -42,6 +42,20 @@
<method
name=
"Color"
>
<return
type=
"Color"
>
</return>
<argument
index=
"0"
name=
"c"
type=
"Color"
>
</argument>
<argument
index=
"1"
name=
"a"
type=
"float"
>
</argument>
<description>
Constructs a color from an existing color, but with a custom alpha value.
[codeblock]
var red = Color(Color.red, 0.5) # 50% transparent red.
[/codeblock]
</description>
</method>
<method
name=
"Color"
>
<return
type=
"Color"
>
</return>
<argument
index=
"0"
name=
"r"
type=
"float"
>
</argument>
<argument
index=
"1"
name=
"g"
type=
"float"
>
...
...
modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
View file @
90df1d67
...
...
@@ -420,7 +420,7 @@ namespace Godot
return
txt
;
}
// Constructors
// Constructors
public
Color
(
float
r
,
float
g
,
float
b
,
float
a
=
1.0f
)
{
this
.
r
=
r
;
...
...
@@ -429,6 +429,14 @@ namespace Godot
this
.
a
=
a
;
}
public
Color
(
Color
c
,
float
a
=
1.0f
)
{
r
=
c
.
r
;
g
=
c
.
g
;
b
=
c
.
b
;
this
.
a
=
a
;
}
public
Color
(
uint
rgba
)
{
a
=
(
rgba
&
0xFF
)
/
255.0f
;
...
...
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