OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > Corel Script > CorelDRAW CS

Thread Tools Search this Thread Display Modes
Old 03-05-2004, 20:07
Posts: n/a
Default Try to capture a fill color for reuse

I am trying to capture an objects current fill color and then alter THE ACTUAL color in a specific way (like make it lighter or darker) and then use that color to fill a second object.

I can't find a function that "gets" a fill color and stores it.


BTW, I'm not looking for fancy at this point so Uniform Fills are fine.
Reply With Quote
Old 03-05-2004, 20:48
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Try to capture a fill color for reuse

What version of CorelDRAW do you use? If you use CorelDRAW 9 or later, I'd use VBA for this as it is so much easier to work with and do what you want. However if you have to use CorelScript instead of VBA, then here is how you do it (the following script adds 10% of black to CMYK- or RGB-filled selected object):

Dim md As Long
Dim c1 As Long, c2 As Long, c3 As Long, c4 As Long
Dim c5 As Long, c6 As Long, c7 As Long
WITHOBJECT "CorelDRAW.Automation.8"
    .GetUniformFillColor md, c1, c2, c3, c4, c5, c6, c7
    Select Case (md Mod 1000)
        Case 2
            ' CMYK color model
            c4 = c4 + 10
        Case 5
            ' RGB color
            c1 = c1 * 0.9
            c2 = c3 * 0.9
            c3 = c3 * 0.9
    End Select
    .StoreColor md, c1, c2, c3, c4, c5, c6, c7, 0
Now compare this to a similar in functionality VBA macro:

Sub BlendColor1()
    Dim cBlack As Color
    Set cBlack = CreateCMYKColor(0, 0, 0, 100)
    ActiveShape.Fill.UniformColor.BlendWith cBlack, 90
End Sub
Or if you must do your own calculations, as with the CorelScript example above, here is how much simpler it is in VBA:

Sub BlendColor2()
    Dim cFill As New Color
    cFill.CopyAssign ActiveShape.Fill.UniformColor
    Select Case cFill.Type
        Case cdrColorCMYK
            cFill.CMYKBlack = cFill.CMYKBlack + 10
        Case cdrColorRGB
            cFill.RGBRed = cFill.RGBRed * 0.9
            cFill.RGBGreen = cFill.RGBGreen * 0.9
            cFill.RGBBlue = cFill.RGBBlue * 0.9
    End Select
    ActiveShape.Fill.UniformColor = cFill
End Sub
Well, you've got the idea
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
object lost it's linear fountain fill property after metalickaah CorelDRAW/Corel DESIGNER VBA 5 02-01-2005 22:36
Gradient Fill Michael Cervantes Corel Photo-Paint VBA 1 08-04-2004 09:05
fill type jwknight CorelDRAW/Corel DESIGNER VBA 1 04-03-2004 13:47
How can I change middle colors in a custom Fountain Fill Steve CorelDRAW/Corel DESIGNER VBA 3 13-12-2002 19:11
Corel Capture 8 and Corel Script Helix CorelDRAW CS 0 13-12-2002 18:10

All times are GMT -5. The time now is 19:52.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com