Previous Document Next Document

Object Model Reference : Classes : C : Color : Methods : Color.ConvertToGray


Color.ConvertToGray

Sub ConvertToGray()

Description

Member of Color

The ConvertToGray method converts the active color model to 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 converts all uniform fill colors in the selected shapes to the grayscale color model.

Sub Test()
 Dim c As New color
 Dim s As Shape
 For Each s In ActiveSelection.Shapes
  If s.Fill.Type = cdrUniformFill Then
   s.Fill.UniformColor.ConvertToGray
  End If
 Next s
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.