Previous Document Next Document

Object Model Reference : Classes : C : Color : Properties : Color.Gray


Color.Gray

Property Gray As Long

Description

Member of Color

The Gray property returns or specifies the Gray value in for the grayscale color model in CorelDRAW. A color is an effect applied to an object that alters the object’s appearance by the way it reflects light. A color model is a system that defines the number and type of colors that make up an image and that is used to organize and define colors according to a set of basic properties that can be reproduced. Black-and-white, grayscale, RGB, CMYK, and paletted are examples of popular color modes.

The grayscale color model is a color mode that displays images using 256 shades of gray. Each color is defined as a value between 0 and 255, where 0 is darkest (black) and 255 is lightest (white). In the RGB color mode, a grayscale value corresponds to equal amounts of all RGB colors; in CMYK, a grayscale value corresponds to zero C, M, and Y values, with a positive K value; in HSB, a grayscale value corresponds to zero H and S values, with a positive B value. The grayscale color mode is based on the grayscale color model.

VBA example

The following VBA example decreases the lightness of the grayscale fill of the object. If the uniform fill color is not grayscale, the code assigns grayscale white to the object fill, prior to changing the lightness.

Sub Test()
 Dim s As Shape
 Set s = ActiveSelection.Shapes(1)
 If s.Fill.Type = cdrUniformFill Then
  If s.Fill.UniformColor.Type <> cdrColorGray Then
   s.Fill.UniformColor.GrayAssign 255
   s.Fill.UniformColor.Gray = s.Fill.UniformColor.Gray / 2
  End If
 End If
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.