diff --git a/src/draw.cpp b/src/draw.cpp index 2c3d5f9e..30dd1183 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -61,7 +61,7 @@ void GraphicsWindow::Selection::Draw(void) { topLeft = topLeft.Minus(SS.GW.offset); ssglLineWidth(40); - RgbColor rgb = Style::Color(Style::HOVERED); + RgbaColor rgb = Style::Color(Style::HOVERED); glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), 0.2); glBegin(GL_LINES); ssglVertex3v(topLeft); @@ -517,7 +517,7 @@ void GraphicsWindow::Paint(void) { SS.backgroundColor.blueF(), 1.0f); } else { // Draw a different background whenever we're having solve problems. - RgbColor rgb = Style::Color(Style::DRAW_ERROR); + RgbaColor rgb = Style::Color(Style::DRAW_ERROR); glClearColor(0.4f*rgb.redF(), 0.4f*rgb.greenF(), 0.4f*rgb.blueF(), 1.0f); // And show the text window, which has info to debug it ForceTextWindowShown(); diff --git a/src/drawconstraint.cpp b/src/drawconstraint.cpp index 77170ff8..e2d85179 100644 --- a/src/drawconstraint.cpp +++ b/src/drawconstraint.cpp @@ -570,7 +570,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) { // Let's adjust the color of this constraint to have the same // rough luma as the point color, so that the constraint does not // stand out in an ugly way. - RgbColor cd = Style::Color(Style::DATUM), + RgbaColor cd = Style::Color(Style::DATUM), cc = Style::Color(Style::CONSTRAINT); // convert from 8-bit color to a vector Vector vd = Vector::From(cd.redF(), cd.greenF(), cd.blueF()), diff --git a/src/dsc.h b/src/dsc.h index 9da5b344..e2765477 100644 --- a/src/dsc.h +++ b/src/dsc.h @@ -397,12 +397,12 @@ public: void Solve(void); }; -#define RGBi(r, g, b) RgbColor::From((r), (g), (b)) -#define RGBf(r, g, b) RgbColor::FromFloat((float)(r), (float)(g), (float)(b)) +#define RGBi(r, g, b) RgbaColor::From((r), (g), (b)) +#define RGBf(r, g, b) RgbaColor::FromFloat((float)(r), (float)(g), (float)(b)) -// Note: sizeof(class RgbColor) should be exactly 4 +// Note: sizeof(class RgbaColor) should be exactly 4 // -class RgbColor { +class RgbaColor { public: uint8_t red, green, blue, alpha; @@ -411,7 +411,7 @@ public: float blueF(void) const { return (float)blue / 255.0f; } float alphaF(void) const { return (float)alpha / 255.0f; } - bool Equals(RgbColor c) const { + bool Equals(RgbaColor c) const { return c.red == red && c.green == green && @@ -427,8 +427,8 @@ public: (uint32_t)((255 - alpha) << 24); } - static RgbColor From(int r, int g, int b, int a = 255) { - RgbColor c; + static RgbaColor From(int r, int g, int b, int a = 255) { + RgbaColor c; c.red = (uint8_t)r; c.green = (uint8_t)g; c.blue = (uint8_t)b; @@ -436,7 +436,7 @@ public: return c; } - static RgbColor FromFloat(float r, float g, float b, float a = 1.0) { + static RgbaColor FromFloat(float r, float g, float b, float a = 1.0) { return From( (int)(255.1f * r), (int)(255.1f * g), @@ -444,7 +444,7 @@ public: (int)(255.1f * a)); } - static RgbColor FromPackedInt(uint32_t bgra) { + static RgbaColor FromPackedInt(uint32_t bgra) { return From( (int)((bgra) & 0xff), (int)((bgra >> 8) & 0xff), diff --git a/src/export.cpp b/src/export.cpp index ea658d98..37a4e884 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -506,8 +506,8 @@ void VectorFileWriter::Output(SBezierLoopSetSet *sblss, SMesh *sm) { hStyle hs = { (uint32_t)b->auxA }; Style *stl = Style::Get(hs); double lineWidth = Style::WidthMm(b->auxA)*s; - RgbColor strokeRgb = Style::Color(hs, true); - RgbColor fillRgb = Style::FillColor(hs, true); + RgbaColor strokeRgb = Style::Color(hs, true); + RgbaColor fillRgb = Style::FillColor(hs, true); StartPath(strokeRgb, lineWidth, stl->filled, fillRgb); for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) { diff --git a/src/exportvector.cpp b/src/exportvector.cpp index 0f58ac35..c92fa4c5 100644 --- a/src/exportvector.cpp +++ b/src/exportvector.cpp @@ -71,12 +71,12 @@ void DxfFileWriter::StartFile(void) { "ENTITIES\r\n"); } -void DxfFileWriter::StartPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) +void DxfFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) { } -void DxfFileWriter::FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) +void DxfFileWriter::FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) { } @@ -172,14 +172,14 @@ void EpsFileWriter::StartFile(void) { MmToPts(ptMax.y - ptMin.y)); } -void EpsFileWriter::StartPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) +void EpsFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) { fprintf(f, "newpath\r\n"); prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE); } -void EpsFileWriter::FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) +void EpsFileWriter::FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) { fprintf(f, " %.3f setlinewidth\r\n" " %.3f %.3f %.3f setrgbcolor\r\n" @@ -397,8 +397,8 @@ void PdfFileWriter::FinishAndCloseFile(void) { } -void PdfFileWriter::StartPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) +void PdfFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) { fprintf(f, "1 J 1 j " // round endcaps and joins "%.3f w " @@ -412,8 +412,8 @@ void PdfFileWriter::StartPath(RgbColor strokeRgb, double lineWidth, prevPt = Vector::From(VERY_POSITIVE, VERY_POSITIVE, VERY_POSITIVE); } -void PdfFileWriter::FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) +void PdfFileWriter::FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) { if(filled) { fprintf(f, "b\r\n"); @@ -486,14 +486,14 @@ void SvgFileWriter::StartFile(void) { (ptMax.x - ptMin.x), (ptMax.y - ptMin.y)); } -void SvgFileWriter::StartPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) +void SvgFileWriter::StartPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) { fprintf(f, "c = RgbColor::FromPackedInt(u); + p->c = RgbaColor::FromPackedInt(u); break; case 'P': @@ -564,7 +564,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le, &(tr.c.x), &(tr.c.y), &(tr.c.z)) != 11) { oops(); } - tr.meta.color = RgbColor::FromPackedInt((uint32_t)rgba); + tr.meta.color = RgbaColor::FromPackedInt((uint32_t)rgba); m->AddTriangle(&tr); } else if(StrStartsWith(line, "Surface ")) { unsigned int rgba = 0; @@ -573,7 +573,7 @@ bool SolveSpaceUI::LoadEntitiesFromFile(const char *file, EntityList *le, &(srf.degm), &(srf.degn)) != 5) { oops(); } - srf.color = RgbColor::FromPackedInt((uint32_t)rgba); + srf.color = RgbaColor::FromPackedInt((uint32_t)rgba); } else if(StrStartsWith(line, "SCtrl ")) { int i, j; Vector c; diff --git a/src/glhelper.cpp b/src/glhelper.cpp index 348d9221..915423a7 100644 --- a/src/glhelper.cpp +++ b/src/glhelper.cpp @@ -198,7 +198,7 @@ void ssglFatLine(Vector a, Vector b, double width) } -void ssglLockColorTo(RgbColor rgb) +void ssglLockColorTo(RgbaColor rgb) { ColorLocked = false; glColor3d(rgb.redF(), rgb.greenF(), rgb.blueF()); @@ -210,14 +210,14 @@ void ssglUnlockColor(void) ColorLocked = false; } -void ssglColorRGB(RgbColor rgb) +void ssglColorRGB(RgbaColor rgb) { // Is there a bug in some graphics drivers where this is not equivalent // to glColor3d? There seems to be... ssglColorRGBa(rgb, 1.0); } -void ssglColorRGBa(RgbColor rgb, double a) +void ssglColorRGBa(RgbaColor rgb, double a) { if(!ColorLocked) glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), a); } @@ -253,7 +253,7 @@ static void Stipple(bool forSel) } } -static void StippleTriangle(STriangle *tr, bool s, RgbColor rgb) +static void StippleTriangle(STriangle *tr, bool s, RgbaColor rgb) { glEnd(); glDisable(GL_LIGHTING); @@ -269,20 +269,20 @@ static void StippleTriangle(STriangle *tr, bool s, RgbColor rgb) glBegin(GL_TRIANGLES); } -void ssglFillMesh(bool useSpecColor, RgbColor specColor, +void ssglFillMesh(bool useSpecColor, RgbaColor specColor, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2) { - RgbColor rgbHovered = Style::Color(Style::HOVERED), + RgbaColor rgbHovered = Style::Color(Style::HOVERED), rgbSelected = Style::Color(Style::SELECTED); glEnable(GL_NORMALIZE); bool hasMaterial = false; - RgbColor prevColor; + RgbaColor prevColor; glBegin(GL_TRIANGLES); for(int i = 0; i < m->l.n; i++) { STriangle *tr = &(m->l.elem[i]); - RgbColor color; + RgbaColor color; if(useSpecColor) { color = specColor; } else { diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index 9d0fa577..ad404fa2 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -434,7 +434,7 @@ Group *Group::RunningMeshGroup(void) { } void Group::DrawDisplayItems(int t) { - RgbColor specColor; + RgbaColor specColor; bool useSpecColor; if(t == DRAWING_3D || t == DRAWING_WORKPLANE) { // force the color to something dim diff --git a/src/polygon.h b/src/polygon.h index 9210c023..a4ea0830 100644 --- a/src/polygon.h +++ b/src/polygon.h @@ -123,7 +123,7 @@ public: typedef struct { uint32_t face; - RgbColor color; + RgbaColor color; } STriMeta; class SPolygon { diff --git a/src/sketch.h b/src/sketch.h index b0911124..6cf61eb9 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -118,7 +118,7 @@ public: double valA; double valB; double valC; - RgbColor color; + RgbaColor color; struct { int how; @@ -242,7 +242,7 @@ public: void GenerateDisplayItems(void); void DrawDisplayItems(int t); void Draw(void); - RgbColor GetLoopSetFillColor(SBezierLoopSet *sbls, + RgbaColor GetLoopSetFillColor(SBezierLoopSet *sbls, bool *allSame, Vector *errorAt); void FillLoopSetAsPolygon(SBezierLoopSet *sbls); void DrawFilledPaths(void); @@ -729,9 +729,9 @@ public: }; int textOrigin; double textAngle; - RgbColor color; + RgbaColor color; bool filled; - RgbColor fillColor; + RgbaColor fillColor; bool visible; bool exportable; @@ -740,7 +740,7 @@ public: typedef struct { hStyle h; const char *cnfPrefix; - RgbColor color; + RgbaColor color; double width; } Default; static const Default Defaults[]; @@ -757,13 +757,13 @@ public: static void AssignSelectionToStyle(uint32_t v); static uint32_t CreateCustomStyle(void); - static RgbColor RewriteColor(RgbColor rgb); + static RgbaColor RewriteColor(RgbaColor rgb); static Style *Get(hStyle hs); - static RgbColor Color(hStyle hs, bool forExport=false); - static RgbColor FillColor(hStyle hs, bool forExport=false); + static RgbaColor Color(hStyle hs, bool forExport=false); + static RgbaColor FillColor(hStyle hs, bool forExport=false); static float Width(hStyle hs); - static RgbColor Color(int hs, bool forExport=false); + static RgbaColor Color(int hs, bool forExport=false); static float Width(int hs); static double WidthMm(int hs); static double TextHeight(hStyle hs); diff --git a/src/solvespace.h b/src/solvespace.h index 2ad6afb2..4a2664cd 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -115,7 +115,7 @@ inline double Random(double vmax) { class Expr; class ExprVector; class ExprQuaternion; -class RgbColor; +class RgbaColor; #ifndef MAX_PATH # define MAX_PATH PATH_MAX @@ -300,7 +300,7 @@ void ssglAxisAlignedLineLoop(double l, double r, double t, double b); extern "C" { typedef void SSGL_CALLBACK ssglCallbackFptr(void); } void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p); void ssglFillPolygon(SPolygon *p); -void ssglFillMesh(bool useSpecColor, RgbColor color, +void ssglFillMesh(bool useSpecColor, RgbaColor color, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2); void ssglDebugPolygon(SPolygon *p); void ssglDrawEdges(SEdgeList *l, bool endpointsToo); @@ -313,11 +313,11 @@ void ssglWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vecto ssglLineFn *fn, void *fndata); double ssglStrWidth(const char *str, double h); double ssglStrHeight(double h); -void ssglLockColorTo(RgbColor rgb); +void ssglLockColorTo(RgbaColor rgb); void ssglFatLine(Vector a, Vector b, double width); void ssglUnlockColor(void); -void ssglColorRGB(RgbColor rgb); -void ssglColorRGBa(RgbColor rgb, double a); +void ssglColorRGB(RgbaColor rgb); +void ssglColorRGBa(RgbaColor rgb, double a); void ssglDepthRangeOffset(int units); void ssglDepthRangeLockToFront(bool yes); void ssglDrawPixelsWithTexture(uint8_t *data, int w, int h); @@ -345,9 +345,9 @@ bool StringEndsIn(const char *str, const char *ending); void Message(const char *str, ...); void Error(const char *str, ...); void CnfFreezeBool(bool v, const char *name); -void CnfFreezeColor(RgbColor v, const char *name); +void CnfFreezeColor(RgbaColor v, const char *name); bool CnfThawBool(bool v, const char *name); -RgbColor CnfThawColor(RgbColor v, const char *name); +RgbaColor CnfThawColor(RgbaColor v, const char *name); class System { public: @@ -546,10 +546,10 @@ public: void BezierAsPwl(SBezier *sb); void BezierAsNonrationalCubic(SBezier *sb, int depth=0); - virtual void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) = 0; - virtual void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb) = 0; + virtual void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) = 0; + virtual void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb) = 0; virtual void Bezier(SBezier *sb) = 0; virtual void Triangle(STriangle *tr) = 0; virtual void StartFile(void) = 0; @@ -560,10 +560,10 @@ public: }; class DxfFileWriter : public VectorFileWriter { public: - void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); - void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); + void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); + void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); void Triangle(STriangle *tr); void Bezier(SBezier *sb); void StartFile(void); @@ -575,10 +575,10 @@ public: Vector prevPt; void MaybeMoveTo(Vector s, Vector f); - void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); - void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); + void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); + void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); void Triangle(STriangle *tr); void Bezier(SBezier *sb); void StartFile(void); @@ -592,10 +592,10 @@ public: Vector prevPt; void MaybeMoveTo(Vector s, Vector f); - void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); - void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); + void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); + void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); void Triangle(STriangle *tr); void Bezier(SBezier *sb); void StartFile(void); @@ -607,10 +607,10 @@ public: Vector prevPt; void MaybeMoveTo(Vector s, Vector f); - void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); - void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); + void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); + void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); void Triangle(STriangle *tr); void Bezier(SBezier *sb); void StartFile(void); @@ -620,10 +620,10 @@ public: class HpglFileWriter : public VectorFileWriter { public: static double MmToHpglUnits(double mm); - void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); - void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); + void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); + void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); void Triangle(STriangle *tr); void Bezier(SBezier *sb); void StartFile(void); @@ -632,10 +632,10 @@ public: }; class Step2dFileWriter : public VectorFileWriter { StepFileWriter sfw; - void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); - void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); + void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); + void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); void Triangle(STriangle *tr); void Bezier(SBezier *sb); void StartFile(void); @@ -645,10 +645,10 @@ class Step2dFileWriter : public VectorFileWriter { class GCodeFileWriter : public VectorFileWriter { public: SEdgeList sel; - void StartPath( RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); - void FinishPath(RgbColor strokeRgb, double lineWidth, - bool filled, RgbColor fillRgb); + void StartPath( RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); + void FinishPath(RgbaColor strokeRgb, double lineWidth, + bool filled, RgbaColor fillRgb); void Triangle(STriangle *tr); void Bezier(SBezier *sb); void StartFile(void); @@ -729,7 +729,7 @@ public: // Little bits of extra configuration state enum { MODEL_COLORS = 8 }; - RgbColor modelColor[MODEL_COLORS]; + RgbaColor modelColor[MODEL_COLORS]; Vector lightDir[2]; double lightIntensity[2]; double ambientIntensity; @@ -743,7 +743,7 @@ public: bool drawBackFaces; bool checkClosedContour; bool showToolbar; - RgbColor backgroundColor; + RgbaColor backgroundColor; bool exportShadedTriangles; bool exportPwlCurves; bool exportCanvasSizeAuto; diff --git a/src/srf/surface.cpp b/src/srf/surface.cpp index ad789323..0cbacf2e 100644 --- a/src/srf/surface.cpp +++ b/src/srf/surface.cpp @@ -489,7 +489,7 @@ typedef struct { hSSurface hs; } TrimLine; -void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, RgbColor color) +void SShell::MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, RgbaColor color) { // Make the extrusion direction consistent with respect to the normal // of the sketch we're extruding. @@ -608,7 +608,7 @@ typedef struct { hSSurface d[4]; } Revolved; -void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis, RgbColor color) +void SShell::MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis, RgbaColor color) { SBezierLoop *sbl; diff --git a/src/srf/surface.h b/src/srf/surface.h index 4581db8d..af7bc407 100644 --- a/src/srf/surface.h +++ b/src/srf/surface.h @@ -250,7 +250,7 @@ public: // when I copy things over. hSSurface newH; - RgbColor color; + RgbaColor color; uint32_t face; int degm, degn; @@ -361,9 +361,9 @@ public: bool booleanFailed; void MakeFromExtrusionOf(SBezierLoopSet *sbls, Vector t0, Vector t1, - RgbColor color); + RgbaColor color); void MakeFromRevolutionOf(SBezierLoopSet *sbls, Vector pt, Vector axis, - RgbColor color); + RgbaColor color); void MakeFromUnionOf(SShell *a, SShell *b); void MakeFromDifferenceOf(SShell *a, SShell *b); diff --git a/src/style.cpp b/src/style.cpp index bf780d09..e03b2731 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -197,7 +197,7 @@ Style *Style::Get(hStyle h) { // A couple of wrappers, so that I can call these functions with either an // hStyle or with the integer corresponding to that hStyle.v. //----------------------------------------------------------------------------- -RgbColor Style::Color(int s, bool forExport) { +RgbaColor Style::Color(int s, bool forExport) { hStyle hs = { (uint32_t)s }; return Color(hs, forExport); } @@ -210,7 +210,7 @@ float Style::Width(int s) { // If a color is almost white, then we can rewrite it to black, just so that // it won't disappear on file formats with a light background. //----------------------------------------------------------------------------- -RgbColor Style::RewriteColor(RgbColor rgbin) { +RgbaColor Style::RewriteColor(RgbaColor rgbin) { Vector rgb = Vector::From(rgbin.redF(), rgbin.greenF(), rgbin.blueF()); rgb = rgb.Minus(Vector::From(1, 1, 1)); if(rgb.Magnitude() < 0.4 && SS.fixExportColors) { @@ -227,7 +227,7 @@ RgbColor Style::RewriteColor(RgbColor rgbin) { //----------------------------------------------------------------------------- // Return the stroke color associated with our style as 8-bit RGB. //----------------------------------------------------------------------------- -RgbColor Style::Color(hStyle h, bool forExport) { +RgbaColor Style::Color(hStyle h, bool forExport) { Style *s = Get(h); if(forExport) { return RewriteColor(s->color); @@ -239,7 +239,7 @@ RgbColor Style::Color(hStyle h, bool forExport) { //----------------------------------------------------------------------------- // Return the fill color associated with our style as 8-bit RGB. //----------------------------------------------------------------------------- -RgbColor Style::FillColor(hStyle h, bool forExport) { +RgbaColor Style::FillColor(hStyle h, bool forExport) { Style *s = Get(h); if(forExport) { return RewriteColor(s->fillColor); @@ -349,7 +349,7 @@ void TextWindow::ScreenCreateCustomStyle(int link, uint32_t v) { } void TextWindow::ScreenChangeBackgroundColor(int link, uint32_t v) { - RgbColor rgb = SS.backgroundColor; + RgbaColor rgb = SS.backgroundColor; SS.TW.ShowEditControlWithColorPicker(v, 3, rgb); SS.TW.edit.meaning = EDIT_BACKGROUND_COLOR; } @@ -455,7 +455,7 @@ void TextWindow::ShowListOfStyles(void) { Printf(false, ""); - RgbColor rgb = SS.backgroundColor; + RgbaColor rgb = SS.backgroundColor; Printf(false, "%Ft background color (r, g, b)%E"); Printf(false, "%Ba %@, %@, %@ %Fl%D%f%Ll[change]%E", rgb.redF(), rgb.greenF(), rgb.blueF(), @@ -549,7 +549,7 @@ void TextWindow::ScreenChangeStyleColor(int link, uint32_t v) { Style *s = Style::Get(hs); // Same function used for stroke and fill colors int row, col, em; - RgbColor rgb; + RgbaColor rgb; if(link == 's') { row = 15; col = 13; em = EDIT_STYLE_COLOR; diff --git a/src/textwin.cpp b/src/textwin.cpp index 28cfa79b..c474bb6c 100644 --- a/src/textwin.cpp +++ b/src/textwin.cpp @@ -85,7 +85,7 @@ void TextWindow::ShowEditControl(int halfRow, int col, char *s) { ShowTextEditControl(x - 3, y + 2, s); } -void TextWindow::ShowEditControlWithColorPicker(int halfRow, int col, RgbColor rgb) +void TextWindow::ShowEditControlWithColorPicker(int halfRow, int col, RgbaColor rgb) { char str[1024]; sprintf(str, "%.2f, %.2f, %.2f", rgb.redF(), rgb.greenF(), rgb.blueF()); @@ -132,7 +132,7 @@ void TextWindow::Printf(bool halfLine, const char *fmt, ...) { char fg = 'd'; char bg = 'd'; - RgbColor bgRgb = RGBi(0, 0, 0); + RgbaColor bgRgb = RGBi(0, 0, 0); int link = NOT_A_LINK; uint32_t data = 0; LinkFunction *f = NULL, *h = NULL; @@ -203,11 +203,11 @@ void TextWindow::Printf(bool halfLine, const char *fmt, ...) { case 'F': case 'B': { char cc = fmt[1]; // color code - RgbColor *rgbPtr = NULL; + RgbaColor *rgbPtr = NULL; switch(cc) { case 0: goto done; // truncated directive case 'p': cc = (char)va_arg(vl, int); break; - case 'z': rgbPtr = va_arg(vl, RgbColor *); break; + case 'z': rgbPtr = va_arg(vl, RgbaColor *); break; } if(*fmt == 'F') { fg = cc; @@ -541,7 +541,7 @@ uint8_t *TextWindow::HsvPattern1d(double h, double s) { void TextWindow::ColorPickerDone(void) { char str[1024]; - RgbColor rgb = editControl.colorPicker.rgb; + RgbaColor rgb = editControl.colorPicker.rgb; sprintf(str, "%.2f, %.2f, %.3f", rgb.redF(), rgb.greenF(), rgb.blueF()); EditControlDone(str); } @@ -559,7 +559,7 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown, if(!editControl.colorPicker.show) return false; if(how == CLICK || (how == HOVER && leftDown)) InvalidateText(); - static const RgbColor BaseColor[12] = { + static const RgbaColor BaseColor[12] = { RGBi(255, 0, 0), RGBi( 0, 255, 0), RGBi( 0, 0, 255), @@ -612,7 +612,7 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown, for(i = 0; i < WIDTH/2; i++) { for(j = 0; j < HEIGHT; j++) { Vector rgb; - RgbColor d; + RgbaColor d; if(i == 0 && j < 8) { d = SS.modelColor[j]; rgb = Vector::From(d.redF(), d.greenF(), d.blueF()); @@ -844,7 +844,7 @@ void TextWindow::Paint(void) { int fg = meta[r][c].fg; int bg = meta[r][c].bg; - RgbColor bgRgb = meta[r][c].bgRgb; + RgbaColor bgRgb = meta[r][c].bgRgb; // On the first pass, all the background quads; on the next // pass, all the foreground (i.e., font) quads. diff --git a/src/ui.h b/src/ui.h index 1012b93f..69c13f9a 100644 --- a/src/ui.h +++ b/src/ui.h @@ -17,8 +17,8 @@ public: }; typedef struct { - char c; - RgbColor color; + char c; + RgbaColor color; } Color; static const Color fgColors[]; static const Color bgColors[]; @@ -47,7 +47,7 @@ public: struct { char fg; char bg; - RgbColor bgRgb; + RgbaColor bgRgb; int link; uint32_t data; LinkFunction *f; @@ -199,17 +199,17 @@ public: int col; struct { - RgbColor rgb; - double h, s, v; - bool show; - bool picker1dActive; - bool picker2dActive; + RgbaColor rgb; + double h, s, v; + bool show; + bool picker1dActive; + bool picker2dActive; } colorPicker; } editControl; void HideEditControl(void); void ShowEditControl(int halfRow, int col, char *s); - void ShowEditControlWithColorPicker(int halfRow, int col, RgbColor rgb); + void ShowEditControlWithColorPicker(int halfRow, int col, RgbaColor rgb); void ClearSuper(void); diff --git a/src/util.cpp b/src/util.cpp index 1f551f13..df832f5c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -210,14 +210,14 @@ void SolveSpace::Message(const char *str, ...) void SolveSpace::CnfFreezeBool(bool v, const char *name) { CnfFreezeInt(v ? 1 : 0, name); } -void SolveSpace::CnfFreezeColor(RgbColor v, const char *name) +void SolveSpace::CnfFreezeColor(RgbaColor v, const char *name) { CnfFreezeInt(v.ToPackedInt(), name); } bool SolveSpace::CnfThawBool(bool v, const char *name) { return CnfThawInt(v ? 1 : 0, name) != 0; } -RgbColor SolveSpace::CnfThawColor(RgbColor v, const char *name) - { return RgbColor::FromPackedInt(CnfThawInt(v.ToPackedInt(), name)); } +RgbaColor SolveSpace::CnfThawColor(RgbaColor v, const char *name) + { return RgbaColor::FromPackedInt(CnfThawInt(v.ToPackedInt(), name)); } //----------------------------------------------------------------------------- // Solve a mostly banded matrix. In a given row, there are LEFT_OF_DIAG