recursal/Fanatic-Fandom huggingface dataset:
Associa imagem

Após abrir e carregar uma imagem na biblioteca usando *AbreImagem()*,é possível renderizar esta imagem em uma geometria qualquer, com **exceção** do Polígono, Reta e Ponto.

Preferivelmente, para que a imagem não sofra nenhum corte ou deformação, as geometrias ideais para renderizar uma imagem costumam ser **Quadrados** ou **Retângulos**.

Ao colocar a imagem na geometria, cada pixel de cor da imagem é multiplicado pela cor da geometria para resultar na nova cor daquele pixel. Ou seja:

Seja

c
o
r

{\displaystyle cor}

 uma matriz definida por

c
o
# r

(

r

g

b

)

{\displaystyle
cor = \begin{pmatrix}
r\\
g\\
b
\end{pmatrix}
}

Onde

r

{\displaystyle r}

 indica quantidade de vermelho que,

g

{\displaystyle g}

 indica a quantidade de verde e

b

{\displaystyle b}

 a quantidade de azul que o pixel contém. Os valores de

r

{\displaystyle r}

,

g

{\displaystyle g}

 e

b

{\displaystyle b}

 variam de 0 à 1, onde 0 significa ausência e 1 significa presença.

Para o cálculo da nova cor, é realizado o seguinte processo:

```
Deforma imagem de acordo com a geometria

Para cada pixel da geometria
	pixel novo = pixel da cor original

 ×

 {\displaystyle \times}

 pixel correspondente da cor da imagem
Fim-para

```

Portanto, para que a imagem não tenha nenhuma mudança inesperada de cor, é preferível que a cor da geometria seja **branco**.

A transparência da imagem é ativada se a imagem possue esse canal.

```
void AssociaImagem(int textura)

```

Associa uma imagem com a última geometria criada.

#### Parâmetros

*textura*: índice de retorno da função *AbreImagem()*.

#### Exemplo:

```
#include <playCB/playcb.h>

int main(){
    int img;
    Ponto p;

    AbreJanela(400, 400, "Marvin");
    PintarFundo(0, 0, 64);

    img = AbreImagem("./marvin.png");

    p.x = -100;
    p.y = -100;
    CriaRetangulo(200, 20, p);
    Pintar(94, 47, 0);

    p.x = -40;
    p.y = -100;
    CriaRetangulo(40, 80, p);
    Pintar(255, 255, 255);
    AssociaImagem(img);

    img = AbreImagem("./terra.png");
    p.x = 40;
    p.y = 60;
    CriaCirculo(20, p);
    Pintar(255, 255, 255);
    AssociaImagem(img);

    img = AbreImagem("./estrelas.png");

    p.x = -40;
    p.y = 20;
    CriaTriangulo(50, 80, p);
    Pintar(255, 0, 0);
    AssociaImagem(img);

    p.x = -90;
    p.y = -40;
    CriaQuadrado(70, p);
    Pintar(255, 255, 255);
    AssociaImagem(img);

    Desenha();

    return 0;
}

```

*Revisado dia 18/08/2015*
Complex Unfoldments

On his 18th birthday, the prince inherited the kingdom.

Until this day, he had not taken any interest in what was going on, or what was needed to keep everything running. To his horror, he found mismanagement everywhere; corruption, crazy systems, advisers who clearly didn't know what they were doing and after his first day, totally overwhelmed with the enormity of the task, he sat down in the garden, in the privacy of the center of a maze and sighed. He sighed deeply and on his in breath, he breathed in the scent of night flowers. And there, something happened in his mind; he saw all the problems like threads in a tapestry unraveling at first, then re-assembling to make a newer, better, bigger picture.
Summer Rain

The land was dusty, dry and tired; parched ground, yellowed, flattened grass, the leaves of the trees were hanging tiredly, the sky was dark and the atmosphere hot and oppressive.

And then they came, the summer rains, and when they had passed, all was fresh, bright and new, all was green once more and sparkling in the sunshine.
Spirit Cleansing

Once there was a wise traveller who came across a waterfall deep in the forest, and there, he saw a man standing under the waterfall, scrubbing and scrubbing frantically at his skin, even though it was nearly red raw already.

The traveller called out to the man, "What are you doing?"

The man explained that he had been in a terrible place where terrible things had happened to him, and he was trying to wash all that away so he could be clean and at peace again.

The traveller told the man that water cannot accomplish this alone but offered him a new suggestion.

"There is a magical plant that grows right there, on the banks of the river. You scrub yourself with that, and you will find your spirit will begin to shine again, and you'll get clean beyond your skin."
Laughter

There once was a young man who disliked himself terribly. He had a terrible temper, no friends, and even his long suffering parents and siblings only put up with him because they had to. He didn't want to be like that, but didn't know what to do about it, and finally one day, he ran away into the forest and this time, didn't slow down or turn around but kept running and running and running.

So it was that he eventually stumbled on a camp of fairy people who lived in the forest. They had never seen a person before and were much delighted with him; they played with is hair and laughed and danced, as is their nature; and in his honour, they threw a big festival. The young man was suspicious and afraid at first for he had never known anyone to really want him at all, but he soon realised that the fairy people were truthful through and through, and so he just gave up and joined in with their festival, eating their strange flower food and drinking their strange flower wine.

When he woke up in the morning, the fairy people had gone; but when he returned to the village, he found that people were smiling at him, and treating him as though he was all different, as though he was all new.
The Fire

It is winter and a family has been fighting from the moment they got up. Everyone is fed up with each other so the brother has gone off to see his friends, the daughter has gone off to see hers, the father is in the barn, the mother in the attic, the grandmother in her bedroom, the uncle is in the stables.

As night falls and temperatures plummet, one by one they grudgingly return home, driven by necessity and hunger - but there is no wood chopped, no fire in the hearth and nothing has been cooked to eat.

They stand looking at each other for a while, and finally, they sigh - they exchange a few embarrassed glances, and even fewer words, but everyone starts to work together, and not much later, they are all in front of a cosy fire, bellies full, and all's well with the world again.
The Path

