[DEVELOPMENT ENVIRONMENT]
* BUG: Image.Mirror() now works in place. [GB.GTK] * NEW: Color.LightForeground has been implemented. git-svn-id: svn://localhost/gambas/trunk@2297 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
ac548e8734
commit
f0b39ad212
@ -18,7 +18,7 @@ colon, a space, and the text.
|
||||
Slots are the name of the component, in uppercase if possible, or some other
|
||||
slots like [INTERPRETER], [COMPILER]...
|
||||
|
||||
All lines must be lower or equal than 76 characters.
|
||||
All lines lengths must be lower or equal than 76 characters.
|
||||
|
||||
If a changelog modification is more than one line, you must use a two space
|
||||
indent.
|
||||
|
@ -288,7 +288,7 @@ Private Sub InitUser()
|
||||
DrawText(.Name, 0, 0, W, H, Color.Merge(.Color, Color.White, 0.7), Color.Default)
|
||||
Draw.End
|
||||
.Image = hPict.Image
|
||||
.Image.MakeTransparent
|
||||
.Image.Transparent
|
||||
End With
|
||||
Next
|
||||
|
||||
|
@ -398,11 +398,8 @@ Public Sub timMadeIn_Timer()
|
||||
|
||||
'If Me.Minimized Then Return
|
||||
|
||||
If $eIncAng < 0 Then
|
||||
hImage = $hLogo.Mirror(True, False)
|
||||
Else
|
||||
hImage = $hLogo.Copy()
|
||||
Endif
|
||||
If $eIncAng < 0 Then hImage.Mirror(True, False)
|
||||
hMadeIn = $hMadeIn.Rotate(Rad($eAng))
|
||||
hImage.Draw(hMadeIn, - (hMadeIn.W - hImage.W) / 2, - (hMadeIn.H - hImage.H) / 2)
|
||||
$hDraw = hImage.Picture
|
||||
|
@ -94,6 +94,17 @@ BEGIN_PROPERTY(CCOLOR_button_foreground)
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(CCOLOR_light_foreground)
|
||||
|
||||
uint col;
|
||||
|
||||
col = IMAGE.MergeColor(gDesktop::bgColor(), gDesktop::fgColor(), 0.5);
|
||||
col = IMAGE.LighterColor(col);
|
||||
|
||||
GB.ReturnInteger(col);
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
GB_DESC CColorDesc[] =
|
||||
{
|
||||
GB_DECLARE("Color", 0), GB_VIRTUAL_CLASS(),
|
||||
@ -106,6 +117,7 @@ GB_DESC CColorDesc[] =
|
||||
|
||||
GB_STATIC_PROPERTY("Foreground", "i", CCOLOR_foreground),
|
||||
GB_STATIC_PROPERTY("SelectedForeground", "i", CCOLOR_selected_foreground),
|
||||
GB_STATIC_PROPERTY("LightForeground", "i", CCOLOR_light_foreground),
|
||||
GB_STATIC_PROPERTY("TextForeground", "i", CCOLOR_text_foreground),
|
||||
GB_STATIC_PROPERTY("ButtonForeground", "i", CCOLOR_button_foreground),
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <qpalette.h>
|
||||
|
||||
#include "gambas.h"
|
||||
#include "gb.image.h"
|
||||
|
||||
#include "CWidget.h"
|
||||
#include "CColor.h"
|
||||
@ -37,12 +38,7 @@ static int _v = 0;
|
||||
|
||||
QColor CCOLOR_merge(const QColor &colorA, const QColor &colorB, int factor)
|
||||
{
|
||||
const int maxFactor = 100;
|
||||
QColor tmp = colorA;
|
||||
tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
|
||||
tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
|
||||
tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
|
||||
return tmp;
|
||||
return QColor(IMAGE.MergeColor(colorA.rgba(), colorB.rgba(), factor / 100.0));
|
||||
}
|
||||
|
||||
static void get_hsv(int col)
|
||||
@ -131,8 +127,12 @@ END_PROPERTY
|
||||
|
||||
BEGIN_PROPERTY(CCOLOR_light_foreground)
|
||||
|
||||
QColor col = CCOLOR_merge(qApp->palette().color(QPalette::Window), qApp->palette().color(QPalette::WindowText)).lighter();
|
||||
GB.ReturnInteger(col.rgb() & 0xFFFFFF);
|
||||
uint col;
|
||||
|
||||
col = IMAGE.MergeColor(qApp->palette().color(QPalette::Window).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::WindowText).rgb() & 0xFFFFFF, 0.5);
|
||||
col = IMAGE.LighterColor(col);
|
||||
|
||||
GB.ReturnInteger(col);
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
|
@ -180,6 +180,50 @@ void COLOR_hsv_to_rgb(int h, int s, int v, int *R, int *G, int *B)
|
||||
}
|
||||
}
|
||||
|
||||
GB_COLOR COLOR_merge(GB_COLOR col1, GB_COLOR col2, double weight)
|
||||
{
|
||||
int a, r, g, b;
|
||||
|
||||
if (weight == 0.0)
|
||||
return col1;
|
||||
else if (weight == 1.0)
|
||||
return col2;
|
||||
else
|
||||
{
|
||||
#define MIX_COLOR(_shift) (int)((((col2 >> _shift) & 0xFF) * weight + ((col1 >> _shift) & 0xFF) * (1 - weight)) + 0.5)
|
||||
|
||||
a = MIX_COLOR(24);
|
||||
r = MIX_COLOR(16);
|
||||
g = MIX_COLOR(8);
|
||||
b = MIX_COLOR(0);
|
||||
|
||||
return gt_rgba_to_color(r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
GB_COLOR COLOR_lighter(GB_COLOR color)
|
||||
{
|
||||
int h, s, v;
|
||||
int r, g, b, a;
|
||||
|
||||
gt_color_to_rgba(color, &r, &g, &b, &a);
|
||||
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
|
||||
COLOR_hsv_to_rgb(h, s / 2, 255 - (255 - v) / 2, &r, &g, &b);
|
||||
|
||||
return gt_rgba_to_color(r, g, b, a);
|
||||
}
|
||||
|
||||
GB_COLOR COLOR_darker(GB_COLOR color)
|
||||
{
|
||||
int h, s, v;
|
||||
int r, g, b, a;
|
||||
|
||||
gt_color_to_rgba(color, &r, &g, &b, &a);
|
||||
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
|
||||
COLOR_hsv_to_rgb(h, 255 - (255 - s) / 2, v / 2, &r, &g, &b);
|
||||
|
||||
return gt_rgba_to_color(r, g, b, a);
|
||||
}
|
||||
|
||||
BEGIN_METHOD(CCOLOR_rgb, GB_INTEGER r; GB_INTEGER g; GB_INTEGER b; GB_INTEGER a)
|
||||
|
||||
@ -255,54 +299,19 @@ END_PROPERTY
|
||||
|
||||
BEGIN_METHOD(CCOLOR_lighter, GB_INTEGER color)
|
||||
|
||||
int h, s, v;
|
||||
int r, g, b, a;
|
||||
|
||||
gt_color_to_rgba(VARG(color), &r, &g, &b, &a);
|
||||
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
|
||||
COLOR_hsv_to_rgb(h, s / 2, 255 - (255 - v) / 2, &r, &g, &b);
|
||||
|
||||
GB.ReturnInteger(gt_rgba_to_color(r, g, b, a));
|
||||
GB.ReturnInteger(COLOR_lighter(VARG(color)));
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(CCOLOR_darker, GB_INTEGER color)
|
||||
|
||||
int h, s, v;
|
||||
int r, g, b, a;
|
||||
|
||||
gt_color_to_rgba(VARG(color), &r, &g, &b, &a);
|
||||
COLOR_rgb_to_hsv(r, g, b, &h, &s, &v);
|
||||
COLOR_hsv_to_rgb(h, 255 - (255 - s) / 2, v / 2, &r, &g, &b);
|
||||
|
||||
GB.ReturnInteger(gt_rgba_to_color(r, g, b, a));
|
||||
GB.ReturnInteger(COLOR_darker(VARG(color)));
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(CCOLOR_mix, GB_INTEGER color1; GB_INTEGER color2; GB_FLOAT weight)
|
||||
BEGIN_METHOD(CCOLOR_merge, GB_INTEGER color1; GB_INTEGER color2; GB_FLOAT weight)
|
||||
|
||||
int col1, col2;
|
||||
int r, g, b, a;
|
||||
double weight = VARGOPT(weight, 0.5);
|
||||
|
||||
col1 = VARG(color1);
|
||||
col2 = VARG(color2);
|
||||
|
||||
if (weight == 0.0)
|
||||
GB.ReturnInteger(col1);
|
||||
else if (weight == 1.0)
|
||||
GB.ReturnInteger(col2);
|
||||
else
|
||||
{
|
||||
#define MIX_COLOR(_shift) (int)((((col2 >> _shift) & 0xFF) * weight + ((col1 >> _shift) & 0xFF) * (1 - weight)) + 0.5)
|
||||
|
||||
a = MIX_COLOR(24);
|
||||
r = MIX_COLOR(16);
|
||||
g = MIX_COLOR(8);
|
||||
b = MIX_COLOR(0);
|
||||
|
||||
GB.ReturnInteger(gt_rgba_to_color(r, g, b, a));
|
||||
}
|
||||
GB.ReturnInteger(COLOR_merge(VARG(color1), VARG(color2), VARGOPT(weight, 0.5)));
|
||||
|
||||
END_METHOD
|
||||
|
||||
@ -408,7 +417,7 @@ GB_DESC CColorDesc[] =
|
||||
|
||||
GB_STATIC_METHOD("Lighter", "i", CCOLOR_lighter, "(Color)i"),
|
||||
GB_STATIC_METHOD("Darker", "i", CCOLOR_darker, "(Color)i"),
|
||||
GB_STATIC_METHOD("Merge", "i", CCOLOR_mix, "(Color1)i(Color2)i[(Weight)f]"),
|
||||
GB_STATIC_METHOD("Merge", "i", CCOLOR_merge, "(Color1)i(Color2)i[(Weight)f]"),
|
||||
GB_STATIC_METHOD("Blend", "i", CCOLOR_blend, "(Source)i(Destination)i"),
|
||||
|
||||
GB_STATIC_METHOD("_get", "ColorInfo", CCOLOR_get, "(Color)i"),
|
||||
|
@ -41,5 +41,8 @@ typedef
|
||||
|
||||
void COLOR_rgb_to_hsv(int r, int g, int b, int *H, int *S, int *V);
|
||||
void COLOR_hsv_to_rgb(int h, int s, int v, int *R, int *G, int *B);
|
||||
GB_COLOR COLOR_merge(GB_COLOR col1, GB_COLOR col2, double weight);
|
||||
GB_COLOR COLOR_lighter(GB_COLOR color);
|
||||
GB_COLOR COLOR_darker(GB_COLOR color);
|
||||
|
||||
#endif
|
||||
|
@ -125,6 +125,12 @@ typedef
|
||||
GB_COLOR (*GetPixel)(GB_IMG *img, int x, int y);
|
||||
// Converts an image to one of the following formats: BGRA, RGBA, BGRP, RGBP
|
||||
void (*Convert)(GB_IMG *img, int format);
|
||||
// Merge two colors
|
||||
GB_COLOR (*MergeColor)(GB_COLOR col1, GB_COLOR col2, double weight);
|
||||
// Make a color lighter
|
||||
GB_COLOR (*LighterColor)(GB_COLOR col);
|
||||
// Make a color darker
|
||||
GB_COLOR (*DarkerColor)(GB_COLOR col);
|
||||
}
|
||||
IMAGE_INTERFACE;
|
||||
|
||||
|
@ -63,6 +63,9 @@ void *GB_IMAGE_1[] EXPORT =
|
||||
(void *)IMAGE_get_default_format,
|
||||
(void *)IMAGE_get_pixel,
|
||||
(void *)IMAGE_convert,
|
||||
(void *)COLOR_merge,
|
||||
(void *)COLOR_lighter,
|
||||
(void *)COLOR_darker,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user