@@ -228,6 +228,273 @@ public static void Func6(GraphicHelper helper, string str,string alias, string p
228228 } , "cubic-bezier(0,.8,.2,1)" ) ;
229229 } ) ;
230230 }
231+
232+ //说明:根据包围盒进行检测,如果是长方形则从对应的横向/纵向进入。
233+ //TODO: 带时间轴
234+ public static void Func7 ( GraphicHelper helper , string str , string alias , string parent , TextProperty prop ,
235+ float direction , float effect , float duration , List < float > timeline )
236+ {
237+ int charDistance = ( int ) ( 100f * prop . scale ?? 1.0 ) ;
238+ const float strokeOffset = 0.04f ;
239+ const float charOffset = 0.1f ;
240+ helper . AddText ( str , alias , parent , prop , ( p , noChar , noStroke ) =>
241+ {
242+ p . x = 0 ;
243+ p . alpha = 0 ;
244+ } , ( motion , p , noChar , noStroke , ctx ) =>
245+ {
246+ var graphic = ctx . Info ;
247+ var ( width , height ) = GraphicHelper . GetRealBoundingBox ( graphic ) ;
248+ width ++ ;
249+ height ++ ;
250+ var ratio = width / height ;
251+ var offset = strokeOffset * noStroke + timeline [ noChar ] ;
252+ var dstX = ( float ) ( noChar * charDistance * Math . Cos ( direction ) ) ;
253+ var dstY = ( float ) ( noChar * charDistance * Math . Sin ( direction ) ) ;
254+ var index = ( ( noChar * 5 + noStroke ) % 2 ) * 2 - 1 ;
255+
256+ motion . Apply ( offset ) ;
257+ motion . Apply ( 0.001f , new TextProperty { alpha = 1 } ) ;
258+ if ( ratio < 0.5 ) //竖线
259+ {
260+ motion . Apply ( 0.001f , new TextProperty { y = index * 1000 + dstY , x = dstX } ) ;
261+ motion . Apply ( effect * 0.15f , new TextProperty ( )
262+ {
263+ y = index * 100 + dstY
264+ } ) ;
265+ motion . Apply ( effect * 0.85f , new TextProperty ( )
266+ {
267+ y = dstY
268+ } , "cubic-bezier(0,1,0,1)" ) ;
269+ }
270+ else if ( ratio < 1.5 ) //一般
271+ {
272+ motion . Apply ( 0.001f , new TextProperty { y = dstY , x = dstX } ) ;
273+ motion . Apply ( 0.001f , new TextProperty { scale = 0 , rotateZ = 720 } ) ;
274+ motion . Apply ( effect , new TextProperty ( )
275+ {
276+ scale = prop . scale ,
277+ rotateZ = 0
278+ } , "cubic-bezier(0,1,0,1)" ) ;
279+ }
280+ else
281+ { //横线
282+ motion . Apply ( 0.001f , new TextProperty { y = dstY , x = index * 1000 + dstX } ) ;
283+ motion . Apply ( effect * 0.15f , new TextProperty ( )
284+ {
285+ x = index * 100 + dstX
286+ } ) ;
287+ motion . Apply ( effect * 0.85f , new TextProperty ( )
288+ {
289+ x = dstX
290+ } , "cubic-bezier(0,1,0,1)" ) ;
291+ }
292+ motion . Apply ( duration - offset ) ;
293+ motion . Apply ( 0.001f , new TextProperty { alpha = 0 } ) ;
294+ } ) ;
295+ }
296+
297+ //说明:横向向右弹出。带时间轴
298+ public static void Func8 ( GraphicHelper helper , string str , string alias , string parent , TextProperty prop ,
299+ float effect , float duration , List < float > timeline )
300+ {
301+ const int charDistance = 30 ;
302+ const float strokeOffset = 0.04f ;
303+ const float charOffset = 0f ;
304+ helper . AddText ( str , alias , parent , prop , ( p , noChar , noStroke ) =>
305+ {
306+ p . x = 0 ;
307+ p . alpha = 0 ;
308+ } , ( motion , p , noChar , noStroke ) =>
309+ {
310+ var offset = strokeOffset * noStroke ;
311+ motion . Apply ( timeline [ noChar ] + offset ) ;
312+ motion . Apply ( 0.001f , new TextProperty { alpha = 1 } ) ;
313+ motion . Apply ( effect + offset , new TextProperty ( )
314+ {
315+ x = charDistance * noChar
316+ } , "cubic-bezier(0,.8,.2,1)" ) ;
317+ motion . Apply ( duration ) ;
318+ } ) ;
319+ }
320+
321+ public static void RandomMove ( MotionHelper motion , Random rnd , float duration , float dstX , float dstY ,
322+ float distanceX = 1f , float distanceY = 200f , bool isBackup = false )
323+ {
324+ for ( ; ; )
325+ {
326+ if ( duration <= 0 )
327+ break ;
328+ float current = 1.0f ;
329+ if ( duration < 2.0f )
330+ {
331+ distanceX = 0 ;
332+ distanceY = 0 ;
333+ current = duration ;
334+ }
335+
336+ float angle = ( float ) ( ( rnd . NextDouble ( ) - 0.5f ) * Math . PI ) ;
337+ motion . Apply ( current , new TextProperty
338+ {
339+ x = dstX + distanceX * ( float ) Math . Cos ( angle ) ,
340+ y = dstY + distanceY * ( float ) Math . Sin ( angle ) ,
341+ } , "cubic-bezier(.5,0,.5,1)" , isBackup : isBackup ) ;
342+ duration -= current ;
343+ }
344+ }
345+
346+ public static void RandomRot ( MotionHelper motion , Random rnd , float duration , float dstRot ,
347+ float distance = 3 , bool isBackup = false )
348+ {
349+ for ( ; ; )
350+ {
351+ if ( duration <= 0 )
352+ break ;
353+ float current = 0.75f ;
354+ if ( duration < 1.5f )
355+ {
356+ distance = 0 ;
357+ current = duration ;
358+ }
359+
360+ float value = ( float ) ( ( rnd . NextDouble ( ) - 0.5f ) * distance ) ;
361+ motion . Apply ( current , new TextProperty
362+ {
363+ rotateZ = ( dstRot + value )
364+ } , "cubic-bezier(.5,0,.5,1)" , isBackup : isBackup ) ;
365+ duration -= current ;
366+ }
367+ }
368+
369+
370+ //说明:横向向左弹出。带时间轴
371+ public static void Func9 ( GraphicHelper helper , string str , string alias , string parent , TextProperty prop ,
372+ float effect , float duration , List < float > timeline )
373+ {
374+ const int charDistance = - 30 ;
375+ const float strokeOffset = 0.04f ;
376+ const float charOffset = 0f ;
377+ helper . AddText ( str , alias , parent , prop , ( p , noChar , noStroke ) =>
378+ {
379+ p . x = 0 ;
380+ p . alpha = 0 ;
381+ } , ( motion , p , noChar , noStroke ) =>
382+ {
383+ var offset = strokeOffset * noStroke ;
384+ motion . Apply ( timeline [ noChar ] + offset ) ;
385+ motion . Apply ( 0.001f , new TextProperty { alpha = 1 } ) ;
386+ motion . Apply ( effect + offset , new TextProperty ( )
387+ {
388+ x = charDistance * noChar
389+ } , "cubic-bezier(0,.8,.2,1)" ) ;
390+ motion . Apply ( duration ) ;
391+ } ) ;
392+ }
393+
394+ //说明:横向笔划闪现。带时间轴
395+ public static void Func10 ( GraphicHelper helper , string str , string alias , string parent , TextProperty prop ,
396+ float effect , List < float > timeline )
397+ {
398+ const int charDistance = 90 ;
399+ const int strokeDistance = 30 ;
400+ const float strokeOffset = 0.02f ;
401+ const float charOffset = 0f ;
402+ helper . AddText ( str , alias , parent , prop , ( p , noChar , noStroke ) =>
403+ {
404+ p . x = charDistance * noChar + strokeDistance * noStroke ;
405+ p . alpha = 0 ;
406+ } , ( motion , p , noChar , noStroke ) =>
407+ {
408+ var offset = strokeOffset * noStroke ;
409+ motion . Apply ( timeline [ noChar ] + offset ) ;
410+ motion . Apply ( 0.001f , new TextProperty { alpha = 1 } ) ;
411+ motion . Apply ( effect , new TextProperty ( )
412+ {
413+ x = 30 + charDistance * noChar + strokeDistance * noStroke
414+ } , "cubic-bezier(0,.8,.2,1)" ) ;
415+ motion . Apply ( 0.001f , new TextProperty { alpha = 0 } ) ;
416+ } ) ;
417+ }
418+
419+
420+ //说明:根据包围盒进行检测,如果是长方形则从对应的横向/纵向进入。
421+ //带字体大小分别设定,和行距处理的版本
422+ public static void Func11 ( GraphicHelper helper , string str , string alias , string parent , TextProperty prop ,
423+ float direction , float effect , float duration , List < float > timeline , List < float > fontSize )
424+ {
425+ const int lineSpacing = 25 ;
426+ int charLocation = 0 ; //(int)(lineSpacing + 100f * prop.scale??1.0);
427+ const float strokeOffset = 0.03f ;
428+ const float charOffset = 0.1f ;
429+ helper . AddText ( str , alias , parent , prop , ( p , noChar , noStroke ) =>
430+ {
431+ p . alpha = 0 ;
432+ p . scale = fontSize [ noChar ] ;
433+ if ( noChar > 0 && noStroke == 0 )
434+ {
435+ charLocation += ( int ) ( lineSpacing + 0.5f * 50f * fontSize [ noChar - 1 ]
436+ + 50f * fontSize [ noChar ] ) ;
437+ }
438+ } , ( motion , p , noChar , noStroke , ctx ) =>
439+ {
440+ var graphic = ctx . Info ;
441+ var ( width , height ) = GraphicHelper . GetRealBoundingBox ( graphic ) ;
442+ width ++ ;
443+ height ++ ;
444+ var ratio = width / height ;
445+ var offset = strokeOffset * noStroke + timeline [ noChar ] ;
446+ var dstX = ( float ) ( charLocation * Math . Cos ( direction ) ) ;
447+ var dstY = ( float ) ( charLocation * Math . Sin ( direction ) ) ;
448+ var index = ( ( noChar * 5 + noStroke ) % 2 ) * 2 - 1 ;
449+
450+ motion . Apply ( offset ) ;
451+ motion . Apply ( 0.001f , new TextProperty { alpha = 1 } ) ;
452+ if ( ratio < 0.5 ) //竖线
453+ {
454+ motion . Apply ( 0.001f , new TextProperty { y = index * 1000 + dstY , x = dstX } ) ;
455+ motion . Apply ( effect * 0.15f , new TextProperty ( )
456+ {
457+ y = index * 100 + dstY
458+ } ) ;
459+ motion . Apply ( effect * 0.85f , new TextProperty ( )
460+ {
461+ y = dstY
462+ } , "cubic-bezier(0,1,0,1)" ) ;
463+ }
464+ else if ( ratio < 1.5 ) //一般
465+ {
466+ motion . Apply ( 0.001f , new TextProperty { y = dstY , x = dstX } ) ;
467+ motion . Apply ( 0.001f , new TextProperty { scale = 0 , rotateZ = 720 } ) ;
468+ motion . Apply ( effect , new TextProperty ( )
469+ {
470+ scale = prop . scale ,
471+ rotateZ = 0
472+ } , "cubic-bezier(0,1,0,1)" ) ;
473+ }
474+ else
475+ { //横线
476+ motion . Apply ( 0.001f , new TextProperty { y = dstY , x = index * 1000 + dstX } ) ;
477+ motion . Apply ( effect * 0.15f , new TextProperty ( )
478+ {
479+ x = index * 100 + dstX
480+ } ) ;
481+ motion . Apply ( effect * 0.85f , new TextProperty ( )
482+ {
483+ x = dstX
484+ } , "cubic-bezier(0,1,0,1)" ) ;
485+ }
486+ motion . Apply ( duration - offset - 0.100f ) ;
487+ motion . Apply ( 0.001f , new TextProperty { alpha = 0 } ) ;
488+ motion . Apply ( 0.02f , new TextProperty { alpha = 1 } ) ;
489+ motion . Apply ( 0.02f , new TextProperty { alpha = 0 } ) ;
490+ motion . Apply ( 0.02f , new TextProperty { alpha = 1 } ) ;
491+ motion . Apply ( 0.02f , new TextProperty { alpha = 0 } ) ;
492+ motion . Apply ( 0.02f , new TextProperty { alpha = .5f } ) ;
493+ motion . Apply ( 0.02f , new TextProperty { alpha = 0 } ) ;
494+ motion . Apply ( 0.02f , new TextProperty { alpha = .5f } ) ;
495+ motion . Apply ( 0.02f , new TextProperty { alpha = 0 } ) ;
496+ } ) ;
497+ }
231498
232499 static void Func3 ( )
233500 {
0 commit comments