资源简介
绘制魔法鱼儿
鼠标按哪,鱼儿游哪

代码片段和文件信息
#include “magic_fish.h“
#include
#include
#include
MagicFish::MagicFish(QWidget *parent)
: QWidget(parent)
fish_r(30)
fin_length(30 * 1.3)
body_height(30 * 3.2)
head_alpha(200)
body_alpha(225)
fin_alpha(120)
main_angle(0.0)
current_value(0)
speed(30)
start_fin(false)
paint_point(false)
wave(1.0)
{
this->timer = new QTimer(this);
this->timer->setInterval(100);
connect(timer &QTimer::timeout this &MagicFish::updateValue);
this->timer->start();
this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::framelessWindowHint);
}
void MagicFish::updateValue()
{
this->current_value = (this->current_value + this->speed) % 54000;
this->update();
}
void MagicFish::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QPointF middle_pos = QPointF(this->width() / 2 this->height() / 2);
this->head_pos = this->calcPoint(middle_pos this->body_height / 2.0 this->main_angle);
this->paintMyPoint(painter this->head_pos);
this->paintMyPoint(painter middle_pos);
painter.setPen(Qt::NoPen);
painter.setBrush(QBrush(QColor(20 203 232 50)));
painter.setBrush(QBrush(QColor(244 92 71 this->head_alpha)));
painter.drawEllipse(this->head_pos this->fish_r this->fish_r);
float angle = this->main_angle + qSin(qDegreesToRadians(this->current_value * 1.2 * wave)) * 2;
QPointF end_pos = this->calcPoint(this->head_pos this->body_height angle - 180);
QPointF pos1 = calcPoint(this->head_pos this->fish_r angle - 80);
QPointF pos2 = calcPoint(end_pos this->fish_r * 0.7 angle - 90);
QPointF pos3 = calcPoint(end_pos this->fish_r * 0.7 angle + 90);
QPointF pos4 = calcPoint(this->head_pos this->fish_r angle + 80);
QPointF central_left = this->calcPoint(this->head_pos this->body_height * 0.56 angle - 130);
QPointF central_right = this->calcPoint(this->head_pos this->body_height * 0.56 angle + 130);
QPainterPath path;
path.moveTo(pos1);
path.quadTo(central_left pos2);
path.lineTo(pos3);
path.quadTo(central_right pos4);
path.lineTo(pos1);
painter.setBrush(QBrush(QColor(244 92 71 this->body_alpha)));
painter.drawPath(path);
this->paintMyBody(painter end_pos this->fish_r * 0.7 0.6 angle);
QPointF left_fin_pos = this->calcPoint(head_pos this->fish_r * 0.9 angle + 110);
this->paintMyFishFins(painter left_fin_pos true angle);
QPointF right_fin_pos = this->calcPoint(head_pos this->fish_r * 0.9 angle - 110);
this->paintMyFishFins(painter right_fin_pos false angle);
QWidget::paintEvent(e);
}
void MagicFish::resizeEvent(QResizeEvent *e)
{
QWidget::resizeEvent(e);
this->fish_r = qMin(this->width() this->height()) / 10.0;
this->fin_length = this->fish_r
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-12-28 00:26 magic-fish\
文件 1109 2017-12-19 19:03 magic-fish\magic-fish.pro
文件 23917 2017-12-28 00:26 magic-fish\magic-fish.pro.user
文件 23493 2017-12-18 15:25 magic-fish\magic-fish.pro.user.43ca8d8
文件 8434 2017-12-21 11:29 magic-fish\magic_fish.cpp
文件 1493 2017-12-21 11:25 magic-fish\magic_fish.h
文件 4666 2017-12-21 11:33 magic-fish\magic_pool.cpp
文件 926 2017-12-21 11:21 magic-fish\magic_pool.h
文件 183 2017-12-18 15:25 magic-fish\main.cpp
文件 333 2017-12-21 11:20 magic-fish\mainwindow.cpp
文件 313 2017-12-21 11:21 magic-fish\mainwindow.h
文件 571 2017-12-18 16:05 magic-fish\mainwindow.ui
相关资源
- Qt界面外观
- [嵌入式Linux项目实战开发]基于QT4.7.
- Qt GUI 界面通用系统模板 源码
- 网上的一款QT界面设计的电子地图
- 二维码解析
- linux下关于Qt界面的摄像头v4l2操作源码
- 360UI完美界面
- 净化设备管理
- 基于qt界面的语音交互软件
- 综合组件的界面
- opencv打开图片并显示在Qt界面上
- Qt360 界面
- 动态绘制曲线
- QtitanRibbon3.zip
- VS+QT环境下读取excel文件到QT界面,并
- 基于嵌入式QT界面GPS定位系统
- [嵌入式Linux项目实战开发]基于QT4.7.
- 物联网 智能家居 Qt界面
- 将QT界面做成dll在qt其他程序中调用
-
将xm
l内容显示Qt界面 - DS18B20测温及QT界面实现
- qt界面跳转切换
- 基于v4l的视频采集显示程序。外加Q
- QT计算器界面和计算器功能实现
- qt界面连接wifi
- myseria串口
- 基于Qt界面显示的温湿度检测
- Qt界面多线程opencv调用摄像头
- 智慧大棚QT界面设计
- Qt高仿网易云音乐界面源码
评论
共有 条评论