Skip to content

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TETSUAKI BABA committed Oct 25, 2023
1 parent eddf019 commit 686ee21
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 120 deletions.
8 changes: 4 additions & 4 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function createWindow() {
let { width, height } = active_screen.workAreaSize
const x = active_screen.workArea.x;
const y = active_screen.workArea.y;
// width = 1200;
// height = 800;
//width = 1200;
//height = 800;
//console.log(x, y);
win = new BrowserWindow({
title: "commentable-desktop",
Expand All @@ -41,7 +41,7 @@ function createWindow() {
transparent: true,
frame: false,
resizable: false,
//alwaysOnTop: true,
alwaysOnTop: true,
//focusable: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
Expand Down Expand Up @@ -133,7 +133,7 @@ app.whenReady().then(() => {
customStylesheet: path.join(__dirname, '/css/prompt.css')
})
.then((r) => {
win.setAlwaysOnTop(true, 'floating');
//win.setAlwaysOnTop(true, 'floating');
win.setVisibleOnAllWorkspaces(true, {
visibleOnFullScreen: true
});
Expand Down
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "commentable-desktop",
"version": "1.3.3",
"version": "1.4.0",
"description": "コメンタブルの表示をデスクトップ上に投影するアプリケーション.終了する場合はタスクバーから終了を選択してください.",
"main": "main.js",
"scripts": {
Expand Down
136 changes: 99 additions & 37 deletions electron/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var time_end;
var time_end_hour;
var time_end_minute;
var is_streaming = false;

let max_life = 255;
var timestamp_last_send

var flg_speech;
Expand Down Expand Up @@ -161,7 +161,7 @@ class ProtofessionalEffect {

if (this.is_activating == true &&
(millis() - this.timestamp) < this.effect_duration) {
let alpha = 255 * cos(radians(90 * (millis() - this.timestamp) / this.effect_duration));
let alpha = max_life * cos(radians(90 * (millis() - this.timestamp) / this.effect_duration));
background(0, 0, 0, alpha);
noStroke();
fill(255, 255, 255, alpha);
Expand All @@ -185,6 +185,7 @@ class Comment {
this.size = 72.0;
this.flg_img = false;
this.volume = 0.1;
this.text_direction = 'still';

}
setColor(_color_text, _color_text_stroke) {
Expand Down Expand Up @@ -226,28 +227,101 @@ class Comment {
}
}
update() {
if (this.life > 0) {
this.alpha = this.life;
this.size = abs((height / 20) * sin(0.5 * PI * this.life / 255.0));
this.life = this.life - 1;
if (this.life == 0) {
this.flg_img = false;
this.size = abs((height / 20) * sin(0.5 * PI));

if (this.text_direction == 'still') {
if (this.life > 0) {
this.alpha = this.life;
this.size = abs((height / 20) * sin(0.5 * PI * this.life / max_life));
this.life = this.life - 1;
}
}
else if (this.text_direction == 'left') {
if (this.life > 0) {
textAlign(LEFT, CENTER);
// this.textの横野長さを計算
textSize(this.size);
let text_width = textWidth(this.text);

let start_x = windowWidth;
let end_x = -text_width;

// lifeの割合を計算
let life_ratio = this.life / max_life;

// xの位置を更新
this.x = start_x + (1 - life_ratio) * (end_x - start_x);
this.alpha = 255;
this.life--;
}
}
else if (this.text_direction == "right") {
if (this.life > 0) {
textAlign(LEFT, CENTER);
// this.textの横野長さを計算
textSize(this.size);
let text_width = textWidth(this.text);

let start_x = -text_width;
let end_x = windowWidth;

// lifeの割合を計算
let life_ratio = this.life / max_life;

// xの位置を更新
this.x = start_x + (1 - life_ratio) * (end_x - start_x);
this.alpha = 255;
this.life--;
}
}
else if (this.text_direction == 'up') {
if (this.life > 0) {
textAlign(CENTER, TOP);

// this.textの縦の高さを計算
textSize(this.size);
let text_height = textAscent() + textDescent();

let start_y = windowHeight;
let end_y = -text_height;

// lifeの割合を計算
let life_ratio = this.life / max_life;

// xの位置を更新
this.y = start_y + (1 - life_ratio) * (end_y - start_y);
this.alpha = 255;
this.life--;
}
}
else if (this.text_direction == "down") {
if (this.life > 0) {
textAlign(CENTER, TOP);
// this.textの縦の高さを計算
textSize(this.size);
let text_height = textAscent() + textDescent();

let start_y = -text_height;
let end_y = windowHeight;

// lifeの割合を計算
let life_ratio = this.life / max_life;

// xの位置を更新
this.y = start_y + (1 - life_ratio) * (end_y - start_y);
this.alpha = 255;
this.life--;
}

}
return;
}
draw() {

if (this.flg_img == false) {
textSize(this.size);
strokeWeight(5.0 * this.alpha / 255.0);
stroke(this.color_text_stroke + str(hex(this.alpha, 2)));
fill(this.color_text + str(hex(this.alpha, 2)));
text(this.text, this.x, this.y);
} else {
//imageMode(CENTER);
//image(this.img[0],this.x, this.y, this.img[0].width*this.alpha/255, this.img[0].height*this.alpha/255);
}
textSize(this.size);
strokeWeight(5.0 * this.alpha / 255.0);
stroke(this.color_text_stroke + str(hex(this.alpha, 2)));
fill(this.color_text + str(hex(this.alpha, 2)));
text(this.text, this.x, this.y);
return;
}
}
Expand Down Expand Up @@ -395,6 +469,7 @@ function draw() {
flash.draw();

if (admin_message.show) {
textAlign(CENTER, CENTER);
textSize(height / 20);
let txt = admin_message.text;
let txtWidth = textWidth(txt);
Expand Down Expand Up @@ -463,8 +538,9 @@ function newComment(data) {
protofessional_effect.setVolume(volume);
protofessional_effect.activate();
}

} else if (data.flg_image == false) {
}
// 通常のコメント
else {
let id = -1;
if (data.comment.length <= 0) {
return;
Expand All @@ -477,8 +553,10 @@ function newComment(data) {
}
// パーティクルに空きがあれば
if (id >= 0) {
console.log(data);
comments[id].setLife(255);
comments[id].setText(data.comment);
comments[id].text_direction = data.text_direction;
textSize(abs((height / 20) * sin(0.5 * PI)));
let text_width = textWidth(data.comment);
// console.log(textWidth(data.comment));
Expand Down Expand Up @@ -514,23 +592,7 @@ function newComment(data) {
}

comment_format += "[" + data.my_name + "]" + "\n";
} else { // image reaction
for (var i = 0; i < max_number_of_comment; i++) {
if (comments[i].getLife() == 0) {
id = i;
i = max_number_of_comment;
}
}
if (id >= 0) {
comments[id].setLife(255);
comments[id].setX(random(100, width - 100));
comments[id].setY(random(100, height - 100));
comments[id].useImage(0);
}

}


}

function windowResized() {
Expand Down
Empty file removed public/getOGP.php
Empty file.
Loading

0 comments on commit 686ee21

Please sign in to comment.