comment it

This commit is contained in:
Er2 2022-02-10 20:45:10 +03:00
parent 7018143aaf
commit 5400a0d42d
4 changed files with 48 additions and 11 deletions

View File

@ -1,12 +1,19 @@
package org.er2.fireplace;
import android.service.dreams.DreamService;
import android.widget.TextView;
/* Dream service to show fireplace on device
* instead of just black screen (useful for TVs).
*
* (c) Er2 2022 <er2@dismail.de>
* Zlib License
*/
public class Dream extends DreamService {
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
setInteractive(false);
setFullscreen(true);
setContentView(R.layout.dream);

View File

@ -3,24 +3,34 @@ package org.er2.fireplace;
import java.util.Random;
import java.util.ArrayList;
/* This file is a model and some controller in MVC pattern
*
* (c) Er2 <er2@dismail.de>
* Zlib License
*/
public class Fireplace {
/* Characters and colors to use */
/* (yes I like comments in C style) */
private static String chr = "!\"#$%&*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`~ ";
private static int[] cols = {
/* 0x OPACITY hex
Because Android uses opacity before hex
*/
0xFFfdcf58,
0xFFf27d0c,
0xFFf07f13,
0xFF800909,
};
int fsize;
public int w, h, col;
ArrayList<Integer> fire;
Random rand;
int fsize; /* Font size */
public int w, h, col; /* width, height, columns */
ArrayList<Integer> fire; /* ArrayList is to allow resize */
Random rand; /* Some random :) */
int ind;
int cid;
int hid;
int ind, cid, hid; /* column INDex, Color InDex, cHaracter InDex */
/* Pls no comments */
public Fireplace() {
fire = new ArrayList<Integer>();
rand = new Random();

View File

@ -9,10 +9,17 @@ import android.util.AttributeSet;
import android.util.Log;
/* Fireplace frontend
* TODO: Optimize this..
*
* (c) Er2 2022 <er2@dismail.de>
* Zlib License
*/
public class FireplaceView extends View {
Paint paint;
Fireplace fpl;
Bitmap bmp;
Paint paint; /* Android paint */
Fireplace fpl; /* Our backend */
Bitmap bmp; /* Screenshot of previous frame (thing to be optimized) */
public FireplaceView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
@ -22,9 +29,14 @@ public class FireplaceView extends View {
}
public void drawFire(Canvas canv) {
/* draw previous frame and apply transparency
thing to be optimized
*/
canv.drawBitmap(bmp, 0, 0, null);
paint.setColor(0x1E000000);
canv.drawRect(0, 0, getWidth(), getHeight(), paint);
/* going through columns */
for(int i = 0; i < fpl.col; i++) {
fpl.next();
paint.setColor(fpl.getCol());
@ -39,6 +51,7 @@ public class FireplaceView extends View {
@Override
public void onDraw(Canvas c) {
/* TODO: To be optimized */
Bitmap bip = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas canv = new Canvas(bip);
drawFire(canv);
@ -49,6 +62,7 @@ public class FireplaceView extends View {
@Override
protected void onSizeChanged(int w, int h, int ow, int oh) {
/* Set size directly */
fpl.setSize(w, h);
}
}

View File

@ -3,6 +3,12 @@ package org.er2.fireplace;
import android.app.Activity;
import android.os.Bundle;
/* Typical main activity file
*
* (c) Er2 2022 <er2@dismail.de>
* Zlib License
*/
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {