google-cloud-vision 0.38.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +343 -0
  6. data/README.md +35 -49
  7. data/lib/{google/cloud/vision/v1/doc/google/protobuf/wrappers.rb → google-cloud-vision.rb} +4 -11
  8. data/lib/google/cloud/vision.rb +131 -214
  9. data/lib/google/cloud/vision/version.rb +6 -2
  10. metadata +73 -101
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/vision/v1.rb +0 -249
  13. data/lib/google/cloud/vision/v1/credentials.rb +0 -42
  14. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/geometry.rb +0 -66
  15. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +0 -923
  16. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search.rb +0 -115
  17. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search_service.rb +0 -569
  18. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +0 -254
  19. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb +0 -102
  20. data/lib/google/cloud/vision/v1/doc/google/longrunning/operations.rb +0 -51
  21. data/lib/google/cloud/vision/v1/doc/google/protobuf/any.rb +0 -131
  22. data/lib/google/cloud/vision/v1/doc/google/protobuf/empty.rb +0 -29
  23. data/lib/google/cloud/vision/v1/doc/google/protobuf/field_mask.rb +0 -222
  24. data/lib/google/cloud/vision/v1/doc/google/protobuf/timestamp.rb +0 -113
  25. data/lib/google/cloud/vision/v1/doc/google/rpc/status.rb +0 -39
  26. data/lib/google/cloud/vision/v1/doc/google/type/color.rb +0 -161
  27. data/lib/google/cloud/vision/v1/doc/google/type/latlng.rb +0 -31
  28. data/lib/google/cloud/vision/v1/geometry_pb.rb +0 -39
  29. data/lib/google/cloud/vision/v1/helpers.rb +0 -1154
  30. data/lib/google/cloud/vision/v1/image_annotator_client.rb +0 -519
  31. data/lib/google/cloud/vision/v1/image_annotator_client_config.json +0 -46
  32. data/lib/google/cloud/vision/v1/image_annotator_pb.rb +0 -344
  33. data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +0 -74
  34. data/lib/google/cloud/vision/v1/product_search_client.rb +0 -1493
  35. data/lib/google/cloud/vision/v1/product_search_client_config.json +0 -121
  36. data/lib/google/cloud/vision/v1/product_search_pb.rb +0 -54
  37. data/lib/google/cloud/vision/v1/product_search_service_pb.rb +0 -207
  38. data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +0 -233
  39. data/lib/google/cloud/vision/v1/text_annotation_pb.rb +0 -94
  40. data/lib/google/cloud/vision/v1/web_detection_pb.rb +0 -51
  41. data/lib/google/cloud/vision/v1p3beta1.rb +0 -249
  42. data/lib/google/cloud/vision/v1p3beta1/credentials.rb +0 -42
  43. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +0 -72
  44. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +0 -763
  45. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +0 -156
  46. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +0 -536
  47. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +0 -255
  48. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +0 -101
  49. data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +0 -51
  50. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +0 -131
  51. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb +0 -29
  52. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +0 -222
  53. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +0 -113
  54. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +0 -26
  55. data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +0 -39
  56. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +0 -161
  57. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +0 -31
  58. data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +0 -43
  59. data/lib/google/cloud/vision/v1p3beta1/helpers.rb +0 -1154
  60. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +0 -315
  61. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client_config.json +0 -36
  62. data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +0 -306
  63. data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +0 -56
  64. data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +0 -1418
  65. data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +0 -116
  66. data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +0 -65
  67. data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +0 -194
  68. data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +0 -223
  69. data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +0 -94
  70. data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +0 -51
