From f9fa8f33bd092895c6e4d868e510ba3553e1529b Mon Sep 17 00:00:00 2001 From: Martin Dias Date: Tue, 10 Dec 2024 19:06:45 -0300 Subject: [PATCH] AeCairoRadialGradientPattern: Add instance creation API for same inner and outer center (frequent scenario) --- .../AeCairoExamplesRenderTest.class.st | 6 ++---- .../AeCairoGradientShadowFilter.class.st | 7 +++---- .../AeCairoRadialGradientPattern.class.st | 10 ++++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st b/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st index 6fe3887..a2a9202 100644 --- a/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st +++ b/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st @@ -626,9 +626,8 @@ AeCairoExamplesRenderTest >> surfaceWithShadowedCircleEmulatedBuffered [ format: AeCairoSurfaceFormat a8. aShadowContext := aShadowSurface newContext. aGradient := (AeCairoRadialGradientPattern - innerCenter: shadowCenter + center: shadowCenter innerRadius: radius - outerCenter: shadowCenter outerRadius: radius + shadowSize) addStopAt: 0.0 color: Color white; addStopAt: 0.2 color: (Color white alpha: 0.5); @@ -693,9 +692,8 @@ AeCairoExamplesRenderTest >> surfaceWithShadowedCircleEmulatedDirect [ "draw shadow" aGradient := (AeCairoRadialGradientPattern - innerCenter: shadowCenter + center: shadowCenter innerRadius: radius - outerCenter: shadowCenter outerRadius: radius + shadowSize) addStopAt: 0.0 color: shadowColor; addStopAt: 0.2 color: (shadowColor alpha: 0.5); diff --git a/src/Alexandrie-Cairo/AeCairoGradientShadowFilter.class.st b/src/Alexandrie-Cairo/AeCairoGradientShadowFilter.class.st index aaf4ca8..1d39b7c 100644 --- a/src/Alexandrie-Cairo/AeCairoGradientShadowFilter.class.st +++ b/src/Alexandrie-Cairo/AeCairoGradientShadowFilter.class.st @@ -43,11 +43,10 @@ AeCairoGradientShadowFilter >> paintFor: rectangle blurRadius: radius color: aCo aGradient := AeCairoRadialGradientPattern - innerCenter: rectangle topLeft + center: rectangle topLeft innerRadius: 0.0 - outerCenter: rectangle topLeft - outerRadius: radius - addStopsFrom: colorRamp. + outerRadius: radius. + aGradient addStopsFrom: colorRamp. aGradientMatrix := AeCairoMatrix newIdentity. aContext restoreStateAfter: [ diff --git a/src/Alexandrie-Cairo/AeCairoRadialGradientPattern.class.st b/src/Alexandrie-Cairo/AeCairoRadialGradientPattern.class.st index a6bbc44..d2ebbc7 100644 --- a/src/Alexandrie-Cairo/AeCairoRadialGradientPattern.class.st +++ b/src/Alexandrie-Cairo/AeCairoRadialGradientPattern.class.st @@ -9,6 +9,16 @@ Class { #category : #'Alexandrie-Cairo-Patterns' } +{ #category : #'instance creation' } +AeCairoRadialGradientPattern class >> center: aCenter innerRadius: anInnerRadius outerRadius: anOuterRadius [ + + ^ self + innerCenter: aCenter + innerRadius: anInnerRadius + outerCenter: aCenter + outerRadius: anOuterRadius +] + { #category : #'instance creation' } AeCairoRadialGradientPattern class >> innerCenter: anInnerCenter innerRadius: anInnerRadius outerCenter: anOuterCenter outerRadius: anOuterRadius [