A young woman in difficult circumstances has escaped her home life for a time and is walking towards the woods near her home. Many times she has walked here, but it is today that a ray of light reveals a forest path she has never noticed before.

She forgets about her troubles and is immediately intrigued; her footsteps lighten as she swiftly steps upon the path. The forest is light, bright and breezy around her, and it is soothing and refreshing both. Where will this path lead her?

What will she find?

What will those treasures be?

Wild flowers, berries ripe and juicy, or perhaps a well of clearest, purest healing water might await.
The White Angel

A young woman on her wedding day sits in all her finery in the garden behind the church where she is to be wed, and cries bitterly.

She loves her husband to be most dearly; indeed, she loves him so much that she feels she isn't good enough for him, that he would be much better off with another, one who is much smarter, richer and more beautiful than she could ever be. She is about to get up and run away when her young lover enters the garden. It is against the custom but he felt in his heart that something wasn't right.

He runs to her, kneels before her and takes her hands in his. She cannot speak for the pain in her heart, and he doesn't say a word - he just sends her his love and absolute devotion best he can.

As she looks into his eyes, she sees herself reflected for the first time - not as she saw herself in mirrors, but on this day, she looks and sees the angel.
Giving & Receiving

There once was a woman who believed that to give is good, and to receive is bad. So she gave and gave of her belongings, until there was nothing left to give. She gave and gave of her time, until it was all taken up with giving.

She gave and gave to her family and friends, until she was so starved and exhausted, that she fell down and died; and thus, was of no use to anyone any longer, and least of all, to herself.
The Child

A young and sickly prince stands by the side of an ocean shore. His young shoulders are born down with the responsibilities of his birth; his face is pale and his lips are thin and bloodless.

"What good is this ocean?" he cries and shakes a fist into the wind, "It brings me no pleasure, as nothing does these days!" A dolphin swims close to shore in the shallows, flaps his tail hard in water and drenches the prince with a shower of spray in an instant. "How dare you!" shouts the prince, wet and breathless, "I shall have you arrested, all of your kind!"

The dolphin splashes him again before the final words are spoken, and then again, and finally the prince, his finery completely soaked and dripping head to foot, has got to start to laugh - and he runs to the water, throws himself into the ocean and becomes a child again.
Holiday

A lady reclines on the terrace of a beautiful villa that overlooks the sea. Behind the house, stately trees reach up into the clear blue sky. It is a soft, sunny day with a light breeze, bringing with it the fragrance of the land and the lady stretches and smiles, blissfully happy, perfectly at ease.
The Renewer

After a very long march, a group of people who are travelling with their animals have finally made it across the deserts and a high mountain. They are wearily stumbling down the hill into the valley when they find the most beautiful meadow - here, all is green!

All is lush and full of life, vibrant, fresh, moist and there are so many different plants, all of them life giving in the extreme.

The people and the animals as one let themselves fall and roll in the green, laughing with delight and joy of deliverance.
Soul Love

A young woman stands at the grave of her mother and cries. She feels lost and so lonely. Her brother comes to her, stands for a moment by her side, then he gently places his arm about her shoulder, turns her away, turns her towards a beautiful garden, where he takes her to a bench.

They both sit down, hold hands, and share the many wonderful memories they both have been blessed with.

The sister stops crying and starts to laugh at the remembrance of a happy time; she raises her head, her eyes and says, "When I was crying, I was all alone. Now that I am happy, I can feel our mother everywhere - in the sunshine, in the flowers, on the breeze."
The Bright Light

A young artist walks through the town. He is beautiful. He is rich. He is intelligent. He is creative. And yet around him there seems to be no joy; he seems cloaked in swirling shadows, clouds that never let the sunshine in and endlessly rain upon his soul.

A wise magician sees him, takes pity upon him, steps into his path and hands him a small orb of pure, clear glass.

The young man takes it, surprised, holds it to his heart - and then a flash of brightest light explodes and in an instant, the dark clouds have gone; the young artist takes a deep breath, a beautiful sunrise smile comes to his face - he bows his head and joyously, goes on his way.
Always Summer

A woman goes to market for the first time since her husband died after a long illness. She is dressed in black and feels as though she has lived a thousand life times.

It is high summer and as she walks, she gets too hot and at first, drops her thick black woollen scarf down to her shoulders; but it is such a beautiful day, and such a long walk along the country road where everything is bursting with life now and a riot of flowers and weeds stretch and reach beneath the young summer sun, eventually she has to take the heavy cloak off altogether and carries it over her arm instead.

A large cart filled with many workmen passes her on the road; they whistle, laugh and call. For a moment, she looks around to find who might be the target of their sport, and then she realises - they mean her!
Circle Of Safety

A group of travellers have made camp for the night in unknown lands; they light a fire and go about getting everything prepared for food and sleep. Amongst them is a young boy who doesn't like to be told what to do; he thinks they could have travelled much further and is frustrated with their slow progress.

Angrily, he declares that he will strike out on his own and get to the promised land far ahead of his family - armed with nothing but a stick he heads out into the darkening lands.

But away from the fire's shine, and all the voices and the noises from the camp, he can hear all sorts of rustlings in the bushes; can't see his way, can't be sure if that's a monster or a tree - he stops, he reconsiders, and not much later we can see him breaking bread and eating stew, safe between his mother and his father by the fire.
Precision

Once, there was a great artist who lived in a tiny attic room which was strewn with filth. He was sick, had no money at all, and had managed to alienate all customers, well wishers and agents along the way. He was so upset and unhappy with his life that one day in a fit of rage, he threw all his paintings out of the window. In the street, a young woman was nearly hit by a flying painting. She went to see where it had come from and went into the house, met the artist, fell in love with him and set about making him sort out his life. She was an accountant by trade, didn't have an artistic bone in her body, and often over the many happy years to follow, as they watched their children play in the beautiful gardens of their stately home, and the artist was respected and admired by everyone, they would talk of how they were a match made in heaven.
Cathedral Forests

