From 2878f1e34c2c2e19d5b7f6fd368dbf9ec0c6277f Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 15 Dec 2025 00:36:33 +0100 Subject: =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=83=D1=8E=20=D0=B3=D0=BB=D0=B0=D0=B2=D1=83?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BD=D0=B8=D0=BC=D0=B0=D1=82=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D0=BC=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2/4_fading_in/core/build.gradle" | 5 ++ .../core/src/net/caraus/fadein/FadeIn.java" | 84 ++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 "\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/build.gradle" create mode 100644 "\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/src/net/caraus/fadein/FadeIn.java" (limited to 'Занимательное программирование/2/4_fading_in/core') diff --git "a/\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/build.gradle" "b/\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/build.gradle" new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ "b/\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/build.gradle" @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git "a/\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/src/net/caraus/fadein/FadeIn.java" "b/\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/src/net/caraus/fadein/FadeIn.java" new file mode 100644 index 0000000..bd9b6e1 --- /dev/null +++ "b/\320\227\320\260\320\275\320\270\320\274\320\260\321\202\320\265\320\273\321\214\320\275\320\276\320\265 \320\277\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265/2/4_fading_in/core/src/net/caraus/fadein/FadeIn.java" @@ -0,0 +1,84 @@ +package net.caraus.fadein; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.Pixmap.Format; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.ScreenUtils; + +public class FadeIn extends ApplicationAdapter { + SpriteBatch batch; + + Texture etalonTexture; + Pixmap etalon; + + Pixmap pixmap; + Texture img; + int[][][] buffer; + + @Override + public void create () { + batch = new SpriteBatch(); + + FileHandle fileHandle = Gdx.files.internal("badlogic.bmp"); + etalon = new Pixmap(fileHandle); + etalonTexture = new Texture(etalon); + + pixmap = new Pixmap(etalon.getWidth(), etalon.getHeight(), Format.RGB888); + buffer = new int[etalon.getWidth()][etalon.getHeight()][3]; + for (int i = 0; i < pixmap.getWidth(); ++i) { + for (int j = 0; j < pixmap.getHeight(); ++j) { + buffer[i][j][0] = 0xff; + buffer[i][j][1] = 0xff; + buffer[i][j][2] = 0xff; + } + } + img = new Texture(pixmap); + } + + @Override + public void render () { + ScreenUtils.clear(1, 0, 0, 1); + + for (int i = 0; i < pixmap.getWidth(); ++i) { + for (int j = 0; j < pixmap.getHeight(); ++j) { + int etalonPixel = etalon.getPixel(i, j); + + int etalonRed = (etalonPixel >> 24) & 0xff; + int etalonGreen = (etalonPixel >> 16) & 0xff; + int etalonBlue = (etalonPixel >> 8) & 0xff; + + if (etalonRed < buffer[i][j][0]) { + --buffer[i][j][0]; + } + if (etalonGreen < buffer[i][j][1]) { + --buffer[i][j][1]; + } + if (etalonBlue < buffer[i][j][2]) { + --buffer[i][j][2]; + } + pixmap.setColor((buffer[i][j][0] << 24) | (buffer[i][j][1] << 16) | (buffer[i][j][2] << 8) | 0xff); + pixmap.drawPixel(i, j); + } + } + img.draw(pixmap, 0, 0); + + batch.begin(); + batch.draw(etalonTexture, 0, 0); + batch.draw(img, etalon.getWidth() + 15, 0); + batch.end(); + } + + @Override + public void dispose () { + batch.dispose(); + etalonTexture.dispose(); + etalon.dispose(); + + img.dispose(); + pixmap.dispose(); + } +} -- cgit v1.2.3