Skip to content

Commit

Permalink
Add MDLColor>>allTints and Color>>#asRGBA.
Browse files Browse the repository at this point in the history
Close: #2
  • Loading branch information
jecisc committed Mar 31, 2018
1 parent a4d33cb commit b9e1eca
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 39 deletions.
5 changes: 3 additions & 2 deletions src/Material-Design-Colors.package/.filetree
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
"noMethodMetaData" : true,
"useCypressPropertiesFile" : true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
*Material-Design-Colors
asRGBA
^ String
streamContents: [ :s |
| alph |
alph := self alpha asString.
(alph endsWith: '.0')
ifTrue: [ alph := alph allButLast: 2 ].
s
nextPutAll: 'rgba(';
<< (self red * 255) ceiling;
nextPut: $,;
<< (self green * 255) ceiling;
nextPut: $,;
<< (self blue * 255) ceiling;
nextPut: $,;
<< alph;
nextPut: $) ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name" : "Color"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
allTints
^ self allDefaultsColors collect: #tint
19 changes: 10 additions & 9 deletions src/Material-Design-Colors.package/MDLColor.class/properties.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"commentStamp" : "<historical>",
"super" : "Color",
"category" : "Material-Design-Colors",
"classinstvars" : [
"colors" ],
"classvars" : [
],
"commentStamp" : "<historical>",
"colors"
],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"tint",
"code" ],
"code"
],
"name" : "MDLColor",
"pools" : [
],
"super" : "Color",
"type" : "normal" }
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"category" : "Material-Design-Colors",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "<historical>",
"instvars" : [
],
"name" : "ManifestMaterialDesignColors",
"pools" : [
],
"super" : "PackageManifest",
"type" : "normal" }
"category" : "Material-Design-Colors",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "ManifestMaterialDesignColors",
"type" : "normal"
}
3 changes: 1 addition & 2 deletions src/Material-Design-Colors.package/properties.json
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{
}
{ }
5 changes: 3 additions & 2 deletions src/Material-Design-Tests-Colors.package/.filetree
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"noMethodMetaData" : true,
"separateMethodMetaAndSource" : false,
"useCypressPropertiesFile" : true }
"noMethodMetaData" : true,
"useCypressPropertiesFile" : true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
tests
testAsRGBA
"The values were found on Material Design standard."

| rgbaMap |
rgbaMap := Dictionary new
at: #red put: 'rgba(244,67,54,1)';
at: #pink put: 'rgba(233,30,99,1)';
at: #purple put: 'rgba(156,39,176,1)';
at: #deep_purple put: 'rgba(103,58,183,1)';
at: #indigo put: 'rgba(63,81,181,1)';
at: #blue put: 'rgba(33,150,243,1)';
at: #light_blue put: 'rgba(3,169,244,1)';
at: #cyan put: 'rgba(0,188,212,1)';
at: #teal put: 'rgba(0,150,136,1)';
at: #green put: 'rgba(76,175,80,1)';
at: #light_green put: 'rgba(139,195,74,1)';
at: #lime put: 'rgba(205,220,57,1)';
at: #yellow put: 'rgba(255,235,59,1)';
at: #amber put: 'rgba(255,193,7,1)';
at: #orange put: 'rgba(255,152,0,1)';
at: #deep_orange put: 'rgba(255,87,34,1)';
at: #brown put: 'rgba(121,85,72,1)';
at: #grey put: 'rgba(158,158,158,1)';
at: #blue_grey put: 'rgba(96,125,139,1)';
yourself.
rgbaMap keysAndValuesDo: [ :tint :rgba | self assert: (MDLColor tint: tint) asRGBA equals: rgba ]
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"category" : "Material-Design-Tests-Colors",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "MDLColorTests",
"pools" : [
],
"super" : "TestCase",
"type" : "normal" }
"category" : "Material-Design-Tests-Colors",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "MDLColorTests",
"type" : "normal"
}
3 changes: 1 addition & 2 deletions src/Material-Design-Tests-Colors.package/properties.json
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{
}
{ }

0 comments on commit b9e1eca

Please sign in to comment.