A young prince, whilst hunting, meets a young girl in the forest. She is the most wonderful, beautiful and innocent woman he has ever known and he falls in love with her in an instant, vows to make her his queen so he should always be advised of beauty and truth for his people.

He takes her to his castle and preparations for the wedding are made; all the complex rituals of court, dress and fashion are thrown upon the girl. Because of her love for the prince, she tries to cope with it all but as they walk into the huge cathedral, stuffed full of all the dignitaries of the land and fanfares start to blare, she freezes and starts to cry. The prince takes one look, sweeps her up in his arms and carries her away, back to the forest where first they met.

Beneath the ancient columns of the trees, in the silence of the forest, he puts her down and says, "We shall speak our wedding vows in the holiest place of them all."
Sanctuary

A group of soldiers have become lost in a forest following a great battle. They are afraid and desperate and night is drawing in.
They fight their way through the undergrowth and all of a sudden, they come across a clearing - hesitantly they enter, but even as they do they know they have found a holy place.

All is still here; there are sweet, soft plants inviting them to rest, to sleep and dream here, and they know they will not just be safe this night, but they will be healed when they awake in the morning.
Coloured Lights

A young woman is sitting tiredly, after another hard day's work, as the evening falls. She sighs and as she does, she notices something. She looks up, looks ahead - what is this?
Coloured lights that seem to dance in the distance?

All tiredness forgotten, instantly fascinated, she rises to her feet, and she can't help herself. She steps out into the evening, drawn forward by the coloured lights.

Soon, she also hears the sounds of a festival.

What will she find ...?
The Ray Of Sunshine

The long winter is finally over and the first real day of spring has arrived. Young, fresh bright green grass is covering the hillsides; the sky is a delightful powder blue and there isn't a cloud in the sky. Two grandparents walk slowly on the road; but their little granddaughter, dressed in a bright lemon yellow dress, is dancing and spinning on the green, green grass.

She is the joy of spring, she is their ray of sunshine.
Far Futures

An adventurer in a far away land of mists and trees and endless hills and rivers has lost his way.

He has come far but his resources are low and he has no idea how he came to be where he finds himself, nor where he should go next or what to do. He climbs a hill but all is grey in all directions; he can't even tell where the land ends or the sky begins. But then, a wind springs up from nowhere - a powerful rushing wind high above.

Not soon after, the land becomes revealed to him, and he can see for miles and miles - all the way to the mountains on one side, and the shores of the ocean on the other.
One Of A Kind

A family is arguing about the latest grandchild - she is the only daughter of the youngest son and his wife, and the combined families of mothers, fathers, aunts, brothers, cousins and nephews are arguing whether she is like her mother, or like her father.

"She has her mother's hair!" one faction will say. "She has her father's eyes!" the other faction will insist, and so it went with every little thing she did, and thought, and thought to do as well.

This went on all through her childhood, until, during a gathering of all of the relatives for her 14th birthday, the girl finally stood up and announced that she wasn't like anyone else at all, that she was no-one but herself, simply one of a kind.
A Friend In Need

A man comes home, broken from a long war. He is full of pain and hurt, and his wife and children cannot reach him; his mother and father cannot touch him. He sends everyone away and hides himself in a cottage in the woods where he lives alone and sees neither sunrise nor sunset, not the splendour of the old trees or the sparkling light on the lake, nor any of the many wondrous things and beings that surround him. His best friend bids farewell to his loved ones and goes to live with him. The man screams abuse and tries to make him go away, but the friend stays.

And finally, one night, the man breaks down and cries and tells his friend what really happened. The next day they return to their loved ones, and life begins again.
The Confessor

On a park bench in the autumn sits a woman with her gloved hands pressed against her face, her head hanging and her shoulders are shaking - she is clearly upset. A passing older gentleman comes and sits quietly by her side.

After a while, she peeks at him from behind her gloves and sees that he is kind and means her well. His presence is soothing. He doesn't say much at all, but the woman finds she pours out all her worldly troubles to the stranger. It is as though he takes them all, enfolds them into himself and there comes a time when the woman takes a deep sigh of relief - her burdens have been taken from her. She wants to start to thank the man, but he just smiles, touches her briefly on the shoulder, and walks away, through the autumn leaves.
Good Vibrations

A tired traveller sits by the side of the road, exhausted after the journey of the day, that was just one day on what seems an everlasting journey.

They have a small fire they are tending with what strength they have left. From the darkness, there steps a beautiful angel, radiant and bright.

It goes to the traveller and without a word being spoken, stands behind him and enfolds him with their soothing wings; and as the traveller is enfolded in radiance, they rise in spirit, sigh with relief and then with pleasure, and raise their eyes to the sky where the first stars are blessings of angelic light.
The Bridge

Once there was a special young woman who could see the angels. On this day, she felt a call and visited the prison in her town, where she asked to see a man who was going to be executed the next morning for many terrible and vile deeds. The prison wardens didn't argue; they showed her to the cell where the prisoner was lying, sick from an injury he had sustained in his capture. She entered and saw that the bad man surrounded by many, many angels who were trying to reach out to him but could not touch him; he was all closed off and on top of that, surrounded by swirling darkness from his bitter life.

The young woman sat down beside him and took his hand. The other hand, she held out to the angels. One stepped forward, the man's most special guardian, and they took her hand. Thus she became the bridge; and knowing, healing and forgiveness flowed into the man, who cried and in the night, died of his injuries.
The Enchantment

There once was a woman who was driven to perfection in all things. She insisted that absolutely everything had to be done just so, every little item, every little detail, all the time and everywhere. She drove her husband and her children crazy, nobody liked her and she had no friends at all because she always criticised everything and everyone, and most of all, herself.

