我是Android编程的新手,最近我尝试编写一个简单的应用程序,仅用于练习!在这一个中,我想在用户的点击上为图像着色,但我不知道如何启动它.我已经阅读了不同的主题,说使用"Flood Fill"算法.我在网上发现了它,但我不知道如何将它放入我的简单应用程序中.
我发现的代码:
private void FloodFill(Bitmap bmp, Point pt, int targetColor, int replacementColor)
{
Queue<Point> q = new LinkedList<Point>();
q.add(pt);
while (q.size() > 0) {
Point n = q.poll();
if (bmp.getPixel(n.x, n.y) != targetColor)
continue;
Point w = n, e = new Point(n.x + 1, n.y);
while ((w.x > 0) && (bmp.getPixel(w.x, w.y) == targetColor)) {
bmp.setPixel(w.x, w.y, replacementColor);
if ((w.y > 0) && (bmp.getPixel(w.x, w.y - 1) == targetColor))
q.add(new Point(w.x, w.y - 1));
if ((w.y < bmp.getHeight() - …Run Code Online (Sandbox Code Playgroud) 一旦我的Firebase应用程序上的云功能被调用,我想对我的数据库执行查询.
假设我在数据库上有一定的触发器,请考虑Firebase上的入门指南中提供的示例.
// Listens for new messages added to /messages/:pushId/original and creates an
// uppercase version of the message to /messages/:pushId/uppercase
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original')
.onWrite(event => {
// Grab the current value of what was written to the Realtime Database.
const original = event.data.val();
console.log('Uppercasing', event.params.pushId, original);
const uppercase = original.toUpperCase();
// I'D LIKE TO PERFORM A QUERY HERE, JUST A SIMPLE RETRIEVE BASED ON THE ID PROVIDED
// You must return a Promise when performing asynchronous tasks …Run Code Online (Sandbox Code Playgroud) javascript firebase firebase-realtime-database google-cloud-functions
我正在做一个我的小项目,以了解有关Angular的更多信息,但是我真的无法弄清楚如何实现多层路由。
我已经阅读了有关路由器组件新版本的文档,以及关于StackOverlfow的其他一些主题(第一,第二,第三),但是找不到解决方案。
让我们考虑以下应用程序结构,而不考虑Test和Test2块。
让我们考虑一下我的应用程序的组件,如下所示:
主要
import { bootstrap } from '@angular/platform-browser-dynamic';
import { MyAppComponent } from './my-app/my-app.component';
import { APP_ROUTER_PROVIDERS } from './my-app/my-app.routes';
bootstrap(MyAppComponent, [ APP_ROUTER_PROVIDERS ])
.catch(err => console.error(err));
Run Code Online (Sandbox Code Playgroud)
my-app.component.ts
import { Component } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';
@Component({
selector: 'my-app',
template: '<router-outlet></router-outlet>',
directives: [ROUTER_DIRECTIVES],
})
export class MyAppComponent { }
Run Code Online (Sandbox Code Playgroud)
my-app.routes.ts
import { provideRouter, RouterConfig } from '@angular/router';
import { …Run Code Online (Sandbox Code Playgroud)