該系列類沒有實例方法,只有構造方法,只須要構造後,傳入 Paint.setPathEffect(PathEffect effect)
便可。
概覽
java
CornerPathEffect(float radius)
android
Parameters | |
---|---|
radius | float: Amount to round sharp angles between line segments. |
Transforms geometries that are drawn (either STROKE
or FILL
styles) by replacing any sharp angles between line segments into rounded angles of the specified radius.git
DiscretePathEffect(float segmentLength, float deviation)
github
Parameters | |
---|---|
segmentLength | float |
deviation | float |
Chop the path into lines of segmentLengthdeviation**.canvas
segmentLength=1dp, deviation=10dp
app
segmentLength=10dp, deviation=10dp
this
DashPathEffect(float[] intervals, float phase)
spa
Parameters | |
---|---|
intervals | float: array of ON and OFF distances |
phase | float: offset into the intervals array 總體偏移, 動態設置 phase, 能夠產生螞蟻線效果 |
The intervals array must contain an even number of entries (>=2), with the even indices specifying the "on" intervals, and the odd indices specifying the "off" intervals.
phase is an offset into the intervals array (mod the sum of all of the intervals).
The intervals array controls the length of the dashes. The paint's strokeWidth controls the thickness of the dashes.
Note: this patheffect only affects drawing with the paint's style is set to STROKE
or FILL_AND_STROKE
. It is ignored if the drawing is done with style == FILL
.code
PathDashPathEffect(Path shape, float advance, float phase, PathDashPathEffect.Style style)
orm
Parameters | |
---|---|
shape | Path: The path to stamp along shape 須要是閉合路徑 |
advance | float: spacing between each stamp of shape shape 之間的間距, 忽略 shape 自己的大小 |
phase | float: amount to offset before the first shape is stamped 總體偏移, 動態設置 phase, 能夠產生螞蟻線效果 |
style | PathDashPathEffect.Style: how to transform the shape at each position as it is stamped 枚舉取值: MORPH, ROTATE, TRANSLATE MORPH: 方向跟路徑一致, 在拐角處變形 ROTATE: 方向跟路徑一致, 拐角處保持不變, 有斷開效果 TRANSLATE: 保持shape方向不變, 不隨路徑變化 MORPH 效果最好 |
Dash the drawn path by stamping it with the specified shape.
This only applies to drawings when the paint's style is STROKE
or STROKE_AND_FILL
. If the paint's style is FILL
, then this effect is ignored.
The paint's strokeWidth does not affect the results.
MORPH
ROTATE
TRANSLATE
SumPathEffect(PathEffect first, PathEffect second)
Construct a PathEffect whose effect is to apply two effects, in sequence. (e.g. first(path) + second(path))
將兩個 PathEffect 效果疊加,至關與繪製了2次。first
和 second
的順序無影響。
DashPathEffect + CornerPathEffect
ComposePathEffect(PathEffect outerpe, PathEffect innerpe)
Construct a PathEffect whose effect is to apply first the inner effect and the the outer pathEffect. (e.g. outer(inner(path)))
將兩個 PathEffect 效果進行組合,先進行 innerpe
,在此次的結果上在進行 outerpe
。兩次的順序不一樣,結果也有差別。
CornerPathEffect(DashPathEffect())
DashPathEffect(CornerPathEffect())