Eventually, her husband couldn't stand it any more. He went to see a witch and asked for spell to make her stop and consider what she was doing with her life. The witch gave him a magic potion but warned him it would last only for a single day and night; but it might do the trick. The magic potion was an enchantment that took all judgements away, and for a single day and a single night, the woman lived in pleasure and excitement - about how amazing her children were, how wondrously blessed she was with material goods and her own good body and mind, and in the night, the blessing of a man who truly loved her and could make her happy in so many different ways.

In the morning, the enchantment was gone but the memories remained - and the woman had learned her lesson and even though it was sometimes difficult to stop the judging, she never went back to her previous ways.
Tall & Strong

There once was a young lady who was always feeble and frail; super sensitive to every little hush of wind or drop of rain; constantly fainting because it was all too much on every level, or so she thought.

One day, she had taken a journey on a coach to visit her long suffering physician. On the coach were also a number of young orphaned children who were to be delivered to a nunnery in the big town where the young lady was headed. Halfway on the journey, the coachman had a heart attack and died, leaving his hapless occupants all alone in the middle of a scary forest.

No-one was around to come to their rescue; and the young woman was about to go into her usual fainting fit when she found herself surrounded by the orphans, who were no higher than her waist; one tugged on her skirts and asked, "Are we all going to die now?"

And that day, the following night and the next day, the young woman learned a lot about herself, about her strength and her capacity to not just save herself, but others, too.
Satisfaction

An old married couple's cart has broken down on their way home from the market town, in the middle of a stretch of old forest that was still left standing from long times ago. They have argued all day, as they always argue all day, and they are thoroughly tired of each other's company.

There is nothing that can be done as night has fallen, and so reluctantly they decide to camp in the woods for the night. They are still arguing about whose fault it all was, complaining and accusing each other as they look around for a suitable spot to put a blanket down and go to sleep.

They stumble down an embankment in the dark and find themselves in a strange grove, where wondrous night flowers are blooming. Their scent is strong, mysterious and the couple stops fighting; quietly they make their camp.

Later, when the moon is bright above, they look at each other with new eyes, and in the morning, they stand by the road, waiting for assistance, and they are smiling, holding hands.
The Time Traveller

A woman who had a very difficult life is in turmoil. She doesn't understand why things happened to her in the past, can't make sense of the present and there seems to be no future. In desperation, she visits a wise woman who lives by herself in the woods. The wise woman gives her a potion that calms her and makes her very sleepy. The confused woman falls asleep on a bed of soft autumn leaves. She dreams that she is walking along a corridor with many open doors on either side, and each leads into a room that shows her a scene from her past. Each one is fascinating, but the woman knows she must not stop and become enmeshed with any single scene; she must walk on. So she walks the path of her life, noting everything along the way, and then she comes to the doorway that shows her sleeping in the wise woman's house in the woods. Beyond that, there are many more doors but they are still closed; and far away, at the very end of the corridor, there is a bright light that is beautiful, and beckoning. The woman smiles and steps into the room of now, and awakens, much relieved and much refreshed.
Flower Of Youth

A man's wife of many years has died. He is heart broken and distraught and still, he has to deal with the particulars of her burial and the funeral details.

When the undertaker asks him what kind of flowers he would like to be on the coffin, he remembers a special kind - once, as a very young man, he had stolen these flowers from the garden of a rich man, made them into a bouquet and given them to a young girl who he hoped would be his wife.
Loving Life

The sky is brilliant blue, the sun shines purest, brightest gold; the land is richest emerald green, and on this perfect day, there is a young man and a young woman, absolutely in love, and they stand before a palace build in the most beautiful proportions, marble white and precious, new and ready to receive them both - all has been made ready for this couple on their wedding day.

There are fruits and flowers, finest wines and baths filled with the most exquisite sparkling waters, sheets of silk and perfect delicacies awaiting them - but they have eyes for one another only.

Deep in love, they smile at each other; he picks her up in his strong arms, and carries her inside.
Luxury

There once was a woman who was full of good deeds and good works. Every single moment she had, she would spend on something meaningful and important; she was a member of countless charities, committees and pressure groups "to make a better world for our children and our children's children ..." At home, likewise, she never let up; there were no flowers in her garden as they would take up precious space which was better occupied with growing turnips for the poor. One day, whilst weeding furiously amidst the rows of turnips, she spotted a tiny daisy.

"Aha!" she called out, "I'll soon put and end to you!" But her little daughter stepped in the way and cried, "Mamma, mamma, why do you want to kill the flower?"

Looking into the small child's earnest eyes, the woman asked herself that question for the first time in her life. She put down the garden hoe, enfolded her daughter in her arms, and went into her house, to start a whole new way of life from that day forth.
Mind Flight

There once was a young monk who was very devout and worked ever so hard at being holy. There wasn't a second in the day he wouldn't fill with reading about the saints, asking questions to his teachers, debating the finer points of theosophy with fellow monks, writing meaningful poems, singing holy songs and praying to every angel, every saint his religion had to offer.

One of his teachers watched him and recognised a younger self; he ordered the young monk to sit in the garden and talk to no-one for a week.

The young monk grudgingly obeyed; he played games in his head from dawn to dusk and nearly went mad with hopping impatience. But after three days had passed, slowly the garden began to work its magic; and on the morning of the fourth day, as the sun rose, a threshold was finally breached - the young monk fell silent in the beauty of it all, and simply adored everything, and when at last he gave a simple "Thank You" to his creator, for the first time he had the feeling there was really someone there, he had been heard at last.
The Exotic Dancer

A man who was very serious and very set in his ways on his way home from work sees that a group of exotic travellers have made camp near the road where his house is. From the distance, he can hear laughter and music, and he can see the shine of huge roaring fire as well.

Incensed and disturbed, the man strides up to put an end to this nonsense and threaten the travellers with the police so that normalcy and order can be restored; but as he comes close, he is instantly captivated by a beautiful young woman who is dancing, framed by the fire.

He is entranced; forgets all about his complaints and sits down to watch her with the others.

Later, he shares their wine and later still, he too is seen to dance ...
PintarFundo

```
void PintaFundo(int red, int green, int blue)

```

