• Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Hot Door CORE Forum All forums General discussion v
1 2 3 Next »
creating gradients

 
  • 0 Vote(s) - 0 Average
creating gradients
Rick Johnson
Offline

Senior Member

Posts: 267
Threads: 133
Joined: Jan 2014
Reputation: 0
#1
02-21-2021, 11:27 AM (This post was last modified: 02-22-2021, 07:01 PM by Rick Johnson.)
I've been able to modify existing patterns and gradients, but now I need to create new gradients and it's not going well. First I create a gradient that I'm not sure is valid, since I can't put it into the swatches panel to see it, nor have I been able to apply it. I hope someone can help.

First, create a simple gradient. In the SDK is a file SnpGradient.cpp that follows these basic steps in a function CreateLinearGradient() that I've tried to follow.

Code:
hdi::core::Gradient grad = hdi::core::Gradient::create();
grad.setName("test gradient");
grad.setGradientType(hdi::core::Gradient::LinearGradientType);

I can read various member properties, so it appears to be a valid gradient, the default black/white one. I can get and change existing stops, but cannot insert new ones.

Code:
hdi::core::Gradient::Stop stp(0.5, 0.5, hdi::core::ArtColor::blue(), 1);
bool success = grad.insertStopAtIndex(1, stp); <-- ERROR

So I try to at least apply the gradient as-is to a selected path art object tempArt in a currentDocument()->selectedArt() loop.

Code:
hdi::core::PathStyle pStyl = tempArt->path()->style();
hdi::core::ArtColor::GradientStyle gStyl;
gStyl.gradient = grad;
pStyl.useFill = true;
pStyl.fill.color = hdi::core::ArtColor(&gStyl);
tempArt->path()->setStyle(pStyl);

As soon as I leave the matching-art loop I get Thread 1: signal SIGABRT

Does the ArtColor constructor copy the gradient, or merely point to some instance that needs to remain after this function is finished?

currentDocument has functions to count patterns and retrieve them by index, but unfortunately there's no counterparts for gradients so it's difficult to tell if the new gradients exist anywhere. I hope soon patterns and gradients can be added to the document Swatches.

Any suggestions would be very much appreciated.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

Linear Mode
Threaded Mode