@@ -876,19 +876,21 @@ Croquis.createChecker = function (cellSize, colorA, colorB) {
876
876
return checker ;
877
877
}
878
878
Croquis . createBrushPointer = function ( brushImage , brushSize , brushAngle ,
879
- threshold , antialias , color ) {
879
+ threshold , antialias , color ,
880
+ shadow , shadowOffsetX , shadowOffsetY ) {
880
881
brushSize = brushSize | 0 ;
881
882
var pointer = document . createElement ( 'canvas' ) ;
882
883
var pointerContext = pointer . getContext ( '2d' ) ;
884
+ var boundWidth ;
885
+ var boundHeight ;
883
886
if ( brushSize == 0 ) {
884
- pointer . width = 1 ;
885
- pointer . height = 1 ;
886
- return pointer ;
887
+ pointer . width = boundWidth = 1 ;
888
+ pointer . height = boundHeight = 1 ;
887
889
}
888
890
if ( brushImage == null ) {
889
891
var halfSize = ( brushSize * 0.5 ) | 0 ;
890
- pointer . width = brushSize ;
891
- pointer . height = brushSize ;
892
+ pointer . width = boundWidth = brushSize ;
893
+ pointer . height = boundHeight = brushSize ;
892
894
pointerContext . fillStyle = '#000' ;
893
895
pointerContext . beginPath ( ) ;
894
896
pointerContext . arc ( halfSize , halfSize , halfSize , 0 , Math . PI * 2 ) ;
@@ -903,8 +905,8 @@ Croquis.createBrushPointer = function (brushImage, brushSize, brushAngle,
903
905
var abs = Math . abs ;
904
906
var sin = Math . sin ;
905
907
var cos = Math . cos ;
906
- var boundWidth = abs ( height * sin ( ra ) ) + abs ( width * cos ( ra ) ) ;
907
- var boundHeight = abs ( width * sin ( ra ) ) + abs ( height * cos ( ra ) ) ;
908
+ boundWidth = abs ( height * sin ( ra ) ) + abs ( width * cos ( ra ) ) ;
909
+ boundHeight = abs ( width * sin ( ra ) ) + abs ( height * cos ( ra ) ) ;
908
910
pointer . width = boundWidth ;
909
911
pointer . height = boundHeight ;
910
912
pointerContext . save ( ) ;
@@ -914,8 +916,26 @@ Croquis.createBrushPointer = function (brushImage, brushSize, brushAngle,
914
916
pointerContext . drawImage ( brushImage , 0 , 0 , width , height ) ;
915
917
pointerContext . restore ( ) ;
916
918
}
917
- return Croquis . createAlphaThresholdBorder (
918
- pointer , threshold , antialias , color ) ;
919
+ var result ;
920
+ var alphaThresholdBorder = Croquis . createAlphaThresholdBorder (
921
+ pointer , threshold , antialias , color ) ;
922
+ if ( shadow ) {
923
+ shadowOffsetX = shadowOffsetX ? shadowOffsetX : 1 ;
924
+ shadowOffsetY = shadowOffsetY ? shadowOffsetY : 1 ;
925
+ result = document . createElement ( 'canvas' ) ;
926
+ result . width = boundWidth + shadowOffsetX ;
927
+ result . height = boundHeight + shadowOffsetY ;
928
+ var resultContext = result . getContext ( '2d' ) ;
929
+ resultContext . shadowOffsetX = shadowOffsetX ;
930
+ resultContext . shadowOffsetY = shadowOffsetY ;
931
+ resultContext . shadowColor = shadow ;
932
+ resultContext . drawImage (
933
+ alphaThresholdBorder , 0 , 0 , boundWidth , boundHeight ) ;
934
+ }
935
+ else {
936
+ result = alphaThresholdBorder ;
937
+ }
938
+ return result ;
919
939
} ;
920
940
Croquis . createAlphaThresholdBorder = function ( image , threshold ,
921
941
antialias , color ) {
0 commit comments