Função de criação de um ponto. Um ponto é representado por um pixel.

### Parâmetros

*red*: valor de 0 a 255 em relação a pigmento vermelho da imagem

*green*: valor de 0 a 255 em relação a pigmento verde da imagem

*blue*: valor de 0 a 255 em relação a pigmento azul da imagem

### Exemplo

```
#include <playCB/playcb.h>

int main(){

    AbreJanela(400, 400, "Fundo Azul");
    PintarFundo(0, 0, 255);

    Desenha();

    return 0;
}

```

*Revisado dia 18/08/2015*
Mostra Plano

```
void MostraPlanoCartesiano(int intervalo)

```

Exibe linhas das coordenadas da playCB. Seu centro é localizado em (0,0) e é identificado pelas linhas pretas. As linhas cinzas indentificam o intervalo das coordenadas.

### Parâmetros

*intervalo*: valor do intervalo que cada linha cinza tem. Valor teve ser **maior que** 0.

### Exemplo

```
#include <playCB/playcb.h>
int main(){

    AbreJanela(400, 400, "Intervalo menor");

    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(5);

    Desenha();
}

```

*Revisado dia 19/08/2015*
Triângulo

```
int criaTriangulo(float base, float altura, Ponto cantoesq)

```

Função de criação de triângulos isósceles.

### Parâmetros

*base*: tamanho da base do triângulo

*altura*: altura do triângulo

*cantoesq*: ponto da base inferior esquerda do triângulo

### Exemplo

#### Exemplo 1: Entendendo parâmetros de CriaTriangulo

```
#include <playCB/playcb.h>

int main(){
    Ponto p;

    p.x = 0;
    p.y = 0;

    AbreJanela(400, 400, "Triangulo");
    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(10);

    **CriaTriangulo**(50, 80, p);
    Pintar(255, 0, 0);

    Desenha();
}

```

#### Exemplo 1: Usando retorno de CriaTriangulo

```
#include <playCB/playcb.h>

int main(){
    Ponto p;
    int geos[9];
    int j = -85;

    AbreJanela(600, 600, "Pintando o elemento do meio de vermelho");
    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(10);

    p.y = 0;
    for(int i = 0; i < 9; i++){
        p.x = j;
        j += 20;

        geos[i] = CriaTriangulo(10, 15, p);
        Pintar(255, 255, 0);
    }
    Pintar(255, 0, 0, TRIANGULO, geos[4]);
    Desenha();
}

```

## Ver também

* Pintar outras geometrias usando seus índices

*Revisado dia 24/02/2016*
Delicious

A sick child in hospital won't eat and is fading away, not getting any better. Everyone is upset and a wise woman hears about this. She sets to making a special sweet desert for the child; it is full of vitamins as it is made from special fruits she grows in her garden, but there is more to it than that. She also adds magical flower petals and blesses it, puts it into a beautifully shaped coloured glass bowl, decorates it lovingly with tiny leaves and fairy flowers, and takes it to the child.

The child is so delighted by this offering, he actually puts his finger in the soft, sweet, cool stuff and smells it, tastes it. A shudder of delight runs through him, he smiles and eagerly, hungrily, sets to eating the entire bowl.
Lista

A

1. AbreImagem()
2. AbreJanela()
3. ApagaGrupo()
4. ApertouTecla()
5. AssociaImagem()

C

1. CriaCirculo()
2. CriaCircunferencia()
3. CriaElipse()
4. CriaGrupo()
5. CriaPoligono()
6. CriaPoligonoVetor()
7. CriaPonto()
8. CriaQuadrado()
9. CriaReta()
10. CriaRetangulo()
11. CriaTriangulo()

D

1. Desenha()
2. Desenha1Frame()

G

1. Gira()
2. Grafite()

L

1. LimpaDesenho()

M

1. MostraPlanoCartesiano()
2. Move()
3. MudaLimitesJanela()

P

1. Pintar()
2. PintarFundo()

R

1. Redimensiona()
2. RetornaTecla()
Carrinho

```
#include <playCB/playcb.h>

void casinha(){
    Ponto p;

    CriaGrupo(); //Grupo casinha

    p.x = -20;       p.y = 0;
    CriaRetangulo(20, 30, p); Pintar(230, 255, 0);

    p.y = 30;
    CriaTriangulo(20, 20, p); Pintar(255, 0, 0);
}

int carrinho(){
    Ponto p;
    int grupo;

    grupo = CriaGrupo(); //grupo do carrinho
    p.x = -100;      p.y = 0;

    CriaRetangulo(30, 20, p); Pintar(0, 178, 0);
    p.x = -95;      p.y = -2;

    CriaCirculo(3, p);
    p.x = -80;
    CriaCirculo(3, p);

    return grupo;
}
int main(void){
    Ponto p;
    float i;
    int grupocar;

    AbreJanela(400,400, "Carrinho");
    PintarFundo(255, 255, 255);

    grupocar = carrinho();
    casinha();

    for(i = -100; i < 100; i += 0.5){
        //Vou andar de -100 à 100
        p.x = i;
        Move(p, grupocar);
        Desenha1Frame();
    }

    Desenha();
    return 0;
}

```

*Revisado dia 17/09/2015*
Sistema Solar

```
#include <playCB/playcb.h>
#include <math.h>
int main () {
  Ponto p1, p2, p3;
  int orbitalua, terra, lua, sol;
  double ang;

  AbreJanela (400,400, "Sistema Solar");
  PintarFundo (255, 255, 255);

  p1.x =  0;    p1.y = 0;
  CriaCircunferencia(50, p1); //Órbita da Terra
  Pintar (255,0,0);  Grafite(3);

  orbitalua = CriaGrupo();
  CriaCircunferencia(10, p1); //Órbita da Lua
  Pintar (0,255,255);  Grafite(2);

  terra = CriaGrupo();
  CriaCirculo(5, p1); Pintar (0,0,255); //Terra

  lua = CriaGrupo();
  CriaCirculo(2, p1); Pintar (100, 100, 100);//Lua

  sol = CriaGrupo();
  CriaCirculo(10, p1); Pintar (255,255,0); //Sol

  for (ang = 0;  ; ang +=.01) {
    p2.x = 50*cos(ang);
    p2.y = 50*sin(ang);
    Move(p2,terra);//translada Terra para sua órbita

    p3.x = 10*cos(ang*15)+p2.x;
    p3.y = 10*sin(ang*15)+p2.y;
    Move(p3,lua);//translada Lua para sua órbita
    Move(p2,orbitalua);//em torno da Terra

    Desenha1Frame();
  }
  Desenha ();//(desnecessário) mantém janela aberta
  return 0;
}

```

