Page 1 of 2

Filled circle with circular gradient in ruby

Posted: Sat Dec 30, 2017 11:49 am
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.

Re: Filled circle with circular gradient in ruby

Posted: Sat Dec 30, 2017 12:11 pm
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

Re: Filled circle with circular gradient in ruby

Posted: Sat Dec 30, 2017 1:19 pm
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!

Re: Filled circle with circular gradient in ruby

Posted: Sat Dec 30, 2017 2:02 pm
by adamszabo
tulamide wrote: :o You've become a real pro at Ruby!


Haha, nah im still far from that :D

Re: Filled circle with circular gradient in ruby

Posted: Sun Dec 31, 2017 11:34 am
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.

Re: Filled circle with circular gradient in ruby

Posted: Sun Dec 31, 2017 12:53 pm
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.

Re: Filled circle with circular gradient in ruby

Posted: Sun Dec 31, 2017 10:38 pm
by tester
tulamide - may I ask you to not participate in topics, in which I'm OP? Thank you.

Re: Filled circle with circular gradient in ruby

Posted: Sun Dec 31, 2017 11:24 pm
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!

Re: Filled circle with circular gradient in ruby

Posted: Mon Jan 01, 2018 11:13 am
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

Re: Filled circle with circular gradient in ruby

Posted: Mon Jan 01, 2018 2:16 pm
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.