@@ -17,8 +17,7 @@ How to use:
17
17
- Click the box at the top to open the picker
18
18
- Move around and click to select colours
19
19
- Type/backspace and enter to change the colour directly
20
- - Move the slider on the right of the save button to change the transparency.
21
- - Click the save button to the right of the box to save the colour
20
+ - Click the button to the right of the box to save the colour
22
21
- Saved colours appear when you press the cog icon at the top of expressions list and click the coloured circle for a given expression
23
22
24
23
When you save a desmos graph using custom colours the colours on the expressions will save!
@@ -40,13 +39,6 @@ setTimeout(function() {
40
39
return "#" + hex ( rgb [ 1 ] ) + hex ( rgb [ 2 ] ) + hex ( rgb [ 3 ] ) ;
41
40
}
42
41
43
- function rgbaify ( rgb , a ) {
44
- if ( / ^ # [ 0 - 9 A - F ] { 6 } $ / i. test ( rgb ) ) return rgb ;
45
-
46
- rgb = rgb . match ( / ^ r g b \( ( \d + ) , \s * ( \d + ) , \s * ( \d + ) \) $ / ) ;
47
- return "rgba(" + rgb [ 1 ] + ',' + rgb [ 2 ] + ',' + rgb [ 3 ] + ',' + Number ( a ) / 100 + ')' ;
48
- }
49
-
50
42
var target = document . getElementsByClassName ( "dcg-header-desktop" ) [ 0 ] ;
51
43
var hold = document . createElement ( 'span' ) ;
52
44
target . insertBefore ( hold , target . childNodes [ 2 ] )
@@ -55,48 +47,35 @@ setTimeout(function() {
55
47
zNode . setAttribute ( 'id' , 'picker' ) ;
56
48
zNode . setAttribute ( 'value' , "ffffff" ) ;
57
49
zNode . jscolor = new jscolor ( zNode ) ;
58
- console . log ( zNode . jscolor ) ;
59
- zNode . style . width = '25%' ;
50
+ zNode . jscolor . alpha = 1 ;
51
+ zNode . jscolor . option ( 'hash' , false ) ;
52
+ zNode . style . width = '40%' ;
60
53
zNode . style . height = '45%' ;
61
54
hold . appendChild ( zNode ) ;
62
55
63
56
var gp = document . getElementById ( 'picker' )
64
- var tr = "100" ;
65
57
66
58
zNode = document . createElement ( 'span' ) ;
67
59
zNode . setAttribute ( 'id' , 'cstore' ) ;
68
60
zNode . setAttribute ( 'role' , 'button' ) ;
69
61
zNode . setAttribute ( 'class' , "dcg-btn-green" ) ;
70
- zNode . innerHTML = "<div style = \"font-size: 85%; position: relative; left:-180%; top:-20%\">Save</div>" ;
71
- zNode . setAttribute ( 'style' , "position: relative; width:11.25%; left:2.5%; top:10%; height:50%" ) ;
72
- hold . appendChild ( zNode ) ;
73
-
74
- zNode = document . createElement ( 'input' ) ;
75
- zNode . setAttribute ( 'id' , 'ctrans' ) ;
76
- zNode . type = 'range' ;
77
- zNode . min = 0 ;
78
- zNode . max = 100 ;
79
- zNode . value = 100 ;
80
- zNode . step = 1 ;
81
- zNode . setAttribute ( 'style' , "position: relative; width:15%; left:5%; top:5%; height:22.5%" ) ;
82
- zNode . oninput = function ( ) {
83
- tr = this . value ;
84
- }
62
+ zNode . setAttribute ( 'text' , "Save" ) ;
63
+ zNode . setAttribute ( 'style' , "position: relative; width:11.25%; left:2.5%; top:15%; height:45%" ) ;
85
64
hold . appendChild ( zNode ) ;
86
65
87
66
document . getElementById ( 'cstore' ) . addEventListener ( "click" , makeColour , false ) ;
88
67
function makeColour ( zEvent ) {
89
- var gcol = gp . jscolor . toRGBString ( ) ;
90
- if ( gcol ) {
91
- var col = tr + rgb2hex ( gcol ) ;
92
- var acol = rgbaify ( gcol , tr ) ;
68
+ var col = gp . jscolor . toHEXString ( ) + '|' + gp . jscolor . channel ( 'A' ) ;
69
+ var acol = gp . jscolor . toRGBAString ( )
70
+ if ( gp . jscolor . channel ( 'A' ) == '1' ) {
71
+ var gcol = gp . jscolor . toHEXString ( )
93
72
for ( var c in unsafeWindow . Calc . colors ) {
94
- if ( unsafeWindow . Calc . colors [ c ] == acol ) {
73
+ if ( unsafeWindow . Calc . colors [ c ] == gcol ) {
95
74
return ;
96
75
}
97
76
}
98
- unsafeWindow . Calc . colors [ col ] = acol ;
99
77
}
78
+ unsafeWindow . Calc . colors [ col ] = acol ;
100
79
}
101
80
102
81
} , 0 ) ;
0 commit comments