*Revisado dia 17/09/2015*
Refreshing The Spirit

A young mother is ill in hospital, and her husband says repeatedly that he doesn't like to visit her there, not because he doesn't love her, but because he finds this hospital so depressing, with so many sick people and the dead and dying all around.

His son and daughter, little children both, confer about this. They go out and gather a bouquet from the hedgerows - little flowers, branches from shrubs, grasses and all manner of weeds, for are too young to know the difference. They bring it to their father and say they want him to take them to the hospital, so they can give this to their mum, so she can smell it and be reminded of the open air, the countryside.
Floco de neve

```
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <playCB/playcb.h>

#define LARGURA 800 //1962
#define ALTURA  600 //1280
#define SIZE 180

Ponto movaCaneta(Ponto from, double theta, double len) {
  Ponto to;
  double rad = theta*PI/180;
  to.x = from.x + len*cos(rad);
  to.y = from.y + len*sin(rad);
  return to;
}

Ponto koch (Ponto from, double len, double theta, int order) {
  Ponto to;
  double rad = theta*PI/180;

  if (order==0) {
    to.x = from.x + len*cos(rad);
    to.y = from.y + len*sin(rad);

    CriaReta(from, to); Grafite(2); Pintar(255,0,0);
  }
  else {
    koch(from, len/3, theta, order-1);

    to = movaCaneta(from, theta, len/3);
    from = to;//dispensável.
    // seu uso é para tornar intuitiva a chamada abaixo
    koch(from, len/3, theta+60, order-1);

    to = movaCaneta(from, theta+60, len/3);
    from = to;
    koch(from, len/3, theta-60, order-1);

    to = movaCaneta(to, theta-60, len/3);
    from = to;
    koch(from, len/3, theta, order-1);
  }
  return movaCaneta(from, theta, len/3);
}

void floco_de_neve(int ordem) {
  Ponto p0;
  p0.x = -45.0; p0.y = 26.0;//centro do floco de neve

  p0 = koch(p0, SIZE/2,    0, ordem);
  p0 = koch(p0, SIZE/2, -120, ordem);
  p0 = koch(p0, SIZE/2,  120, ordem);

}

int main(void) {
  int ordem=6;

  MostraPlanoCartesiano(10);
  AbreJanela(LARGURA,ALTURA, "Flocos de Neve");
  PintarFundo(255, 255, 255);

  floco_de_neve(ordem);

  Desenha();

  return 0;
}

```

*Revisado dia 17/09/2015*
Wikia PlayCB

1. REDIRECIONAMENTO [Guia atualizado[1]]

**Wikia PlayCB**
A PlayAPC é uma biblioteca educacional de programação voltada para os alunos de Computação Gráfica da UnB que tem como objetivo ilustrar, de maneira gráfica, os conceitos aprendidos durante o curso com aplicações simples. Com ela, é possível criar animações simples e desenhos estáticos.

A biblioteca consiste em um conjunto de funções para criação e manipulação de formas 2D e utilização de imagens. Utiliza a API OpenGL e GLFW

A PlayAPC foi desenvolvida usando o conceito de Orientação a Objetos de C++, por praticidade de desenvolvimento e facilidade de encapsulamento. Entretanto, a playapc.h entrega ao aluno uma interface amigável com chamadas de funções simples para a criação de todos os objetos, utilizando o paradigma Imperativo.

### Nota

Esta biblioteca está configurada para executar juntamente com a GLFW 2.7 e qualquer versão da OpenGL

Atualmente está na sua versão 1.6.

Github
Ponto

```
int criaPonto(Ponto p)

```

Função de criação de um ponto. Um ponto é representado por um pixel.

### Exemplo

#### Exemplo 1: Entendendo parâmetros de CriaPonto

```
#include <playCB/playcb.h>
int main(){
    Ponto p;

    p.x = 5;
    p.y = 5;

    AbreJanela(400, 400, "Ponto");
    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(10);

    **CriaPonto(p);**
    Pintar(128, 0, 255);

    Desenha();
}

```

#### Exemplo 2: Usando retorno de CriaPonto

```
#include <playCB/playcb.h>
int main(){
    Ponto p;
    int geos[9];
    int j = -85;

    AbreJanela(600, 600, "Pintando o elemento do meio de vermelho");
    PintarFundo(0, 0, 0);

    p.y = 0;
    for(int i = 0; i < 9; i++){
        p.x = j;
        j += 20;

        geos[i] = CriaPonto(p);
        Pintar(255, 255, 0);
    }
    Pintar(255, 0, 0, PONTO, geos[4]);
    Desenha();
}

```

## Ver também

* Pintar outras geometrias usando seus índices

*Revisado dia 24/02/2016*
Circunferência

```
int criaCircunferencia(float raio, Ponto meio)

```

Função de criação de um circunferência.

### Parâmetros

*raio*: raio da circunferência

*meio*: coordenadas do centro do circunferência

### Retorno

Índice da geometria do tipo CIRCUNFERENCIA.

### Exemplo

#### Exemplo 1: Entendendo parâmetros de CriaCircunferencia

```

#include <playCB/playcb.h>

int main(){

 Ponto p;

 AbreJanela(600, 600, "Circunferencia");
 MostraPlanoCartesiano(10);
 PintarFundo(255, 255, 255);

 p.x = 0;
 p.y = 0;

 **CriaCircunferencia(50, p);**
 Pintar(200, 191, 231);

 Desenha();

 return 0;
}

```

