Click here to Skip to main content
15,569,547 members

Comments by Mike-MadBadger (Top 15 by date)

Mike-MadBadger 22-Oct-13 17:02pm View    
I think it may help if you assume I'm a rank amateur.
(I wonder if there is some confusion? I am looking at a library rather than an application, does that make a difference?)
Do you mean that it (and it would be only one) would work with a hidden color space, say CIE 1931 XYZ since it is the common reference, and that to obtain a model or a space, whichever is desired, this object would have methods that kick out a new object of the desired type? Presumably it could then construct itself on the basis of being given any color object, model or space - the reverse to the previous sentence and that perhaps the constructor could have an optional parameter of space, the default of which exposes the default space which is not directly accessible otherwise? How would you assign colors the model that it contains without specifying a model type and exposing its members, Red, Green and Blue for example?
Mike-MadBadger 22-Oct-13 16:25pm View    
Let's see if I've understood:
The classes, as conceived, don't think at all about actual drawing, they are just objects to manage colors, either color models or color spaces plus the conversions and the transitions between spaces and models (which is often confused). A color space being the manner in which a model becomes something real rather than abstract.

However, I think you are suggesting this:
A class called Color which contains as a member an interface, let's call it IColorModel.
The classes that manage the color models must implement IColorModel, RGB, CMYK etc.
The Color class should have a second member called IColorSpace which allows the model to be interpreted in such a way that it can be rendered correctly.
Color model conversions, e.g. RGB to CMYK, simply change the IColorModel member.
Color space changes, e.g. CIE 1931 XYZ to Adobe RGB change the IColorSpace member and have consequent changes on the IColorModel member, either a complete change or a change in the detail: CIELAB to sRGB would change both, Adobe RGB to sRGB would change the space and the detail of the model.
The ToGray methods, as an example, would call the relavant method of the IColor member which would probably also implement the IColorToGrey interface, both interface members pointing at the same actual object.

Have I understood anything?
Mike-MadBadger 20-Oct-13 16:48pm View    
aCMYK newColor = new aCMYK();

Public Interface IToGrey
Sub ToGrey(ByRef color As IColorModelConvertible)
End Interface

Public Interface IColorModelConvertible
Function ToARGB(Optional ByVal alpha As Integer = 255) As aRGB
Function ToColor(Optional ByVal alpha As Integer = 255) As Color
Function ToAHSB() As aHSB
Function ToAHSL() As aHSL
Function ToACMYK() As aCMYK
Function ToHex(Optional ByVal alpha As Integer = 255) As String
End Interface

Public Class RGBAverage
Implements IToGrey
Public Sub ToGrey(ByRef color As IColorModelConvertible) Implements IToGrey.ToGrey
Dim newARGB As aRGB = color.ToARGB()
newRGB.Green = newRGB.Red()
newRGB.Blue = newRGB.Red()
color = newRGB.To [Help: Don't know original class type!)
End Sub
Mike-MadBadger 27-Aug-13 16:27pm View    
Out of interest (sorry for the delay) why custom rather than InvalidEnumArgumentException or ArgumentOutOfRangeException?
I get the idea / benefit of writing your own exceptions, however those two seem pretty well aligned with the problem at hand?
Mike-MadBadger 27-Aug-13 16:23pm View    
Struggled a bit to understand your articles, they are, at least as yet, a bit ahead of me - hopefully I'll get there sooner or later.
I did however find this:
I found it be a usefully simpler explanation for my level.