1
// -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi:tw=80:et:ts=2:sts=2
4
// -----------------------------------------------------------------------
6
// This file is part of RLVM, a RealLive virtual machine clone.
8
// -----------------------------------------------------------------------
10
// Copyright (C) 2009 Elliot Glaysher
12
// This program is free software; you can redistribute it and/or modify
13
// it under the terms of the GNU General Public License as published by
14
// the Free Software Foundation; either version 3 of the License, or
15
// (at your option) any later version.
17
// This program is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
// GNU General Public License for more details.
22
// You should have received a copy of the GNU General Public License
23
// along with this program; if not, write to the Free Software
24
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
25
// -----------------------------------------------------------------------
27
#ifndef SRC_MACHINE_RLOPERATION_RGB_COLOUR_T_H_
28
#define SRC_MACHINE_RLOPERATION_RGB_COLOUR_T_H_
33
#include "machine/rloperation.h"
34
#include "systems/base/colour.h"
37
typedef RGBAColour type;
39
static type getData(RLMachine& machine,
40
const libreallive::ExpressionPiecesVector& p,
41
unsigned int& position) {
42
int r = IntConstant_T::getData(machine, p, position);
43
int g = IntConstant_T::getData(machine, p, position);
44
int b = IntConstant_T::getData(machine, p, position);
45
return RGBAColour(r, g, b);
48
static void ParseParameters(unsigned int& position,
49
const std::vector<std::string>& input,
50
libreallive::ExpressionPiecesVector& output) {
51
IntConstant_T::ParseParameters(position, input, output);
52
IntConstant_T::ParseParameters(position, input, output);
53
IntConstant_T::ParseParameters(position, input, output);
56
enum { is_complex = false };
59
// RGB colour triplet with option alpha.
60
struct RGBMaybeAColour_T {
61
typedef RGBAColour type;
63
static type getData(RLMachine& machine,
64
const libreallive::ExpressionPiecesVector& p,
65
unsigned int& position) {
66
int r = IntConstant_T::getData(machine, p, position);
67
int g = IntConstant_T::getData(machine, p, position);
68
int b = IntConstant_T::getData(machine, p, position);
71
if (position < p.size()) {
72
a = IntConstant_T::getData(machine, p, position);
77
return RGBAColour(r, g, b, a);
80
static void ParseParameters(unsigned int& position,
81
const std::vector<std::string>& input,
82
libreallive::ExpressionPiecesVector& output) {
83
IntConstant_T::ParseParameters(position, input, output);
84
IntConstant_T::ParseParameters(position, input, output);
85
IntConstant_T::ParseParameters(position, input, output);
87
if (position < input.size()) {
88
IntConstant_T::ParseParameters(position, input, output);
90
output.emplace_back(new libreallive::IntegerConstant(255));
95
enum { is_complex = false };
98
#endif // SRC_MACHINE_RLOPERATION_RGB_COLOUR_T_H_