Answer the question
In order to leave comments, you need to log in
How to make a semi-transparent mask from a raster layer?
Prepared as a mask a b/w layer with white and black areas and with the necessary transitional gray gradations. How to make a (semi-transparent) mask out of this existing this layer?
Everywhere they teach how to heat up a mask with a brush, vector, filters, etc. But I have a layer already prepared for the mask (and not at all easy to draw).
I feel that it is simple, but I did not find the answer. Thanks in advance.
Answer the question
In order to leave comments, you need to log in
In the forehead: copy the contents of the layer, create an alpha channel and paste the content into this layer. It is possible to make an invert, depending on what black and white means in the mask.
Not in the forehead: assign a layer as a mask. I don't remember how. In the list of layers, either drag the layer with alt, or something like that ... but there is a very simple and elegant solution that I had no reason to use and I forgot it ...
You either need to make $pdo global or return it (better).
<?php
function connectDB() {
try {
$pdo = new PDO('mysql:host=localhost;dbname=#', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $pdo;
} catch (PDOException $e) {
exit($e->getMessage());
}
}
function getA() {
$pdo = connectDB();
$select = $pdo->query("SELECT * FROM # ORDER BY id DESC", PDO::FETCH_ASSOC);
$result = $select->fetchAll();
var_dump($result);
}
getA();
?>
$pdo
you have a global variable. In this case, when using it inside a function, you need to use the keyword global
.
function connectDB() {
global $pdo;
$pdo = new PDO('...');
}
function getA() {
global $pdo;
connectDB();
$pdo->query('...');
}
Get to grips with the very basics of the language: scopes and how variables work.
You don't have a variable defined in the method getA()
that should contain the PDO object.
// Вот здесь ошибка:
$select = $pdo->query("SELECT * FROM # ORDER BY id DESC", PDO::FETCH_ASSOC);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question