Exemplo 2: Usando retorno de CriaCircunferecia

```
#include <playCB/playcb.h>

int main(){
    Ponto p;
    int geos[9];
    int j = -80;

    AbreJanela(600, 600, "Pintando o elemento do meio de vermelho");
    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(10);

    p.y = 0;
    for(int i = 0; i < 9; i++){
        p.x = j;
        j += 20;

        geos[i] = CriaCircunferencia(5, p);
        Pintar(0, 0, 255);
    }
    Pintar(255, 0, 0, CIRCUNFERENCIA, geos[4]);
    Desenha();
}

```

 Ver também

* Pintar outras geometrias usando seus índices

*Revisado dia 24/02/2016*
Pintar

Atualmente, há dois modos de usar a função *Pintar()*. Em ambos os modos, cada ponto da geometria definida possui uma única cor sólida definida pelos parâmetros. Não há a possibilidade de definir a cor transparente para uma geometria.

## Mudando a cor da última geometria definida

```
void Pintar(int red, int green, int blue)

```

Após a definição de uma geometria , a função *Pintar()* neste modo irá colorir toda a geometria de uma cor sólida usando padrão RGB.

#### Parâmetros

*red*: valor de 0 a 255 em relação a pigmento vermelho da imagem

*green*: valor de 0 a 255 em relação a pigmento verde da imagem

*blue*: valor de 0 a 255 em relação a pigmento azul da imagem

#### Exemplo:

```
#include <playCB/playcb.h>

int main(){
    Ponto p;

    AbreJanela(400, 400, "Triangulo branco");
    PintarFundo(0, 0, 0);

    p.x = -20;
    p.y = -25;
    CriaTriangulo(40, 50, p);
    Pintar(255, 255, 255);

    Desenha();

    return 0;
}

```

## Mudando a cor de uma geometria definida anteriormente

```
void Pintar(int red, int green, int blue, geometrias_validas nome, int index)

```

Como cada geometria retorna um índice, este índice junto com o tipo de geometria indica qual geometria deve ser pintada.

#### Parâmetros

*red*: valor de 0 a 255 em relação a pigmento vermelho da imagem

*green*: valor de 0 a 255 em relação a pigmento verde da imagem

*blue*: valor de 0 a 255 em relação a pigmento azul da imagem

*nome:* tipo de geometria que pode ser pintada. Atualmente, este valor pode ser somente os listados a seguir

* PONTO
* RETA
* TRIANGULO
* QUADRADO
* RETANGULO
* CIRCULO
* CIRCUNFERENCIA
* POLIGONO
* ELIPSE
* GRAFICO

*index:* valor de retorno de alguma das funções de criar geometria.

Caso seja passado um índice ou tipo de geometria inválido, irá colorir a última geometria definida.

#### Exemplo:

```
#include <playCB/playcb.h>
#include <stdio.h>

void meuSleep(){
 int i;
 for(i = 0; i < 200; i++)
 printf("Eu nao sei o que estou fazendo\n");
}

int main(){
 Ponto p;
 int indexCirculo, indexQuad[10], i;

 AbreJanela(400, 400, "Muitos quadrados");
 PintarFundo(0, 0, 0);

 p.x = 0;
 p.y = 70;
 indexCirculo = CriaCirculo(30, p);
 Pintar(0, 0, 0);

 p.y = 0;
 i = 0;
 for(p.x = -100; p.x < 100; p.x += 20){
 indexQuad[i] = CriaQuadrado(15, p);
 Pintar(34, 177, 76);
 i++;
 }

 Desenha1Frame();
 meuSleep();

 Pintar(255, 255, 0, CIRCULO, indexCirculo);
 for(i = 0; i < 10; i++){
 Pintar(0, 255, 0, QUADRADO, indexQuad[i]);
 Desenha1Frame();
 meuSleep();
 }

 Desenha();

 return 0;
}

```

 *Revisado dia 24/02/2016*
Altera Plano

```
void MudaLimitesJanela(int limite)

```

Esta é a **única função** da playCB que, se for utilizada, deve ser chamada **antes** da função *AbreJanela*. Ela altera os limites das coordenadas da playCB. Caso esta função não seja chamada, os limites são de -100 à 100, tanto no eixo horizontal quanto no eixo vertical.

### Parâmetros

*limite*: valor dos limites horizontais e verticais dos eixos de coordenadas da playCB.

### Exemplo

```
#include <playCB/playcb.h>
int main(){

    MudaLimitesJanela(50);

    AbreJanela(400, 400, "Limite menor");
    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(10);

    Desenha();
}

```

*Revisado dia 19/08/2015*
Limpa Desenho

```
void LimpaDesenho()

```

Destrói todos os elementos da cena, incluindo grupos e o plano cartesiano. Porém, não altera a cor do fundo nem os limites dos eixos.

### Exemplo

```
#include <playCB/playcb.h>

int main(){
    Ponto p;
    float theta;

    MudaLimitesJanela(20);
    AbreJanela(400, 400, "Magica");
    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(5);

    p.x = -5;
    p.y = -5;
    CriaQuadrado(10, p);
    Pintar(255, 255, 0);

    for(theta = 0; theta <= 360; theta += 0.05){
        Gira(theta);
        Desenha1Frame();
    }

    LimpaDesenho();
    MostraPlanoCartesiano(2.5);
    p.x = -10;
    p.y = -10;
    CriaQuadrado(10, p);
    Pintar(255, 0, 255);

    for(theta = 0; theta <= 360; theta += 0.05){
        Gira(theta);
        Desenha1Frame();
    }

    Desenha();
}

```

*Revisado dia 19/08/2015*
The Sunshine Nurse

There once was a person who had let a small injury run out of control through lack of care so now it had become a big problem and they were taken to a hospital.

