-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple ColorSpinPlugin. Fixes to LessEngine.
minor clean up prevent double evaluation
- Loading branch information
1 parent
cd0d3fd
commit fa5d7cf
Showing
9 changed files
with
158 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace dotless.Core.Plugins | ||
{ | ||
using System; | ||
using Parser.Infrastructure.Nodes; | ||
using Parser.Tree; | ||
using Utils; | ||
|
||
public class ColorSpinPlugin : VisitorPlugin | ||
{ | ||
public double Spin { get; set; } | ||
|
||
public ColorSpinPlugin(double spin) | ||
{ | ||
Spin = spin; | ||
} | ||
|
||
public override PluginType AppliesTo | ||
{ | ||
get { return PluginType.AfterEvaluation; } | ||
} | ||
|
||
public override bool Execute(Node node) | ||
{ | ||
if(node is Color) | ||
{ | ||
var color = node as Color; | ||
|
||
var hslColor = HslColor.FromRgbColor(color); | ||
hslColor.Hue += Spin/360.0d; | ||
var newColor = hslColor.ToRgbColor(); | ||
|
||
color.R = newColor.R; | ||
color.G = newColor.G; | ||
color.B = newColor.B; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace dotless.Test.Plugins | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Core.Parser.Infrastructure; | ||
using Core.Parser.Infrastructure.Nodes; | ||
using Core.Parser.Tree; | ||
using Core.Plugins; | ||
using NUnit.Framework; | ||
|
||
public class ColorSpinPluginFixture : SpecFixtureBase | ||
{ | ||
protected List<Color> Colors; | ||
protected Ruleset Tree { get; set; } | ||
protected ColorSpinPlugin Plugin { get; set; } | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
Plugins.Clear(); | ||
Plugins.Add(new ColorSpinPlugin(60)); | ||
} | ||
|
||
[Test] | ||
public void ColorIsRotated60Degrees() | ||
{ | ||
AssertExpression("#646400", "#640000"); | ||
AssertExpression("#00c8c8", "#00c800"); | ||
} | ||
|
||
[Test] | ||
public void ExpressionIsRotatedAfterEvaluation() | ||
{ | ||
AssertExpression("#00c864", "#640000 + #00c800"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters