-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for color format #165
Comments
This is a nice feature, and I like the general syntactical approach taken here. |
Shouldn't transparent RGB be ARGB and transparent rgb, argb? |
Yeah, that's a good question. I see two general strategies here:
I don't like the strategy of ("randomly") adding our own color schemes on top of the standard ones, so I don't think that's a good idea to add TL;DR: I don't think we need to add |
In my current version, the HTML model supports short hex(333), plain hex(34e869), and long hex(5567899f), gray and cmyk can have an optional alpha channel factor, the alpha channel coefficient for the rgb and RGB models only work if you rename the models as argb and ARGB. |
Well, we're discussing not our current implementation, but the specification, i.e. how we want the feature to be implemented. I've noted your opinion on the matter, thanks. But it won't be too hard to change the implementation if we want the feature to be implemented in other way. I'm okay with either implementations, actually. But we need to choose what specification we want to adhere. |
In the command processing function, we could first check for a color model and read the next two arguments.
|
Here's a code sample of the above(where "ColorUtilities" is a static utility class for processing colors). ...
case "color":
{
//Command to change the foreground color
string colorModel = null;
if (position < value.Length && value[position] == leftBracketChar)
{
colorModel = ReadElementGroup(value, ref position, leftBracketChar, rightBracketChar).ToString();
SkipWhiteSpace(value, ref position);
}
var colorName = ReadElement(value, ref position).ToString().Trim();
var bodyValue = ReadElement(value, ref position);
var bodyFormula = this.Parse(bodyValue, formula.TextStyle);
source = value.Segment(start, position - start);
if (colorModel!=null)
{
var color = ColorUtilities.Parse(colorModel.Trim(), colorName.ToString());
return new StyledAtom(source, bodyFormula.RootAtom, null, new SolidColorBrush(color));
}
else if (predefinedColors.TryGetValue(colorName, out Color color))
{
return new StyledAtom(source, bodyFormula.RootAtom, null, new SolidColorBrush(color));
}
else if (ColorUtilities.TryModifyPredefinedColor(colorName,out Color modifiedColor))
{
return new StyledAtom(source, bodyFormula.RootAtom, null, new SolidColorBrush(modifiedColor));
}
else
{
throw new TexParseException($"Color \"{colorName}\" could neither be found nor converted.");
}
}
... |
@B3zaleel you've already implemented the core of the feature, I'll take care of the rest, don't bother yourself :) |
Alrighty, I've asked several people, and we had no overall consensus on ARGB vs RGBA. Thus I've decided:
|
While working on #142, I've checked internet for documentation about how other LaTeX-related tools deal with colors. I have not found any evidence that LaTeX supports direct color definition (e.g.
\color{rgb}{1.0,1.5,1.0}{mytext}
) for either\color
or\colorbox
. Although, I've found a useful piece of documentation on Wikibooks.I don't want to add ability to define new colors in WPF-Math LaTeX documents, so I don't want to add commands such as
\definecolor
. I believe that the markup should stay static at the moment and should not have any influence on itself (i.e. no macro or color or whatever definitions in markup).So I suggest that we document and add a modified syntax for
\color
and\colorbox
commands by adding an optionalmode
parameter. Full syntax will be:Where:
command
is eithercolor
orcolorbox
mode
is one ofgray
,rgb
,RGB
,HTML
,cmyk
(for now let's stop on that, but the code should be robust enough to add more modes: xcolor manual includes some additional modes)color
is either a predefined color name (as implemented already) if themode
argument wasn't provided or a proper color definition according to the wikibooks documentationcolor
definitions, we will support a transparency parameter that will be optional and should be added in a convenient manner to every mode we supportThe motivation for adding transparency is clear: while LaTeX was designed to provide mostly a printed documents, we know that we're working with display graphics in WPF-Math, and transparency could be useful and shouldn't be too hard to implement, so I think we should add it.
Here're some syntax samples:
The text was updated successfully, but these errors were encountered: