Thursday, March 25, 2021

Edward Lance Lorilla

Edward Lance Lorilla


【FLUTTER ANDROID STUDIO and IOS】panorama view

Posted: 25 Mar 2021 02:59 AM PDT

import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
import 'splash_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Panorama Demo',
theme: ThemeData.dark(),
home: Splash(),
);
}
}
view raw main.dart hosted with ❤ by GitHub
import 'dart:io';
import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
import 'package:panorama/panorama.dart';
import 'package:image_picker/image_picker.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
File _imageFile;
Size size;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Panorama(
zoom: 1,
animSpeed: 1.0,
child: _imageFile != null ? Image.file(_imageFile) : Image.asset(
'assets/brown_wood.jpg'),
),
floatingActionButton: FloatingActionButton(
mini: true,
onPressed: () async {
final picker = ImagePicker();
final pickedFile = await picker.getImage(source: ImageSource.gallery);
if(pickedFile != null){
_imageFile = File(pickedFile.path);
}
setState(() {});
},
child: Icon(Icons.panorama),
),
);
}
}
import 'dart:async';
import 'package:flutter/material.dart';
import 'main.dart';
import 'panorama_view.dart';
class Splash extends StatefulWidget {
@override
VideoState createState() => VideoState();
}
class VideoState extends State<Splash> with SingleTickerProviderStateMixin {
var _visible = true;
AnimationController animationController;
Animation<double> animation;
startTime() async {
var _duration = new Duration(seconds: 2);
return new Timer(_duration, navigationPage);
}
void navigationPage() {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => MyHomePage(title: 'Panorama Demo')));
}
@override
void initState() {
super.initState();
animationController = new AnimationController(
vsync: this, duration: new Duration(seconds: 1));
animation =
new CurvedAnimation(parent: animationController, curve: Curves.easeOut);
animation.addListener(() => this.setState(() {}));
animationController.forward();
setState(() {
_visible = !_visible;
});
startTime();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
fit: StackFit.expand,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(padding: EdgeInsets.only(bottom: 30.0),
child: new Image.asset('assets/powered_by.png', height: 25.0,
fit: BoxFit.scaleDown,))
],),
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Image.asset(
'assets/devs.jpg',
width: animation.value * 250,
height: animation.value * 250,
),
],
),
],
),
);
}
}

【VISUAL BASIC VB.NET】Background Worker

Posted: 24 Mar 2021 08:12 PM PDT

Imports System.ComponentModel
Public Class Form1
Public Sub New()
MyBase.New
InitializeComponent()
AddHandler Shown, New EventHandler(AddressOf Form1_Shown)
BackgroundWorker1.WorkerReportsProgress = True
AddHandler BackgroundWorker1.DoWork, AddressOf BackgroundWorker1_DoWork
AddHandler BackgroundWorker1.ProgressChanged, AddressOf backgroundWorker1_ProgressChanged
End Sub
Private Sub backgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs)
Label1.Text = CStr(e.ProgressPercentage)
ProgressBar1.Value = e.ProgressPercentage
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For i As Integer = 0 To 100
BackgroundWorker1.ReportProgress(i)
Threading.Thread.Sleep(100)
Next
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Form1_Shown(sender As Object, e As EventArgs)
BackgroundWorker1.RunWorkerAsync()
End Sub
End Class
view raw Form1.vb hosted with ❤ by GitHub

【FLUTTER ANDROID STUDIO and IOS】Shader Mask

Posted: 24 Mar 2021 05:48 PM PDT

import 'package:flutter/cupertino.dart';import 'package:flutter/material.dart';
import 'splash_screen.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark(),
debugShowCheckedModeBanner: false,
home: Splash(),
);
}
}
view raw main.dart hosted with ❤ by GitHub
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
class ShaderDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text("ShaderMask Demo")
),
body: Center(
child: ShaderMask(
shaderCallback: (bounds) {
return LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.black, Colors.red]
).createShader(bounds);
},
blendMode: BlendMode.color,
child: Container(
width: double.infinity,
height: double.infinity,
child: Image.asset("assets/showroom.jpg", fit: BoxFit.cover,),
),
),
),
);
}
}
import 'dart:async';
import 'package:flutter/material.dart';
import 'shader_demo.dart';
class Splash extends StatefulWidget {
@override
VideoState createState() => VideoState();
}
class VideoState extends State<Splash> with SingleTickerProviderStateMixin {
var _visible = true;
AnimationController animationController;
Animation<double> animation;
startTime() async {
var _duration = new Duration(seconds: 2);
return new Timer(_duration, navigationPage);
}
void navigationPage() {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => ShaderDemo()));
}
@override
void initState() {
super.initState();
animationController = new AnimationController(
vsync: this, duration: new Duration(seconds: 1));
animation =
new CurvedAnimation(parent: animationController, curve: Curves.easeOut);
animation.addListener(() => this.setState(() {}));
animationController.forward();
setState(() {
_visible = !_visible;
});
startTime();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
fit: StackFit.expand,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(padding: EdgeInsets.only(bottom: 30.0),
child: new Image.asset('assets/spr_block_0.png', height: 25.0,
fit: BoxFit.scaleDown,))
],),
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Image.asset(
'assets/spr_hole_0.png',
width: animation.value * 250,
height: animation.value * 250,
),
],
),
],
),
);
}
}

【PYTHON OPENCV】K-means clustering algorithm applied to three different 'clusters' of points (k=3)

Posted: 24 Mar 2021 04:58 PM PDT

"""
K-means clustering algorithm applied to three different 'clusters' of points (k=3)
"""
# Import required packages:
import numpy as np
import cv2
from matplotlib import pyplot as plt
# Create data (three different 'clusters' of points (it should be of np.float32 data type):
data = np.float32(np.vstack(
(np.random.randint(0, 40, (50, 2)), np.random.randint(30, 70, (50, 2)), np.random.randint(60, 100, (50, 2)))))
# Define the algorithm termination criteria (the maximum number of iterations and/or the desired accuracy):
# In this case the maximum number of iterations is set to 20 and epsilon = 1.0
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 20, 1.0)
# Apply kmeans algorithm# K = 3, which is the number of clusters to split the set bytearray# attempts = 10, which specifies the number of times the algorithm is executed using different initial labellings (the# algorithm returns the labels that yield the best compactness)
# Flag cv2.KMEANS_RANDOM_CENTERS selects random initial centers in each attempt. You can also use cv2.KMEANS_PP_CENTERS
ret, label, center = cv2.kmeans(data, 3, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
# Now separate the data using label output (stores the cluster indices for every sample)
# Therefore, we split the data to different clusters depending on their labels:
A = data[label.ravel() == 0]
B = data[label.ravel() == 1]
C = data[label.ravel() == 2]
# Create the dimensions of the figure and set title:
fig = plt.figure(figsize=(12, 6))
plt.suptitle("K-means clustering algorithm", fontsize=14, fontweight='bold')
fig.patch.set_facecolor('silver')
# Plot the 'original' data:
ax = plt.subplot(1, 2, 1)
plt.scatter(data[:, 0], data[:, 1], c='c')
plt.title("data")
# Plot the 'clustered' data and the centroids
ax = plt.subplot(1, 2, 2)
plt.scatter(A[:, 0], A[:, 1], c='b')
plt.scatter(B[:, 0], B[:, 1], c='g')
plt.scatter(C[:, 0], C[:, 1], c='r')
plt.scatter(center[:, 0], center[:, 1], s=100, c='m', marker='s')
plt.title("clustered data and centroids (K = 3)")
# Show the Figure:
plt.show()

No comments:

Post a Comment