资源简介
kivy 官方 开发 demo,适合初学者,全面了解kivy。涉及空间、图片、动画、3D等。

代码片段和文件信息
‘‘‘
Shuffled Camera Feed Puzzle
===========================
This demonstrates using Scatter widgets with a live camera.
You should see a shuffled grid of rectangles that make up the
camera feed. You can drag the squares around to see the
unscrambled camera feed or double click to scramble the grid
again.
‘‘‘
from kivy.app import App
from kivy.uix.camera import Camera
from kivy.uix.widget import Widget
from kivy.uix.slider import Slider
from kivy.uix.scatter import Scatter
from kivy.animation import Animation
from kivy.graphics import Color Rectangle
from kivy.properties import NumericProperty
from random import randint random
from functools import partial
class Puzzle(Camera):
blocksize = NumericProperty(100)
def on_texture_size(self instance value):
self.build()
def on_blocksize(self instance value):
self.build()
def build(self):
self.clear_widgets()
texture = self.texture
if not texture:
return
bs = self.blocksize
tw th = self.texture_size
for x in range(int(tw / bs)):
for y in range(int(th / bs)):
bx = x * bs
by = y * bs
subtexture = texture.get_region(bx by bs bs)
# node = PuzzleNode(texture=subtexture
# size=(bs bs) pos=(bx by))
node = Scatter(pos=(bx by) size=(bs bs))
with node.canvas:
Color(1 1 1)
Rectangle(size=node.size texture=subtexture)
self.add_widget(node)
self.shuffle()
def shuffle(self):
texture = self.texture
bs = self.blocksize
tw th = self.texture_size
count = int(tw / bs) * int(th / bs)
indices = list(range(count))
childindex = 0
while indices:
index = indices.pop(randint(0 len(indices) - 1))
x = bs * (index % int(tw / bs))
y = bs * int(index / int(tw / bs))
child = self.children[childindex]
a = Animation(d=random() / 4.) + Animation(pos=(x y)
t=‘out_quad‘ d=.4)
a.start(child)
childindex += 1
def on_touch_down(self touch):
if touch.is_double_tap:
self.shuffle()
return True
super(Puzzle self).on_touch_down(touch)
class PuzzleApp(App):
def build(self):
root = Widget()
puzzle = Puzzle(resolution=(640 480) play=True)
slider = Slider(min=100 max=200 step=10 size=(800 50))
slider.bind(value=partial(self.on_value puzzle))
root.add_widget(puzzle)
root.add_widget(slider)
return root
def on_value(self puzzle instance value):
value = int((value + 5) / 10) * 10
puzzle.blocksize = value
instance.value = value
PuzzleApp().run()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-20 11:15 demo\
文件 2957 2018-04-20 11:15 demo\camera_puzzle.py
目录 0 2018-04-20 11:17 demo\kivycatalog\
目录 0 2018-04-20 11:17 demo\kivycatalog\.idea\
文件 11 2018-04-20 11:17 demo\kivycatalog\.idea\.name
文件 159 2018-04-20 11:17 demo\kivycatalog\.idea\encodings.xm
文件 284 2018-04-20 11:17 demo\kivycatalog\.idea\kivycatalog.iml
文件 701 2018-04-20 11:17 demo\kivycatalog\.idea\misc.xm
文件 274 2018-04-20 11:17 demo\kivycatalog\.idea\modules.xm
文件 15318 2018-04-20 11:17 demo\kivycatalog\.idea\workspace.xm
目录 0 2018-04-20 11:15 demo\kivycatalog\container_kvs\
文件 261 2018-04-20 11:15 demo\kivycatalog\container_kvs\AnchorLayoutContainer.kv
文件 246 2018-04-20 11:15 demo\kivycatalog\container_kvs\BoxLayoutContainer.kv
文件 635 2018-04-20 11:15 demo\kivycatalog\container_kvs\ButtonContainer.kv
文件 489 2018-04-20 11:15 demo\kivycatalog\container_kvs\CheckBoxContainer.kv
文件 430 2018-04-20 11:15 demo\kivycatalog\container_kvs\FileChooserContainer.kv
文件 296 2018-04-20 11:15 demo\kivycatalog\container_kvs\FloatLayoutContainer.kv
文件 355 2018-04-20 11:15 demo\kivycatalog\container_kvs\GridLayoutContainer.kv
文件 1763 2018-04-20 11:15 demo\kivycatalog\container_kvs\LabelContainer.kv
文件 183 2018-04-20 11:15 demo\kivycatalog\container_kvs\MediaContainer.kv
文件 748 2018-04-20 11:15 demo\kivycatalog\container_kvs\PlaygroundContainer.kv
文件 911 2018-04-20 11:15 demo\kivycatalog\container_kvs\PopupContainer.kv
文件 335 2018-04-20 11:15 demo\kivycatalog\container_kvs\ProgressBarContainer.kv
文件 220 2018-04-20 11:15 demo\kivycatalog\container_kvs\RestContainer.kv
文件 336 2018-04-20 11:15 demo\kivycatalog\container_kvs\ScatterContainer.kv
文件 292 2018-04-20 11:15 demo\kivycatalog\container_kvs\SelectorsContainer.kv
文件 477 2018-04-20 11:15 demo\kivycatalog\container_kvs\StackLayoutContainer.kv
文件 527 2018-04-20 11:15 demo\kivycatalog\container_kvs\TextContainer.kv
文件 4695 2018-04-20 11:15 demo\kivycatalog\kivycatalog.kv
文件 6949 2018-04-20 11:15 demo\kivycatalog\main.py
目录 0 2018-04-20 11:15 demo\multistroke\
............此处省略64个文件信息
- 上一篇:OA人员选择模块Js+JSON
- 下一篇:hzk16+asc16字库
相关资源
- 易语言播放器组件无缝转换(Demo2.e)
- cc2541 BLE DEMO
- stm32f030 IAP Demo(原创)
- 代码客:G-TcpServer(IOCP) 1.0 正式版及
- CListCtrlExDemo.rar
- 易语言-海康威视SDK-DEMO
- ssm框架登录注册demo
- RK3399 DEMO官方原厂 PCB 原理图以及周边
- MQTT推送Demo
- 微信小程序驾照考试题库demo完整
- redisson的demo
- bootstrap demo 源码大全
- springboot+rabbitmq项目demo(亲测可正常运
- 美松打印机SDK MsPrintSDK-Demo-DLL-CShare-
- 基于pytorch的UNet_demo实现及训练自己的
- 百度API车牌识别DEMO.rar
- stm32f105-usart-DMA收发demo
- springboot+webflux+mongodb+freemarker
- springboot整合activiti完整demo
- RFID读写demo
- 以鼠标位置为中心的滑轮放大功能d
- 基于Zxing的二维码条形码扫描和生成
- 手机基站数据Demo
- iOS Swift简单Demo
- 海康摄像头+web3.0开发包SDK的demo
- 微信小程序开发视频+demo
- 海康SDK delphi demo
- SAML协议交互,实现工程Demo有注释
- 增值税发票电子发票导入接口规范官
- 海康监控视频接入视频demo及操作手册
评论
共有 条评论