Filled circle with circular gradient in ruby

For general discussion related FlowStone
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Filled circle with circular gradient in ruby

Post by tester »

Could someone post how to draw a circle/ellipse in ruby, that is filled with circular gradient? (one color in the center, other color outside). I'm confused a bit with the manual - it speaks on multipoint/coordinate gradients for polygons; I just need a simple ruby replacement for circle drawing prims.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Filled circle with circular gradient in ruby

Post by adamszabo »

try this:

Code: Select all

def draw v

c1 = Color.new 0,35,247
c2 = Color.new 210,34,67

r = [2,2,12,12]
p = GraphicsPath.new
p.addEllipse r
b = PathGradientBrush.new p

b.setSurroundColors [c1]
b.setCenterColor c2
b.setCenterPoint 8,8
b.setBlend [[0,0],[1,1],[1,1]]

v.drawEllipse b,r
end
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Filled circle with circular gradient in ruby

Post by tulamide »

adamszabo wrote:try this:

Code: Select all

def draw v

c1 = Color.new 0,35,247
c2 = Color.new 210,34,67

r = [2,2,12,12]
p = GraphicsPath.new
p.addEllipse r
b = PathGradientBrush.new p

b.setSurroundColors [c1]
b.setCenterColor c2
b.setCenterPoint 8,8
b.setBlend [[0,0],[1,1],[1,1]]

v.drawEllipse b,r
end

:o You've become a real pro at Ruby!
"There lies the dog buried" (German saying translated literally)
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Filled circle with circular gradient in ruby

Post by adamszabo »

tulamide wrote: :o You've become a real pro at Ruby!


Haha, nah im still far from that :D
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Filled circle with circular gradient in ruby

Post by tester »

Hey Adam, basically I need to integrate it into something like this. the csiz is diameter (2r). Center should have one color, and outer - second color.
Attachments
drawingdots.fsm
(635 Bytes) Downloaded 973 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Filled circle with circular gradient in ruby

Post by tulamide »

You mean the equivalent of the prims "Ellipse" and "Filled Ellipse"?

Just use a pen for outlines with :drawEllipse
and a brush for fills with :drawEllipse

Flowstone user guide, page 158+ for more information.
"There lies the dog buried" (German saying translated literally)
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Filled circle with circular gradient in ruby

Post by tester »

tulamide - may I ask you to not participate in topics, in which I'm OP? Thank you.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Filled circle with circular gradient in ruby

Post by tulamide »

tester - of course you may ask. What I do or not do is not up to you, but I'm glad you show your animosity, for whatever reason. You're welcome!
"There lies the dog buried" (German saying translated literally)
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Filled circle with circular gradient in ruby

Post by Spogg »

tester wrote:tulamide - may I ask you to not participate in topics, in which I'm OP? Thank you.


Speaking as a moderator I don’t think it’s acceptable to bar anyone from responding to a topic. A member posting here always has the option of not responding to a comment, for any reason.

If a post is considered to be unacceptable, for any reason whatsoever, please report it, with a reason, and a moderator will review the content.

In this particular instance I can’t judge the technical aspect of tulamide’s post but it may be useful to others following the subject.

As I’ve come to say lately, let’s keep it sweet guys!

Cheers

Spogg
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Filled circle with circular gradient in ruby

Post by tester »

Spogg, as a moderator - should you interfere at this point? Tricky question, isn't it?

Let say, that my motivation is a non-strict parallel to someone else who was recently pretty active on the forum.

I bet this thread is dead now.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Post Reply