@@ -1,29 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # A generic empty message that you can re-use to avoid defining duplicated
19
- # empty messages in your APIs. A typical example is to use it as the request
20
- # or the response type of an API method. For instance:
21
- #
22
- # service Foo {
23
- # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
24
- # }
25
- #
26
- # The JSON representation for `Empty` is empty JSON object `{}`.
27
- class Empty; end
28
- end
29
- end
@@ -1,222 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # `FieldMask` represents a set of symbolic field paths, for example:
19
- #
20
- # paths: "f.a"
21
- # paths: "f.b.d"
22
- #
23
- # Here `f` represents a field in some root message, `a` and `b`
24
- # fields in the message found in `f`, and `d` a field found in the
25
- # message in `f.b`.
26
- #
27
- # Field masks are used to specify a subset of fields that should be
28
- # returned by a get operation or modified by an update operation.
29
- # Field masks also have a custom JSON encoding (see below).
30
- #
31
- # = Field Masks in Projections
32
- #
33
- # When used in the context of a projection, a response message or
34
- # sub-message is filtered by the API to only contain those fields as
35
- # specified in the mask. For example, if the mask in the previous
36
- # example is applied to a response message as follows:
37
- #
38
- # f {
39
- # a : 22
40
- # b {
41
- # d : 1
42
- # x : 2
43
- # }
44
- # y : 13
45
- # }
46
- # z: 8
47
- #
48
- # The result will not contain specific values for fields x,y and z
49
- # (their value will be set to the default, and omitted in proto text
50
- # output):
51
- #
52
- #
53
- # f {
54
- # a : 22
55
- # b {
56
- # d : 1
57
- # }
58
- # }
59
- #
60
- # A repeated field is not allowed except at the last position of a
61
- # paths string.
62
- #
63
- # If a FieldMask object is not present in a get operation, the
64
- # operation applies to all fields (as if a FieldMask of all fields
65
- # had been specified).
66
- #
67
- # Note that a field mask does not necessarily apply to the
68
- # top-level response message. In case of a REST get operation, the
69
- # field mask applies directly to the response, but in case of a REST
70
- # list operation, the mask instead applies to each individual message
71
- # in the returned resource list. In case of a REST custom method,
72
- # other definitions may be used. Where the mask applies will be
73
- # clearly documented together with its declaration in the API. In
74
- # any case, the effect on the returned resource/resources is required
75
- # behavior for APIs.
76
- #
77
- # = Field Masks in Update Operations
78
- #
79
- # A field mask in update operations specifies which fields of the
80
- # targeted resource are going to be updated. The API is required
81
- # to only change the values of the fields as specified in the mask
82
- # and leave the others untouched. If a resource is passed in to
83
- # describe the updated values, the API ignores the values of all
84
- # fields not covered by the mask.
85
- #
86
- # If a repeated field is specified for an update operation, new values will
87
- # be appended to the existing repeated field in the target resource. Note that
88
- # a repeated field is only allowed in the last position of a `paths` string.
89
- #
90
- # If a sub-message is specified in the last position of the field mask for an
91
- # update operation, then new value will be merged into the existing sub-message
92
- # in the target resource.
93
- #
94
- # For example, given the target message:
95
- #
96
- # f {
97
- # b {
98
- # d: 1
99
- # x: 2
100
- # }
101
- # c: [1]
102
- # }
103
- #
104
- # And an update message:
105
- #
106
- # f {
107
- # b {
108
- # d: 10
109
- # }
110
- # c: [2]
111
- # }
112
- #
113
- # then if the field mask is:
114
- #
115
- # paths: ["f.b", "f.c"]
116
- #
117
- # then the result will be:
118
- #
119
- # f {
120
- # b {
121
- # d: 10
122
- # x: 2
123
- # }
124
- # c: [1, 2]
125
- # }
126
- #
127
- # An implementation may provide options to override this default behavior for
128
- # repeated and message fields.
129
- #
130
- # In order to reset a field's value to the default, the field must
131
- # be in the mask and set to the default value in the provided resource.
132
- # Hence, in order to reset all fields of a resource, provide a default
133
- # instance of the resource and set all fields in the mask, or do
134
- # not provide a mask as described below.
135
- #
136
- # If a field mask is not present on update, the operation applies to
137
- # all fields (as if a field mask of all fields has been specified).
138
- # Note that in the presence of schema evolution, this may mean that
139
- # fields the client does not know and has therefore not filled into
140
- # the request will be reset to their default. If this is unwanted
141
- # behavior, a specific service may require a client to always specify
142
- # a field mask, producing an error if not.
143
- #
144
- # As with get operations, the location of the resource which
145
- # describes the updated values in the request message depends on the
146
- # operation kind. In any case, the effect of the field mask is
147
- # required to be honored by the API.
148
- #
149
- # == Considerations for HTTP REST
150
- #
151
- # The HTTP kind of an update operation which uses a field mask must
152
- # be set to PATCH instead of PUT in order to satisfy HTTP semantics
153
- # (PUT must only be used for full updates).
154
- #
155
- # = JSON Encoding of Field Masks
156
- #
157
- # In JSON, a field mask is encoded as a single string where paths are
158
- # separated by a comma. Fields name in each path are converted
159
- # to/from lower-camel naming conventions.
160
- #
161
- # As an example, consider the following message declarations:
162
- #
163
- # message Profile {
164
- # User user = 1;
165
- # Photo photo = 2;
166
- # }
167
- # message User {
168
- # string display_name = 1;
169
- # string address = 2;
170
- # }
171
- #
172
- # In proto a field mask for `Profile` may look as such:
173
- #
174
- # mask {
175
- # paths: "user.display_name"
176
- # paths: "photo"
177
- # }
178
- #
179
- # In JSON, the same mask is represented as below:
180
- #
181
- # {
182
- # mask: "user.displayName,photo"
183
- # }
184
- #
185
- # = Field Masks and Oneof Fields
186
- #
187
- # Field masks treat fields in oneofs just as regular fields. Consider the
188
- # following message:
189
- #
190
- # message SampleMessage {
191
- # oneof test_oneof {
192
- # string name = 4;
193
- # SubMessage sub_message = 9;
194
- # }
195
- # }
196
- #
197
- # The field mask can be:
198
- #
199
- # mask {
200
- # paths: "name"
201
- # }
202
- #
203
- # Or:
204
- #
205
- # mask {
206
- # paths: "sub_message"
207
- # }
208
- #
209
- # Note that oneof type names ("test_oneof" in this case) cannot be used in
210
- # paths.
211
- #
212
- # == Field Mask Verification
213
- #
214
- # The implementation of any API method which has a FieldMask type field in the
215
- # request should verify the included field paths, and return an
216
- # `INVALID_ARGUMENT` error if any path is duplicated or unmappable.
217
- # @!attribute [rw] paths
218
- # @return [Array<String>]
219
- # The set of field mask paths.
220
- class FieldMask; end
221
- end
222
- end
@@ -1,113 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # A Timestamp represents a point in time independent of any time zone or local
19
- # calendar, encoded as a count of seconds and fractions of seconds at
20
- # nanosecond resolution. The count is relative to an epoch at UTC midnight on
21
- # January 1, 1970, in the proleptic Gregorian calendar which extends the
22
- # Gregorian calendar backwards to year one.
23
- #
24
- # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
25
- # second table is needed for interpretation, using a [24-hour linear
26
- # smear](https://developers.google.com/time/smear).
27
- #
28
- # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
29
- # restricting to that range, we ensure that we can convert to and from [RFC
30
- # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
31
- #
32
- # = Examples
33
- #
34
- # Example 1: Compute Timestamp from POSIX `time()`.
35
- #
36
- # Timestamp timestamp;
37
- # timestamp.set_seconds(time(NULL));
38
- # timestamp.set_nanos(0);
39
- #
40
- # Example 2: Compute Timestamp from POSIX `gettimeofday()`.
41
- #
42
- # struct timeval tv;
43
- # gettimeofday(&tv, NULL);
44
- #
45
- # Timestamp timestamp;
46
- # timestamp.set_seconds(tv.tv_sec);
47
- # timestamp.set_nanos(tv.tv_usec * 1000);
48
- #
49
- # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
50
- #
51
- # FILETIME ft;
52
- # GetSystemTimeAsFileTime(&ft);
53
- # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
54
- #
55
- # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
56
- # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
57
- # Timestamp timestamp;
58
- # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
59
- # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
60
- #
61
- # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
62
- #
63
- # long millis = System.currentTimeMillis();
64
- #
65
- # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
66
- # .setNanos((int) ((millis % 1000) * 1000000)).build();
67
- #
68
- #
69
- # Example 5: Compute Timestamp from current time in Python.
70
- #
71
- # timestamp = Timestamp()
72
- # timestamp.GetCurrentTime()
73
- #
74
- # = JSON Mapping
75
- #
76
- # In JSON format, the Timestamp type is encoded as a string in the
77
- # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
78
- # format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
79
- # where {year} is always expressed using four digits while {month}, {day},
80
- # {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
81
- # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
82
- # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
83
- # is required. A proto3 JSON serializer should always use UTC (as indicated by
84
- # "Z") when printing the Timestamp type and a proto3 JSON parser should be
85
- # able to accept both UTC and other timezones (as indicated by an offset).
86
- #
87
- # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
88
- # 01:30 UTC on January 15, 2017.
89
- #
90
- # In JavaScript, one can convert a Date object to this format using the
91
- # standard
92
- # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
93
- # method. In Python, a standard `datetime.datetime` object can be converted
94
- # to this format using
95
- # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
96
- # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
97
- # the Joda Time's [`ISODateTimeFormat.dateTime()`](
98
- # http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
99
- # ) to obtain a formatter capable of generating timestamps in this format.
100
- # @!attribute [rw] seconds
101
- # @return [Integer]
102
- # Represents seconds of UTC time since Unix epoch
103
- # 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
104
- # 9999-12-31T23:59:59Z inclusive.
105
- # @!attribute [rw] nanos
106
- # @return [Integer]
107
- # Non-negative fractions of a second at nanosecond resolution. Negative
108
- # second values with fractions must still have non-negative nanos values
109
- # that count forward in time. Must be from 0 to 999,999,999
110
- # inclusive.
111
- class Timestamp; end
112
- end
113
- end
@@ -1,26 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # Wrapper message for `float`.
19
- #
20
- # The JSON representation for `FloatValue` is JSON number.
21
- # @!attribute [rw] value
22
- # @return [Float]
23
- # The float value.
24
- class FloatValue; end
25
- end
26
- end
@@ -1,39 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Rpc
18
- # The `Status` type defines a logical error model that is suitable for
19
- # different programming environments, including REST APIs and RPC APIs. It is
20
- # used by [gRPC](https://github.com/grpc). Each `Status` message contains
21
- # three pieces of data: error code, error message, and error details.
22
- #
23
- # You can find out more about this error model and how to work with it in the
24
- # [API Design Guide](https://cloud.google.com/apis/design/errors).
25
- # @!attribute [rw] code
26
- # @return [Integer]
27
- # The status code, which should be an enum value of {Google::Rpc::Code}.
28
- # @!attribute [rw] message
29
- # @return [String]
30
- # A developer-facing error message, which should be in English. Any
31
- # user-facing error message should be localized and sent in the
32
- # {Google::Rpc::Status#details} field, or localized by the client.
33
- # @!attribute [rw] details
34
- # @return [Array<Google::Protobuf::Any>]
35
- # A list of messages that carry the error details. There is a common set of
36
- # message types for APIs to use.
37
- class Status; end
38
- end
39
- end
@@ -1,161 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Type
18
- # Represents a color in the RGBA color space. This representation is designed
19
- # for simplicity of conversion to/from color representations in various
20
- # languages over compactness; for example, the fields of this representation
21
- # can be trivially provided to the constructor of "java.awt.Color" in Java; it
22
- # can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
23
- # method in iOS; and, with just a little work, it can be easily formatted into
24
- # a CSS "rgba()" string in JavaScript, as well.
25
- #
26
- # Note: this proto does not carry information about the absolute color space
27
- # that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB,
28
- # DCI-P3, BT.2020, etc.). By default, applications SHOULD assume the sRGB color
29
- # space.
30
- #
31
- # Example (Java):
32
- #
33
- # import com.google.type.Color;
34
- #
35
- # // ...
36
- # public static java.awt.Color fromProto(Color protocolor) {
37
- # float alpha = protocolor.hasAlpha()
38
- # ? protocolor.getAlpha().getValue()
39
- # : 1.0;
40
- #
41
- # return new java.awt.Color(
42
- # protocolor.getRed(),
43
- # protocolor.getGreen(),
44
- # protocolor.getBlue(),
45
- # alpha);
46
- # }
47
- #
48
- # public static Color toProto(java.awt.Color color) {
49
- # float red = (float) color.getRed();
50
- # float green = (float) color.getGreen();
51
- # float blue = (float) color.getBlue();
52
- # float denominator = 255.0;
53
- # Color.Builder resultBuilder =
54
- # Color
55
- # .newBuilder()
56
- # .setRed(red / denominator)
57
- # .setGreen(green / denominator)
58
- # .setBlue(blue / denominator);
59
- # int alpha = color.getAlpha();
60
- # if (alpha != 255) {
61
- # result.setAlpha(
62
- # FloatValue
63
- # .newBuilder()
64
- # .setValue(((float) alpha) / denominator)
65
- # .build());
66
- # }
67
- # return resultBuilder.build();
68
- # }
69
- # // ...
70
- #
71
- # Example (iOS / Obj-C):
72
- #
73
- # // ...
74
- # static UIColor* fromProto(Color* protocolor) {
75
- # float red = [protocolor red];
76
- # float green = [protocolor green];
77
- # float blue = [protocolor blue];
78
- # FloatValue* alpha_wrapper = [protocolor alpha];
79
- # float alpha = 1.0;
80
- # if (alpha_wrapper != nil) {
81
- # alpha = [alpha_wrapper value];
82
- # }
83
- # return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
84
- # }
85
- #
86
- # static Color* toProto(UIColor* color) {
87
- # CGFloat red, green, blue, alpha;
88
- # if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
89
- # return nil;
90
- # }
91
- # Color* result = [[Color alloc] init];
92
- # [result setRed:red];
93
- # [result setGreen:green];
94
- # [result setBlue:blue];
95
- # if (alpha <= 0.9999) {
96
- # [result setAlpha:floatWrapperWithValue(alpha)];
97
- # }
98
- # [result autorelease];
99
- # return result;
100
- # }
101
- # // ...
102
- #
103
- # Example (JavaScript):
104
- #
105
- # // ...
106
- #
107
- # var protoToCssColor = function(rgb_color) {
108
- # var redFrac = rgb_color.red || 0.0;
109
- # var greenFrac = rgb_color.green || 0.0;
110
- # var blueFrac = rgb_color.blue || 0.0;
111
- # var red = Math.floor(redFrac * 255);
112
- # var green = Math.floor(greenFrac * 255);
113
- # var blue = Math.floor(blueFrac * 255);
114
- #
115
- # if (!('alpha' in rgb_color)) {
116
- # return rgbToCssColor_(red, green, blue);
117
- # }
118
- #
119
- # var alphaFrac = rgb_color.alpha.value || 0.0;
120
- # var rgbParams = [red, green, blue].join(',');
121
- # return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
122
- # };
123
- #
124
- # var rgbToCssColor_ = function(red, green, blue) {
125
- # var rgbNumber = new Number((red << 16) | (green << 8) | blue);
126
- # var hexString = rgbNumber.toString(16);
127
- # var missingZeros = 6 - hexString.length;
128
- # var resultBuilder = ['#'];
129
- # for (var i = 0; i < missingZeros; i++) {
130
- # resultBuilder.push('0');
131
- # }
132
- # resultBuilder.push(hexString);
133
- # return resultBuilder.join('');
134
- # };
135
- #
136
- # // ...
137
- # @!attribute [rw] red
138
- # @return [Float]
139
- # The amount of red in the color as a value in the interval [0, 1].
140
- # @!attribute [rw] green
141
- # @return [Float]
142
- # The amount of green in the color as a value in the interval [0, 1].
143
- # @!attribute [rw] blue
144
- # @return [Float]
145
- # The amount of blue in the color as a value in the interval [0, 1].
146
- # @!attribute [rw] alpha
147
- # @return [Google::Protobuf::FloatValue]
148
- # The fraction of this color that should be applied to the pixel. That is,
149
- # the final pixel color is defined by the equation:
150
- #
151
- # pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
152
- #
153
- # This means that a value of 1.0 corresponds to a solid color, whereas
154
- # a value of 0.0 corresponds to a completely transparent color. This
155
- # uses a wrapper message rather than a simple float scalar so that it is
156
- # possible to distinguish between a default value and the value being unset.
157
- # If omitted, this color object is to be rendered as a solid color
158
- # (as if the alpha value had been explicitly given with a value of 1.0).
159
- class Color; end
160
- end
161
- end