Skip to content

Latest commit

 

History

History
217 lines (151 loc) · 3.95 KB

index.md

File metadata and controls

217 lines (151 loc) · 3.95 KB
theme css fonts routerMode canvasWidth
default
unocss
sans mono
'Noto Sans SC', 'Open Sans', 'Noto Color Emoji'
'Fira Code', monospace
hash
1920

Presenter

报告模板

Mufanc

代码框

<style scoped> p { margin-top: 0; } </style>
  • 代码段
float Q_rsqrt( float number ) 
{
    long i;
    float x2, y;
    const float threeHalfs = 1.5f;

    x2 = number * 0.5f;
    y  = number;
    i  = * ( long * ) &y;                       // evil floating point bit level hacking
    i  = 0x5f3759df - ( i >> 1 );               // What the fuck? 
    y  = * ( float * ) &i;
    y  = y * ( threeHalfs - ( x2 * y * y ) );   // 1st iteration
//  y  = y * ( threeHalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

    return y;
}
  • 行内代码

SQL 查询: SELECT `username` FROM users;


<x-clicks> 组件

  • 允许在组件内感知页面 clicks 变化
<x-clicks :k='5'>
    <some-component />
</x-clicks>
  • 后面也还可以再接其它 v-click

  • 就像这样


<style scoped> .at-click { display: inline; } </style>

<at-click> 组件

  • 感知页面 clicks 变化,并显示隐藏一些内容
<at-click k="=3">仅当 clicks 为 3 时显示</at-click>
<at-click k="!3">仅当 clicks 不为 3 时显示</at-click>
<at-click k="3">当 clicks >= 3 时显示</at-click>
<at-click k=">=3" gone>同上,且隐藏时不占用布局空间</at-click>
<at-click k="<3">当 clicks < 3 时显示</at-click>
  • ➡️ 仅当 clicks 为 3 时显示 ⬅️

  • ➡️ 仅当 clicks 不为 3 时显示 ⬅️

  • ➡️ 当 clicks >= 3 时显示 ⬅️

  • ➡️ 同上,且隐藏时不占用文档空间 ⬅️

  • ➡️ 当 clicks < 3 时显示 ⬅️


<flexi-code> 组件

  • 变化的代码框,可以用来实现一些漂亮的动画
class Scheduler(object):
    def __init__(self, timer_id: int):
        self._timer = Timer(timer_id)
        self._pending_tasks = PriorityQueue()
        self._running_tasks = []
        self._lock = ThreadSafeFlag()
        asyncio.create_task(self._loop())
    async def _loop(self):
        while True:  
            await self._lock.wait()
            self._lock.clear()
            self._running_tasks.pop(0)()
    def _refresh(self):
        current_time = ticks_ms()
        delay = self._pending_tasks.peek()[0] - current_time
        self._timer.init(
            mode=Timer.ONE_SHOT, 
            period=delay, 
            callback=self._callback
        )
    def _callback(self, *_):
        _, callback, in_irq = self._pending_tasks.pop()

        if in_irq:
            callback()
        else:
            self._running_tasks.append(callback)
            self._lock.set()

        if len(self._pending_tasks) != 0:
            self._refresh()
    def call_later(self, callback, delay_ms, in_irq=False):
        current_time = ticks_ms()
        
        self._pending_tasks.add((
            ticks_add(current_time, delay_ms), 
            callback, 
            in_irq
        ))
        
        self._refresh()