In this hospital, there were many nurses who were all very strict about hygiene, cleanliness and doing the right things to make people well; but there was one amongst them who was young, and cheerful, and her spirit was bright.

She was very friendly and the person felt much happier in her presence than with the other nurses who tended to be very serious and tut and make them feel it was all their fault; and when they got better, they send a thank you card made out especially to "my sunshine nurse".
Retorna Tecla

```
int RetornaTecla()

```

Função que retorna a tecla pressionada pelo usuário.

### Retorno

A tecla que foi pressionada pelo usuário. Seus valores podem ser:

* GLFW\_KEY\_UNKNOWN
* GLFW\_KEY\_SPACE
* GLFW\_KEY\_APOSTROPHE
* GLFW\_KEY\_COMMA
* GLFW\_KEY\_MINUS
* GLFW\_KEY\_PERIOD
* GLFW\_KEY\_SLASH
* GLFW\_KEY\_0
* GLFW\_KEY\_1
* GLFW\_KEY\_2
* GLFW\_KEY\_3
* GLFW\_KEY\_4
* GLFW\_KEY\_5
* GLFW\_KEY\_6
* GLFW\_KEY\_7
* GLFW\_KEY\_8
* GLFW\_KEY\_9
* GLFW\_KEY\_SEMICOLON
* GLFW\_KEY\_EQUAL
* GLFW\_KEY\_A
* GLFW\_KEY\_B
* GLFW\_KEY\_C
* GLFW\_KEY\_D
* GLFW\_KEY\_E
* GLFW\_KEY\_F
* GLFW\_KEY\_G
* GLFW\_KEY\_H
* GLFW\_KEY\_I
* GLFW\_KEY\_J
* GLFW\_KEY\_K
* GLFW\_KEY\_L
* GLFW\_KEY\_M
* GLFW\_KEY\_N
* GLFW\_KEY\_O
* GLFW\_KEY\_P
* GLFW\_KEY\_Q
* GLFW\_KEY\_R
* GLFW\_KEY\_S
* GLFW\_KEY\_T
* GLFW\_KEY\_U
* GLFW\_KEY\_V
* GLFW\_KEY\_W
* GLFW\_KEY\_X
* GLFW\_KEY\_Y
* GLFW\_KEY\_Z
* GLFW\_KEY\_LEFT\_BRACKET
* GLFW\_KEY\_BACKSLASH
* GLFW\_KEY\_RIGHT\_BRACKET
* GLFW\_KEY\_GRAVE\_ACCENT
* GLFW\_KEY\_ESCAPE
* GLFW\_KEY\_ENTER
* GLFW\_KEY\_TAB
* GLFW\_KEY\_BACKSPACE
* GLFW\_KEY\_INSERT
* GLFW\_KEY\_DELETE
* GLFW\_KEY\_RIGHT
* GLFW\_KEY\_LEFT
* GLFW\_KEY\_DOWN
* GLFW\_KEY\_UP
* GLFW\_KEY\_PAGE\_UP
* GLFW\_KEY\_PAGE\_DOWN
* GLFW\_KEY\_HOME
* GLFW\_KEY\_END
* GLFW\_KEY\_CAPS\_LOCK
* GLFW\_KEY\_SCROLL\_LOCK
* GLFW\_KEY\_NUM\_LOCK
* GLFW\_KEY\_PRINT\_SCREEN
* GLFW\_KEY\_PAUSE
* GLFW\_KEY\_F1
* GLFW\_KEY\_F2
* GLFW\_KEY\_F3
* GLFW\_KEY\_F4
* GLFW\_KEY\_F5
* GLFW\_KEY\_F6
* GLFW\_KEY\_F7
* GLFW\_KEY\_F8
* GLFW\_KEY\_F9
* GLFW\_KEY\_F10
* GLFW\_KEY\_F11
* GLFW\_KEY\_F12
* GLFW\_KEY\_F13
* GLFW\_KEY\_F14
* GLFW\_KEY\_F15
* GLFW\_KEY\_F16
* GLFW\_KEY\_F17
* GLFW\_KEY\_F18
* GLFW\_KEY\_F19
* GLFW\_KEY\_F20
* GLFW\_KEY\_F21
* GLFW\_KEY\_F22
* GLFW\_KEY\_F23
* GLFW\_KEY\_F24
* GLFW\_KEY\_F25
* GLFW\_KEY\_KP\_0
* GLFW\_KEY\_KP\_1
* GLFW\_KEY\_KP\_2
* GLFW\_KEY\_KP\_3
* GLFW\_KEY\_KP\_4
* GLFW\_KEY\_KP\_5
* GLFW\_KEY\_KP\_6
* GLFW\_KEY\_KP\_7
* GLFW\_KEY\_KP\_8
* GLFW\_KEY\_KP\_9
* GLFW\_KEY\_KP\_DECIMAL
* GLFW\_KEY\_KP\_DIVIDE
* GLFW\_KEY\_KP\_MULTIPLY
* GLFW\_KEY\_KP\_SUBTRACT
* GLFW\_KEY\_KP\_ADD
* GLFW\_KEY\_KP\_ENTER
* GLFW\_KEY\_KP\_EQUAL
* GLFW\_KEY\_LEFT\_SHIFT
* GLFW\_KEY\_LEFT\_CONTROL
* GLFW\_KEY\_LEFT\_ALT
* GLFW\_KEY\_LEFT\_SUPER
* GLFW\_KEY\_RIGHT\_SHIFT
* GLFW\_KEY\_RIGHT\_CONTROL
* GLFW\_KEY\_RIGHT\_ALT
* GLFW\_KEY\_RIGHT\_SUPER
* GLFW\_KEY\_MENU

### Exemplo

```
#include <playCB/playcb.h>
int main(){

    AbreJanela(400, 400, "Aperte enter");

    while((GLFW\_KEY\_ENTER != RetornaTecla()){
        Desenha1Frame();
    }

    PintarFundo(255, 255, 255);
    MostraPlanoCartesiano(10);

    Desenha();
}

```

*Revisado dia 4/09/2015*