#unit 0001 0
Explore tagged Tumblr posts
Text
Happy birthday to me! Well, on the 2nd it was, at least. I think this is actually the first birthday drawing I've been able to do in a few years, and it's a pretty frantic scribble I made during work
#livastia#livastia universe#lai#robots#mai#livastian military ai#livastian ai#character#graffi#aristophanes unit 0001 0#aristophanes freling#kelly unit 0634 5#kelly segal#unit 0001 0#unit 0634#graffi sasaki#traditional art#traditional sketch#artists on tumblr#art
9 notes
·
View notes
Text
Beyond the Time - a brief history of Psycho-frame technology
With the Psycommu firmly establishing its place as a mainstay in many high-performance machines, researchers began focusing their efforts into increasing the effectiveness and capabilities of the system while also miniaturizing the technology.
Engineers under Casval Rem Deikun's Newborn Neo Zeon movement eventually developed a way to build the Psycho-frame directly into the inner frame of a mobile suit by lining the material with a technology known as Psycho-chips. Psycho-chips could replace the large subsystem traditionally required by a by a Psycommu system.
The project was headed by former Earth Federation researcher Nanai Miguel.
With the project's success, the technology was applied to the MSN-04 Sazabi as well as several other machines intended for use by Newtypes.
Hoping to make his final confrontation with his long-time rival Amuro Ray a fair fight, Neo Zeon's supreme leader Char Aznable leaked the technology to Anaheim Electronics. The Psycho-frame would be applied to the RX-93 ν Gundam.
Chan Agi was also given a sample of the Psycho-frame material by October Saran, which at one point resonated her will, manifesting a small Psycho-field to deflect a mega-particle cannon blast.
A mysterious resonance between Char and Amuro's Psycho-frame systems lead to the formation of a Psycho-field. Through sheer force of will, the Psycho-field was able to force the asteroid Axis off course and away from the Earth, preventing Char's plan from coming to fruition. This event would be dubbed the "Axis Shock".
Officially, following the end of the Second Neo Zeon War, development and application of Psycho-frame technology was officially halted citing "too many unknowns" regarding it. Unofficially, however, research continued under the UC Project.
The project would result in the RX-0 Unicorn Gundam, the first full Psycho-frame mobile suit. While previous machines incorporating the Psycho-frame did so near and around the cockpit, the Unicorn interwove the material throughout its entire structure. This allowed a Newtype pilot to potentially directly control the mobile suit through sheer willpower.
The construction of the frame remained consistent with RX-0 units 2 and 3, the Banshee and the Phenex.
Psycho-frame was also known to manifest crystals, dubbed Psycho-shards, when perfect synchronization between pilot and mobile suit is achieved.
Psycho-frame would also be incorporated into some other technologies. Jona Basta wore a Psycho-frame equipped normal suit during his pursuit of Phenex. The exact purpose of the modified normal suit is unclear.
The Psycho-frame would see further development and use over the course of UC history. It would be incorporated into several mobile suits developed by the Federation's Strategic Naval Research Institute, such as the F90N and F91 Gundams.
And finally, nearly a century after its initial development, Psycho-frame technology would be incorporated into the α000-0001 Gaia Gear α. It was the only man-machine known to use such a system.
This is by no means a comprehensive list of machines that use the Psycho-frame, or a compete and fully-documented development history! Think of it as a best-of or a highlight reel of Psycho-frame technology!
This piece was a request from a friend!
#lets talk gundam#mobile suit gundam#gaia gear#mobile suit gundam unicorn#mobile suit gundam narrative#char's counterattack#mobile suit gundam f91
27 notes
·
View notes
Text
How to Do Arithmetic with Significant Figures
Rules For Determining If a Number Is Significant or Not
All non-0 digits are considered full-size. For instance, 91 has giant figures (nine and 1), at the same time as 123.Forty five has 5 tremendous figures (1, 2, three, four, and five).Zeros performing among non-0 digits (trapped zeros) are sizeable. Example: one zero one.12 has five huge figures: 1, zero, 1, 1, and a pair of.
Leading zeros (zeros before non-0 numbers) aren't sizeable. For instance, zero.00052 has widespread figures: five and a couple of.Trailing zeros (zeros after non-0 numbers) in more than a few without a decimal are normally now not full-size (see under for greater info). For example, four hundred has handiest one widespread determine (4). The trailing zeros do now not rely as considerable.
Trailing zeros in a range of containing a decimal factor are substantial. For example, 12.2300 has six huge figures: 1, 2, 2, three, zero, and zero. The range 0.000122300 still has only six widespread figures (the zeros earlier than the 1 aren't large). In addition, 120.00 has 5 considerable figures since it has three trailing zeros. This convention clarifies the precision of such numbers.
For instance, if a dimension this is specific to four decimal locations (zero.0001) is given as 12.23, then the measurement is probably understood as having most effective two decimal locations of precision to be had. Stating the end result as 12.2300 makes it clean that the dimension is precise to 4 decimal places (in this case, six significant figures).The variety 0 has one considerable figure. Therefore, any zeros after the decimal factor are also large. Example: zero.00 has 3 considerable figures.Any numbers in clinical notation are considered massive. For instance, 4.300 x 10-four has four good sized figures.
Conventions Addressing Significant Figures
The importance of trailing zeros in a number of not containing a decimal point can be ambiguous. For example, it could not usually be clean if a variety of like 1300 is unique to the nearest unit (and simply takes place coincidentally to be an precise more than one of 100) or if it's miles most effective proven to the nearest hundred because of rounding or uncertainty. Various conventions exist to address this issue:
A bar can be located over the last considerable determine, displaying that any trailing zeros following this are insignificant. For instance, 1300 with a bar positioned over the first zero would have 3 substantial figures (with the bar indicating that the quantity is specific to the closest ten).
The last big parent of more than a few may be underlined; as an instance, “2000” has two giant figures.A decimal point can be placed after the quantity. For instance “100.” indicates specially that three big figures are meant.
In the combination of various and a unit of size the paradox may be avoided by using selecting a appropriate unit prefix. For instance, the variety of sizable figures in a mass unique as 1300 g is ambiguous, while in a mass of thirteen hg or 1.Three kg, it is lots clearer.
1 note
·
View note
Text
Dual Diagnosis and Treatment
Simply put, a Dual Diagnosis refers to the co-occurrence of a substance use disorder (SUD) and a mental disorder, such as depression, anxiety, attention-deficit hyperactivity disorder (ADHD), bipolar disorder, and schizophrenia (National Institute of Mental Health, 2021). Dual Diagnoses are associated with increased negative mental and physical health outcomes, unplanned hospitalizations, suicide, and early onset of death; social consequences including risks for violence, injury, victimization, exploitation, homelessness, personal relationship breakdowns, isolation, and involvement with the criminal justice system. A study by Alsuhaibani et al. (2021) indicated that between a quarter and a third of prison populations in Western countries are known to have a dual diagnosis.
A Dual Diagnosis can occur within any social class, gender, ethnicity, and what have you. They are more common than you might think. Up to 75% of patients with a severe mental illness (SMI) also have SUD, and about 60% of adults with SUD also have at least one type of SMI.
Considering the high prevalence of these coexisting disorders and the known effectiveness of integrated treatment models, it would make sense that integrated services would be made more available. Yet a study by Spivak et al. (2020) reported that even though the proportion of facilities that offered any substance abuse services had increased over the last decade, the Integrated Dual Diagnoses Treatment model has decreased. The National Institute of Mental Health (NIMH) asserts that these co-occurring disorders are more effectively treated together, and that the treatment should be patient-specific, considering the unique demographics, combination of disorders and symptoms, and need to be evaluated by a health care provider for each disorder.
Help is out there, and there is a wealth of information at your fingertips to empower you as a health care provider, and your patients alike in finding it. The NIMH is a great resource for locating substance abuse and mental health services, health information, and information on open clinical trials. Dual Diagnosis Anonymous (DDA) is a peer-led, community-based program which has been shown to demonstrate a perceived positive impact on self-acceptance, social functioning, self-development, recovery progression, and a sense of hope in its members (Milani et al., 2020). Special consideration should be given to the integrated care planning and management of the dually diagnosed to prevent fragmentation of care and promote the best possible outcomes. Take care to dually and adequately screen your patients.
References
Alsuhaibani, R., Smith, D. C., Lowrie, R., Aljhani, S., & Paudyal, V. (2021). Scope, quality and inclusivity of international clinical guidelines on mental health and substance abuse in relation to dual diagnosis, social and community outcomes: a systematic review. BMC Psychiatry, 21(1). https://doi.org/10.1186/s12888-021-03188-0
Milani, R. M., Nahar, K., Ware, D., Butler, A., Roush, S., Smith, D., Perrino, L., & O’Donnell, J. (2020). A qualitative longitudinal study of the first UK Dual Diagnosis Anonymous (DDA), an integrated peer-support programme for concurrent disorders. Advances in Dual Diagnosis, 13(4), 151–167. https://doi.org/10.1108/add-01-2020-0001
NIMH » substance use and Co-Occurring mental disorders. (2021, July 1). National Institute of Mental Health. https://www.nimh.nih.gov/health/topics/substance-use-and-mental-health/
Spivak, S., Strain, E. C., Spivak, A., Cullen, B., Ruble, A. E., Parekh, V., Green, C., & Mojtabai, R. (2020). Integrated dual diagnosis treatment among United States mental health treatment facilities: 2010 to 2018. Drug and Alcohol Dependence, 213, 108074. https://doi.org/10.1016/j.drugalcdep.2020.108074
1 note
·
View note
Text
why does Löb's Theorem work?
The Löb's Theorem is named after a 19th-century Danish mathematician who proved it (see theorem).
Let's talk about bits. We usually think of them as binary digits. They are stored in computer memory as z values. That value is always between zero and a power of 2. (By convention, the bottom bit [0] always sits at power of 2 value 0, while the top bit [255] always seats at power of 2 value 255.)
For concreteness, and for any z between zero and a power of 2, we can take our first digit (say the one at the bottom) and represent it using two complex numbers with z. That is,
z = na,
z = ja,
where n the number of our powers of 2 (so n*a is always a power of 2), j the imaginary unit, i the real unit. There are some units like radians, where the a is just a number we multiply the z by and we have
z =
For instance, we could represent the decimal value 21, (10 22 = 21). So we might then have the digit representations 21, 011, 111, where 21 = (10 22), 011 = 21/2 and 111 = 11.
So a bit is one thing but we need multiple things to encode the "number of bits", and to be honest, how many things doesn't matter. A lot of the time what matters is the "logical representation" (the way we say a bit has the value one, zero or another). We encode this with three things only: if this is a 0 bit, then z; if this is a 1 bit, then z; and if both are 0, they must be the same bit. That means we need a way to set each register, and to know which is the same register, such that after we do this they will each be equal to zero, and can also stay equal to that value for the rest of our computation, and we don't need to store it anywhere.
This is why we need three bits: it tells us to do some arithmetic twice. And this is how the 3 bit Löb's Theorem works.
We know that n*a can be 4/27 and j*a can be 0 1 255, but not all combinations make sense. In general, n*a can be any integer between zero and a power of 2.
So for any z between 0 and a power of 2, we will set to this z and do some arithmetic. (Well, in theory we'll actually do all the arithmetic twice and then know that we have this z.) So clearly the Löb Theorem requires us to also have this z, but for how many z does it depend? For any z, some number of our bits will be zero and some won't be. For any z, some number of our a will be zero and some won't be.
So we really need to understand how many possible z are we.
This is easy to see with the binary numbers. When we start writing them down in normal form, and consider them mod 2, we have:
0 1
We have one zero between two ones. This means i*a can be 0 - so we'd just plug that into the register as zero.
0001
0000
1
This can't be right because a and i are both integers, so if we're taking 0s between 1s, a*j can't be 256*i + 1 - otherwise the two 1s would go over each other, which doesn't make sense.
0111
1111
255
This is still one a between two js, but it's now 255*i + 21. (21 because the top bit always is 1). So if you add 1 to these, you're gonna get a number which is between 0 and 255*i + 22 which is out of the possible values we could have chosen. (Remember that a can be any power of 2 between 0 and 255).
We can see this by checking the table, as there's only two possibilities for the number of ones (n*i):
n i 0 1
That's the only thing we're left with: what if i is not small enough? What if, like our number we're multiplying against, i is big enough that we wouldn't consider it small enough to reduce all 1s to zero?
We see that even if j is 256, it can never reduce our number to zero, because the top bit (the bit we depend on) is always nonzero. In other words, it can make our number bigger. We thus need j to be a number that's bigger than 255 (or bigger than the number we're actually doing our multiplication by), a number that can always be written as an integer which is bigger than a power of 2.
The smallest such number would be 255, and it's just one more than the biggest, so is in fact the biggest. All numbers in our range of numbers have the property that all of their digits are bigger than our number, and all of our numbers have the property that all excess digits are smaller than our number.
But the smallest power of 2 bigger than our number is 2^8 = 1. So our number can be represented as one thing, and be smaller than one other thing, and still be bigger than another one. We need one of these things in order for it to be bigger. Let's look at those possibilities.
There's only one possible z of size between 0 and the smallest power of 2 we can be bigger than.
There's no numbers between zero and the smallest power of 2 we can be bigger than.
There's too many numbers between zero and that size for us to be able to choose one.
So we need just one number between 0 and the smallest power of 2 bigger than zero, but smaller than 255. That's the "logical" requirement.
How does that work, though? Well, we know we need lots of powers of 2, but those all get smaller than zero, so you need a number of bits that can be mapped to zero but not anything else. And between zero and the smallest possible power of 2, you really need more than one such number, because you can't have zero in more than one of those slots. And there's some number of slots. And that works out to three bits.
So that's why the Löb Theorem is (apparently, googling "löb theorem löb's theorem" returns some youtube videos and they seem to be having fun)
2^3 4 8
Because we know that n*a is 0-valued between zero and four, and that j*a must be 0-valued between zero and eight. So it gives us a number of things, each of which either has one bit we depend on that's one, or is all zero for the other two bits. The biggest power of 2 that gets that small, the biggest power of 2 that can take 255 as a power of 2 and still be big enough, is two bits (biggest power of 2
1 note
·
View note
Text
Hey everyone! Happy Ares Appreciation Day! I’ve finally finished that project I’ve been working on, so here it is!
Also Happy Birthday @bring-us-back-light . You can finally drink alcohol!
The Fount
What we know:
The Fount is an area generally believed to be in the South of the Underland, next to the Waterway. It’s controlled by Howard’s family, mainly his mother Susannah and his father York. We can assume Howard and his siblings are generally in the same social class as Luxa, there doesn’t seem to be any official royalty in the Fount, but York is apparently the Chair Governor. Its proximity to the Waterway is definitely reflected in its inhabitants; Howard is trained in water aid and enjoys raw shellfish. The Fount is believed to be smaller than Regalia, but it has similar facilities (They have a hospital that is at least on par with Regalia’s). Other than that, there isn’t much description of the Fount within the books. Enjoy!
=====================================================
A note on timing:
Throughout this document, years have been referenced using the Underland system, but for the sake of readers unfamiliar with this timing standard a short explanation has been provided below:
BD refers to Before Descent, which is the entirety of time there have been no humans in the Underland.
AD refers to After Descent. However, there has been much debate concerning whether years should be counted from the first discovery of the Underland or at the end of the fifty years it took to transfer everyone into the new world. Most scholars, for the sake of consistency, start counting from the first time Bartholomew of Sandwich entered the Underland.
For reference, Gregor Campbell first fell in 377 AD.
History
Backstory:
After Bartholomew of Sandwich migrated to the Underland in 0 AD it took over 200 years for a separate colony to develop. By this time, fliers and humans had developed a strong relationship; whilst riding fliers had been a general method of transport since the original treaty, the concept of bonding was only just starting to emerge around this time. At this specific point, humans held mostly peaceful relationships with Underland species, most notable of which was the Treaty of Klier, which was signed in 116 AD after a particularly brutal war with the Gnawers. This treaty remains the longest kept in Underland history, eventually crumbling after the uprising of Prince Bloodspike (for more reading see “file::TreatyOfKlier/116” in the Regalian library.)
Beginning:
This peace gave humans reason to explore, map and colonize areas within the Underland they had never been before. King Opel especially wished to explore the South, beyond the Waterway. Realising it would be much too impractical to have fliers travel that distance multiple times, he ordered a village, the first of its kind, to be set up just over halfway between Regalia and the unexplored areas. Over a thousand soldiers, families and workers left their Regalian homes to start afresh in this new town. Planning for the future, Lirk of Reyton (who Opel decreed should oversee the building of the village) ordered the construction of various houses upon a cliff. He was famously quoted: “I imagine a beautiful city here. A city of vibrant colour, of joyous life. Of children playing, of friends laughing. I imagine a home.” However, the humans did not have nearly enough resources to create such a large project, and instead of being purposefully created as Regalia was, the Fount started as a just few houses cobbled together on a cliff.
Sustenance:
It was virtually impossible to continue feeding inhabitants with food imported from Regalia, so citizens began to look for their own sources of nutrition. The art of fishing had been lost due to the lack of safe water near Regalia, but over the next couple years people began to set up homes and docks near the shallows of the Waterway. Basic crop fields also sprouted up in the surrounding areas, and despite a small famine for the first few years, inhabitants soon had a steady stream of food. Various tributaries and rivers joined the Waterway nearby, so fresh water was never an issue.
War:
For the first 30 or so years, Regalia kept a tight hold on the Fount, making sure it never developed its own parliament or military. However, increasing action from both Gnawers and Cutters forced Regalia to focus on more pressing concerns. By the end of 268 AD the capital was recovering from a particularly bloody war, and the Fount had developed to have similar size and might as the capital. Fearing another attack, the Regalian council turned to the colony for help, begging them to combine their armies and defeat their common enemy. The Fount agreed, on the terms that whilst the two cities were to be united, they had separate authorities and governments. Accepting these conditions, the two great cities joined together and managed to destroy both the Gnawers and Cutters at the same time, winning a victory that was celebrated for years to come. Over time, the Fount softened and became more under Regalian control, but to this day they are regarded as separate territories and regions.
Peace:
Relative peace ensued between 270 to 320 AD. The Gnawers’ lack of numbers meant they posed no threat, and the Fount continued to develop, enlarging the area it had control over. Connections between the city-state and Regalia had never been stronger; the humans were free to create new technology and continue exploring the Underland. Aside from various attacks from rouge Gnawers, this peace was maintained until the Garden of Hesperides flooding (file::GardenofHesperides) . This, although actually caused by previous grievances, was to set the cornerstone for the war that continued up until Gregor Campbell’s arrival. The Fount assisted the humans, of course, but Regalia’s larger army and royalty meant the coastal city could largely avoid conflict. This, combined with the Fount’s obscure location far away from the Gnawer’s territories are reasons why it is generally believed to be safer than Regalia during times of war.
Ripred:
In what has now become somewhat of an urban legend, Ripred the Gnawer (for more information see “file::Gnawer/0001”) attempted to take over the Fount with an army of Clackers (more commonly known as Lobsters, the Overland term). He, along with several other Gnawers, tried to organise the Clackers into separate attack groups, but the species’ incoherence and confusion resulted in the eventual capture and gentle redistribution of Clackers along the coast. Ripred himself managed to non-lethally injure hundreds of guards before being imprisoned (and promptly escaping less than a day later)
Modern Fount
Physical Description:
Today’s Fount bears almost no similarity to the organized grids of Regalian architecture; having started as a small village and spread out from there, the city is essentially a sprawling mess. It spreads all over the mountain it was originally built upon, some houses are over 400m above the Waterway’s sea level, despite being almost right next to it. The city is almost in reverse; instead of having the palace at the centre, the smallest and oldest homes take pride of place. However, there is something comforting about the way locals can navigate the small alleys and misshapen buildings with ease.The buildings themselves serve as homes, workplaces and leisure areas for inhabitants, and all look cobbled together, somehow teetering on the edge of collapsing but also looking incredibly sturdy at the same time. Due to the Fount’s relative proximity to not only the Jungle but also the flower fields of Kjar, the majority of the Underland’s dyes and paints are mixed and made in the city (various materials from the Waterway’s seabed are also used). This has lead to most of the buildings being painted in an extraordinary array of colours, and first-time visitors - who are usually used to the monochrome palette of Regalia - are often astounded by how beautiful the city is, especially at dawn/dusk.The palace was designed in a very different way to Regalia’s; the eldest city’s royal home is much more blocky and sturdy, whilst the Fount’s palace is slanted, abstract and colourful, giving it a much more vibrant look. The Fount gets its name from the monument outside the palace, the natural geyser, around which was built a beautiful community park (possible, of course, because of the bioluminescent creatures that give off enough light for plants to grow and the fresh water that keeps the soil hydrated). Many ceremonies are held there throughout the year, and it is not uncommon to see weddings or parties taking place. Not to mention, of course, the annual explosion of fresh water due to the build up in the natural pipes (see file::theFount/Geyser), which thousands come to see every year.
Political Structure:
The Fount is ruled over by a single governor, influenced by the Regalian council but also able and encouraged to make their own decisions. Unlike the heredity system used within Regalia, the governor is chosen democratically, with a new election every four years. This governor leads the small council known as The Oligarchy who discuss and impose laws concerning military defence, economic structure and social justice. Whilst both cities follow the Seven Commandments written down by Bartholomew of Sandwich in 2AD, laws passed in each settlement do not apply to each other. The Fount’s justice system is a complicated subject and will not be covered in this document. Governors can be elected no more than twice in a row, and must wait for the amount of time they spent in office before standing for election again. As mentioned previously, the Fount has had a rocky history with Regalia, but as of 379 AD it is almost exclusively under Regalian control, mainly due to the marriage of Susannah Vetring (aunt of Luxa Hawthi, current heir to the Regalian throne ) to York Griye, whose family has ruled the Fount for years. Readers should note that the royal family of the Fount is different to the governor. Susannah is the current leader whilst York is the governor. They have five children, but due to Howard Griye’s pursuit of medicine he has been pardoned of heirship, so Stellovet Griye will rule the Fount after her parents, followed by the rest of her siblings. The Fount abides by the same rules and laws of Regalia, and the two cities share the same social, legal and economic systems. However, a notable difference between the colonies is their justice system; Regalia takes much harsher action on criminals when compared with the Fount’s view on punishments.
Economy:
The Fount has a similar economy to Regalia; although the cities do not have a ‘currency’ as an Overlander would see it, inhabitants obtain necessities by trading goods and services with each other. On a much larger scale, the government also supervises a huge trading system with Underland species, such as trading dyes for silk from the spinners, fish for the safe return of any Overlander’s found by the crawlers and bread for shedded Stinger scales, as they are incredibly tough and are used in armour production. The Fount’s inter-species trading is much larger than Regalia, as the capital is more concerned with military defense.
Daily Life:
There is a variety of jobs Fount inhabitants work as, ranging from fishermen to palace guards, Waterway explorer to simple farmer. Most people are employed in some sense, and the few who aren’t receive benefits from the government. People generally work for 7 hours a day, and the rest of the time is devoted to leisure. Residents have access to a wide variety of recreational activities and centres, swimming being most popular. Almost everyone is able to swim to some extent, and water aid training is mandatory for children. Education is also mandatory for children below sixteen, although there are many further education opportunities after that.
Final Notes:
This document is only an outline of the Fount, various documents in the Regalian library will provide more specific and detailed information about the events and places discussed within this document. For further reading see:
“The Fount: a conclusive history” by Lathor Frej
“Civil Strife: the truth about the Fount and Regalia” by Destho Lok
The Fount’s official history, compiled from multiple sources and on display at the palace.
If you have noticed any mistakes in this document please submit a ticket at the library’s service office.
#gregor#Gregor the Overlander#tuc#the underland chronicles#ares#the fount#luxa#ripred#vikus#regalia#underland#ares appreciation day#please reblog#im being held against my will#save me
37 notes
·
View notes
Text
[Image Description: The first image is of a tweet made by Kilderkin. It reads, “if you can retweet this I’d really appreciate that. Celebrity deaths like Chadwick Boseman’s tend to be followed by a spike in the number of suicides. If you’re feeling suicidal, the US suicide hotline is 1-800-273-8255. Reach out to your friends, especially your black friends.”
The following images are lists of suicide hotlines:
Argentina: 54-0223-493-0430
Australia: 01-713-3374
Barbados: 429-9999
Belgium: 106
Botswana: 3911270
Brazil: 21-233-9191
Canada: 519-416-486-2242
Alberta: 1-888-787-2880
British Columbia: 1-866-872-0113
Quebec: 5-14-723-4000
China: 852-238-20000
Costa Rica: 5-06-253-5439
Croatia: 01-4833-888
Cyprus: 357-77-77-72-67
Denmark: 70-201-201
Egypt: 7621602
France: 01-45-39-4000
Italy: 06-705-4444
Japan: 3-5286-9090
Mexico: 5-25-510-2550
Netherlands: 0900-0767
New Zealand: 4-473-973
Norway: 47-815-33-300
New Guinea: 675-326-00
Philippines: 02-896-9191
Poland: 52-70-000
Russia: 8-20-222-82-10
Spain: 91-459-00-50
United Kingdom: 0800-068-4141
United States: 1-800-784-8433, 1-800-784-2433, 1-800-273-8255
And another list:
Albania: 127
Algeria: 0021 3983 2000 58
Argentina: (54-11) 4758-2554
Armenia: (2) 538194 / (2) 538197
Australia: 13 11 14
Austria (1): 147
Austria (2): 017133374
Bahamas (1): 328-0922
Bahamas (2): 322-4999
Bahrain (1): 0097 161 199 188
Bahrain (2): 0097 161 199 260
Bahrain (3): 0097 161 199 191
Bahrain (4): 0097 161 199 334
Bangladesh: 01985275286
Barbados: (246) 4299999
Belgium: 106
Bolivia: (00 591 4) 4 25 42 42
Botswana: 3911270
Brazil: +55 51 211 2888
Bulgaria: 0035 9249 17 223
Canada - Alberta: 1-888-787-2880
Canada - Greater Vancouver: 604-872-3311
Canada - Howe Sound/ Sunshine Coast: 18666613311
Canada - TTY: 1-866-872-0113
Canada - BC-wide: 1-800-SUICIDE(784-2433)
Canada - Quebec: 5-14-723-4000
Chile: (00 56 42) 22 12 00
China: 0800-810-1117
China (Mobile/IP/Extension users): 010-8295-1332
Colombia (Barranquilla): (00 57 5) 372 27 27
Colombia (Bogota): (57-1) 323 24 25
Colombia (Medellin): (00 57 4) 284 66 00
Colombia (San Juan de Pasto): 3016326701
Costa Rica: 5-06-253-5439
Croatia: (01) 4833-888
Cuba: 532 348 14 49
Cyprus: +357 77 77 72 67
Czech Republic (Modrá Linka): +420 549241010
Czech Republic (Linka bezpečí): 116 111
Czech Republic (Prague): 004 202 460 80 718
Denmark: +45 70 201 201
Dominica: 333
Ecuador: 593 2 6000 477
Egypt: 7621602
El Salvador: 132
Estonia (1): 126
Estonia (2): 127
Estonia (3): 646 6666
Fiji (1): 679 670565
Fiji (2) 679 674364
Finland: 01019-0071
France: (+33) (0)9 51 11 61 30
Gambia: 117
Germany (1): 0800 1110 111
Germany (2): 0800 1110 222
Germany (Youth): 0800 1110 333
Ghana: 233 244 846 701
Greece: (0) 30 210 34 71 164
Guatemala: 502-254-1259
Guinea: 122
Guyana: (+592) 223-0001
Haiti: 114
Honduras: 504-237-3623
Hongkong: 2389 2222
Hungary: (46) 323 888
Iceland: +91 33 2474 4704
Indonesia: 500-454
Iran: 00989127181037
Iraq: 112
India: 2549 7777
Ireland (1): +44 (0) 8457 90 90 90
Ireland (2): +44 (0) 8457 90 91 92
Ireland (3): 1850 60 90 90
Ireland (4): 1850 60 90 91
Israel: 1201
Italy: 06-705-4444
Jamaica: 1-888-429-KARE (5273)
Japan: 3-5286-9090
Jordan: 0096 262 508 900
Kenya: 020 2051323
Latvia: 371 67222922
Liberia: 6534308
Lithuania: 116 123
Malaysia: (063) 92850039
Malta: 179
Mexico: 5-25-50-2550
Morocco: 022 382 42 42
Netherlands: 0900-0767
New Zealand: 4-473-973
Nicaragua: 505-268-6171
Norway: 47-815-33-300
New Guinea: 675-326-00
Pakistan: 15 / 115
Papua New Guinea: 675 326 0011
Philippines: 02-896-9191
Poland: 52-70-000
Portugal: (+351) 225 50 60 70
End Image description)
So I’ve never done one of these, but I felt like it was important for this. I’ve double checked all of these, but if you notice a mistake in one of them, please let me know! Also let me know if there’s a better way I could have done this, or of any other kind of problem you notice!
attached are also numbers for worldwide suicide hotlines. please reach out for help if you’re feeling hopeless.
80K notes
·
View notes
Text
Hey guys, mental health is very important, and I want y’all to take care of yourselves, so here’s a list of worldwide suicide hotlines.
Albania 127
Algeria 0021 3983 2000 58
Argentina (054–011) 4758 2554
Australia 1–800–273–8255
Austria 142
Bahamas 328–0922 / 322–4999 /322–2763
Bahrain 0097 161 199 188/ 0097 161 199 260 / 0097 161 199 191 / 0097 161 199 334
Barbados (246) 42 99 999
Belgium 106
Bolivia 00 591 4 4 25 42 42
Bostwana 3911270
Brazil +55 51 211 2888
Canada 514–723–4000
China 0800–810–1117
Colombia (00 57 5) 372 27 27
Costa Rica 506–253–5439
Croatia (01) 4833–888
Cuba 532 348 14 49
Cyprus +357 77 77 72 67
Denmark +45 70 201 20
Ecuador 593 2 6000 477
Eqypt 762 1602/3
Estonia 126 /127
Fiji (0679) 670565
Finland 040–5032199
France +33 951 11 61 30
Germany 0800 1110 222
Ghana 233 244 846 701
Greece 1018
Guatemala 1–800–999–9999
Guyana +592 223–0001, 223–0009, 600–7896, 623–4444
Honduras (00 504) 2558 08 08 /2232–1314
Hong Kong 2389 2222 /2382 0000
Hungary (46) 323 888
India 2549 7777
Iran 1480
Israel 1201
Italy 800 86 00 22
Jamaica 930–1152 / 1–888–429-KARE (5273)
Japan +81 (0) 3 5286 9090
Kenya +254 20 300 0378/205 1323
Latvia 371 67222922
Liberia 06534308 –
Lithuania 8–800 2 8888
Luxembourg 454545
Malaysia (063) 928 500 39
Malta 179
Mauritius 46 48 889
Mexico 525–510–2550
Namibia 61–232–221
Netherlands 0900–113 0 113
New Zealand 0800 543 354
Nicaragua 2311–7361
Norway +47 815 33 300
Papua New Guinea 675 326 0011 (Daytime only)
Peru (00 51 1) 273 8026
Philippines (02) 8969191 /893 7606
Poland 52 70 000 /52 70 988
Portugal (+351) 225 50 60 70
Russia 007 (8202) 577–577
Samoa 32000
Serbia 037 23 025
Singapore 1800 221 4444
South Africa 0861 322 322
South Korea (02) 715 8600
Spain 0145 900 50
Sri Lanka 011 057 2222662
St. Vincent (784) 456 1044
Sudan (249) 11–555–253
Sweden (46) 31 711 2400
Switzerland 143 suicide prevention
Thailand (02) 713–6793
Tonga 23000 /25144
Trinidad & Tobago (868) 645 2800
Turkey 182
UK & Ireland +44 8457 90 90 90
Ukraine 058
USA 1–800–273-TALK(8255)
United States Crisis Text Line If you are immediately concerned about yourself or a friend, reach out for help: TEXT: 741741 http://www.crisistextline.org/
Venezuela 0241–8433308
Zimbabwe (9) 650 00
9 notes
·
View notes
Text
Girl you are NOT being subtle about it
She just likes lookin' at the goods [her entire husband]
#livastia#livastia universe#lai#robots#mai#livastian military ai#livastian ai#character#mhina freling#aristophanes 0001 0#aristophanes freling#aristophanes unit 0001 0#digital art#sketch#art#artists on tumblr
14 notes
·
View notes
Text
Mun here. If you’re having thoughts like my muse, then know that your life is worth living for. You are more than enough. It’s okay to not be okay. Talk to someone about how you’re feeling. Whether it be a total stranger on the internet, a counselor at your school, a significant other, a friend, a family member, talk to someone about your feelings. And if all else fails, there are hotlines for you to call.
Albania 127
Algeria 0021 3983 2000 58
Argentina (054–011) 4758 2554
Australia 1–800–273–8255
Austria 142
Bahamas 328–0922 / 322–4999 /322–2763
Bahrain 0097 161 199 188/ 0097 161 199 260 / 0097 161 199 191 / 0097 161 199 334
Barbados (246) 42 99 999
Belgium 106
Bolivia 00 591 4 4 25 42 42
Bostwana 3911270
Brazil +55 51 211 2888
Canada 514–723–4000
China 0800–810–1117
Colombia (00 57 5) 372 27 27
Costa Rica 506–253–5439
Croatia (01) 4833–888
Cuba 532 348 14 49
Cyprus +357 77 77 72 67
Denmark +45 70 201 20
Ecuador 593 2 6000 477
Eqypt 762 1602/3
Estonia 126 /127
Fiji (0679) 670565
Finland 040–5032199
France +33 951 11 61 30
Germany 0800 1110 222
Ghana 233 244 846 701
Greece 1018
Guatemala 1–800–999–9999
Guyana +592 223–0001, 223–0009, 600–7896, 623–4444
Honduras (00 504) 2558 08 08 /2232–1314
Hong Kong 2389 2222 /2382 0000
Hungary (46) 323 888
India 2549 7777
Iran 1480
Israel 1201
Italy 800 86 00 22
Jamaica 930–1152 / 1–888–429-KARE (5273)
Japan +81 (0) 3 5286 9090
Kenya +254 20 300 0378/205 1323
Latvia 371 67222922
Liberia 06534308 –
Lithuania 8–800 2 8888
Luxembourg 454545
Malaysia (063) 928 500 39
Malta 179
Mauritius 46 48 889
Mexico 525–510–2550
Namibia 61–232–221
Netherlands 0900–113 0 113
New Zealand 0800 543 354
Nicaragua 2311–7361
Norway +47 815 33 300
Papua New Guinea 675 326 0011 (Daytime only)
Peru (00 51 1) 273 8026
Philippines (02) 8969191 /893 7606
Poland 52 70 000 /52 70 988
Portugal (+351) 225 50 60 70
Russia 007 (8202) 577–577
Samoa 32000
Serbia 037 23 025
Singapore 1800 221 4444
South Africa 0861 322 322
South Korea (02) 715 8600
Spain 0145 900 50
Sri Lanka 011 057 2222662
St. Vincent (784) 456 1044
Sudan (249) 11–555–253
Sweden (46) 31 711 2400
Switzerland 143 suicide prevention
Thailand (02) 713–6793
Tonga 23000 /25144
Trinidad & Tobago (868) 645 2800
Turkey 182
UK & Ireland +44 8457 90 90 90
Ukraine 058
USA 1–800–273-TALK(8255)
United States Crisis Text Line If you are immediately concerned about yourself or a friend, reach out for help: TEXT: 741741 http://www.crisistextline.org/
Venezuela 0241–8433308
Zimbabwe (9) 650 00
#world mental health day#tw: suicide#cw: suicide#tw: suicidal thoughts#cw: suicidal thoughts#Out of character
4 notes
·
View notes
Text
International Suicide Prevention Hotlines
New Post has been published on https://www.bandbacktogether.com/international-suicide-prevention-hotlines/
International Suicide Prevention Hotlines
Please also see: Suicide Prevention Resources and Coping With The Aftermath of Suicide.
Algeria:
34342 and 43 are the national emergency numbers for police and ambulances in Algeria.
Suicide Hotline Algeria: 0021 3983 2000 58
Argentina:
911 is the national emergency number in Argentina.
Centro de Atencíon al Familiar del Suicida (http://www.familiardesuicida.com.ar/) is made up of professionals and focuses on the problems caused by suicide, both in the community and in the people it can impact. Their number is (54-11) 4758-2554.
SOS Un Amigo Anonimo (http://www.sosunamigoanonimo.com.ar/) is available seven days a week from 10 am to 7pm by calling 4783-8888.
Armenia:
112 and 911 are the national emergency numbers in Armenia.
Trust Social Work and Sociological Research Centre: can be reached at (2) 538194 or (2) 538197
Australia:
000 is the national emergency number in Australia.
Lifeline (https://www.lifeline.org.au/) is a 24-hour nationwide service that provides access to crisis support, suicide prevention and mental health support services.[4] It can be reached at 13 11 14. They also offer an online chat service.
Kids Helpline (https://kidshelpline.com.au/) is a 24-hour nationwide service that provides access to crisis support, suicide prevention and counselling services for Australians aged 5–25. It can be reached at 1800 55 1800. In addition the Kids Helpline does also provide online chat services.
Beyond Blue (https://www.beyondblue.org.au) provides nationwide information and support regarding anxiety, depression, and suicide. It has a helpline which can be reached by calling 1300 22 4636. The helpline is available 24 hours a day, 7 days a week. In addition, the organization also provides online chat from 15-24.
Austria
112 is the national emergency number in Austria.
142 is the number of Telefonseelsorge (http://www.telefonseelsorge.at/) in Austria. Free of charge, operating 24 hours a day.
147 is the number of Rat auf Draht (https://www.rataufdraht.at/), a crisis number especially for children, juveniles and their attachment figures. Free of charge, operating 24 hours a day.
The Bahamas:
911 is the national emergency number in The Bahamas.
National Suicide Hotline: 322-2763
Bangladesh:
999 is the national emergency number in Bangladesh. 199 is the national number for ambulance and fire.
Kaan Pete Roi (http://shuni.org/) is an emotional support helpline in Bangladesh whose mission is to alleviate feelings of despair, isolation, distress, and suicidal feelings among members of the community, through confidential listening. The helpline is intended for suicide prevention and the promotion of mental health.
Barbados:
911 is the national emergency number in Barbados.
Samaritans of Barbados: (246) 4299999
Belgium:
112 is the national emergency number in Belgium.
Stichting Zelfmoordlijn 1813 (https://www.zelfmoord1813.be) provides a 24/7 national suicide prevention phone line and a webchat everyday from 18:30 to 22:00 for Dutch language.
Zelfmoordlijn 1813 limited webchat can be found at https://www.zelfmoord1813.be/chat-met-zelfmoordlijn-1813.
Stichting Centre de Prévention du Suicide (https://www.preventionsuicide.be/fr/) provides a 24/7 national suicide prevention phone line for French language.
The Center for the Prevention of Suicide website and Forum can be found at https://www.preventionsuicide.be/fr/j-ai-besoin-d-aide.html
Bolivia:
911 is the national emergency number in Bolivia.
Teléfono de la Esperanza (http://www.telefonodelaesperanza.org/) aims at promoting mental health to the Spanish and Portuguese-speaking world. Bolivians living in Cochabamba and La Paz can call (00 591 4) 4 25 42 42 and 75288084.
Botswana:
911 is the national emergency number in Botswana.
3911270 is the national lifeline.
Brazil:
188 is a national emergency number in Brazil.
190 and 191 are the national emergency numbers for police and ambulances in Brazil.
Centro de Valorização da Vida (http://www.cvv.org.br/) is an emotional and suicidal prevention support NGO founded in 1962 in São Paulo, Brazil, and recognized as Federal Public Utility in 1973. It offers voluntary and free support, with all communications being confidential. Contacts can be made through the phone number 141 (available 24/7), personally (in one of the 72 centres around the country), chat (via their website), VoIP (via Skype) and e-mail.
Bulgaria:
112 is the national emergency number in Bulgaria.
0035 9249 17 223 is the number for the Sofia Hotline.
Canada:
911 is the national emergency number in Canada.
Kids Help Phone (http://org.kidshelpphone.ca/) is a nationwide 24-hour, toll-free, confidential crisis line and counseling service available to Canadians under the age of twenty.
Crisis Services Canada (http://www.crisisservicescanada.ca/) nation wide suicide prevention and support network.
Crisis Text Line (crisistextline.ca), a 24/7 nationwide crisis-intervention text-message hotline created in partnership with Kids Help Phone.
The Crisis Text Line can be reached by texting HOME to 686-868.
Trans Lifeline (http://www.translifeline.org/) is a toll-free crisis hotline available in the United States and in Canada for transgender people staffed by transgender people.
China:
110 is the national emergency number in mainland China.
Beijing Suicide Research and Prevention Center (http://www.crisis.org.cn), a World Health Organization Collaborating Centre for Research and Training in Suicide Prevention, available 24/7 at 800-810-1117 (for landline callers) or 010-8295-1332 (for mobile and VoIP callers)
Lifeline Shanghai (https://www.lifeline-shanghai.com/) available 10am to 10pm every day at 021-6279-8990
Shanghai Mental Health Center (http://www.smhc.org.cn) serves as a mental health clinic as well as teaching, researching and planning mental health prevention throughout China. They can be reached at 021-64387250.
Shenzhen Mental Health Center (http://www.psyonline.com.cn/) free professional counseling available 24/7 at 0755-25629459
Guangzhou Crisis Research and Intervention Center (http://www.gzcrisis.com/) available 24/7 at 020-81899120 or 020-12320-5, online counseling is also available with QQ messenger at 1661042151
Mental Health Center of School of Medicine of Zhejiang University (http://www.hz7hospital.com/) available 24/7 at 0571-85029595
Croatia:
112 is the national emergency number in Croatia.
Plavi Telefon (http://www.plavi-telefon.hr) can be called at 48 33 888 and aim to provide support for issues such as depression, alcoholism, drug abuse and suicide that traditional centers might not accomplish.
Cyprus:
112 and 199 are the national emergency numbers in Cyprus.
Cyprus Samaritans (http://www.cyprussamaritans.org) is available every day from 4pm to 12am and is confidential. They can be reached at 8000 7773.
Czech Republic:
112 is the national emergency number in the Czech Republic.
Modrá linka (http://www.modralinka.cz/) is a line of trust not only for children and youth. They provide a phone support at +420608902410 from 9AM to 9PM and a chat.
Denmark:
Livslinien (https://www.livslinien.dk) offers telephone support 11am-4am on 70 201 201, or online chat
112 is the national emergency number in Denmark.
Egypt:
122 is the national emergency number in Egypt.
126 is the foreigners emergency number in Egypt.
Estonia:
112 is the national emergency number in Estonia.
Eluliin (http://www.eluliin.ee/) provides emotional support for those suffering from depression and relationship issues. They’re available from 7pm to 7am at 655 8088 in Estonian and 655 5688 in Russian.
Fiji:
917 is the national emergency number in Fiji.
Lifeline Fiji runs the National Crisis Line, Crisis Support, and Suicide Intervention line. Free calls at any time on 132454
Finland:
112 is the national emergency number in Finland.
Finnish Association for Mental Health has provided assistance and support for those dealing with mental health issues and suicide since 1897. They can be reached at 010 195 202 (Finnish) or (09) 4135 0501 (foreigners).
France:
112 is the national emergency number in France, 15 is the number for ambulances, 114 for all emergency services for deaf using FAX or SMS and 17 is for police.
Fil santé jeunes : 0800 235 236 : anonymous and toll-free number for young people.
Suicide écoute : 01 45 39 40 00 (24-hour) : suicide prevention helpline (volunteers).
SOS Suicide Phénix: 01 40 44 46 45 (schedule) : suicide prevention through listening and hospitality (volunteers).
Sos amitié : distress listening on multimedia platform : phone, email, chat (volunteers).
La Croix Rouge Ecoute : 0 800 858 858 : psychological support online, anonymous and free (volunteers).
Germany:
112 is the national emergency number in Germany.
Telefonseelsorge (http://www.telefonseelsorge.de/) (24/7, no cost): 0800 111 0 111 (Protestant), 0800 111 0 222 (Catholic), 0800 111 0 333 (for children and youth)
Ghana:
999 is the national emergency number in Ghana.
National Lifeline: 2332 444 71279
Greece:
1018 (http://suicide-help.gr) is the national emergency number in Greece, 166 is the number for ambulances, 199 for the fire department, 100 is for police.
Guyana:
999 is the national emergency number in Guyana.
Inter-agency Suicide Prevention Help Line (http://guyanapoliceforce.gy/police/policing-menu/community-outreach-programs/launching-of-inter-agency-suicide-prevention-help-line) was launched by the Guyana Police Force in 2015 to help those struggling with depression. They can be reached 24 hours a day by calling 223-0001, 223-0009, or 223-0818, as well as 600-7896 or 623-4444 by cellphone.
Hong Kong:
999 is the national emergency number in Hong Kong.
The Samaritans Hong Kong (https://samaritans.org.hk) is available 24/7 by calling 2896 0000.
The Samaritan Befrienders Hong Kong is available 24/7 at 23892222.
Hungary:
112 is the national emergency number for Hungary. 104 is the national number for ambulances and 107 is for police
Blue line (http://www.sos116-123.hu/index.php/segelykeres) – 116-123 is a nationwide 24-hour hotline – [email protected] is an email address to use. Helpline providing emotional support for those who are stressed, distressed, depressed, or suicidal.
Help line: (http://www.kek-vonal.hu/index.php/hu/lelkisegely-vonal) – 116-111 is a helpline providing emotional support for those who are stressed, distressed, depressed, or suicidal.
India:
112 is the national emergency number for India.
Samaritans Mumbai: (smaritaansmumbai.com) – +91 8422984528, +91 8422984529, +91 8422984530 – 3 pm to 9 pm, all days. [email protected]. Helpline providing emotional support for those who are stressed, distressed, depressed, or suicidal.
AASRA (http://www.aasra.info/): 91-22-27546669 is a 24-hours a day, 7 days a week nationwide voluntary, professional and confidential services.
Sneha India (http://www.snehaindia.org) is available 24/7 on the phone by calling 91 44 24640050.
Indonesia:
112 is the national emergency number for Indonesia.
Kementerian Kesehatan: 500-454
Iran:
110 and 115 are the national emergency numbers for police and ambulances in Iran.
Iran Organization of Well Being (http://moshaver.behzisti.ir/page.aspx?id=1480) has provided the free and governmental hotline, 1480, by which the specialists give different types of consultations for a variety of problems such as marriage, family, youths and children, suicide,etc. to those in need. this hotline is open
from 6 am till 9 pm everyday and its services are reached from all provinces of Iran.
Ireland:
112 and 999 are the national emergency numbers in Ireland.
Samaritans (http://www.samaritans.org/) is a registered charity aimed at providing emotional support to anyone in distress or at risk of suicide throughout Ireland.
Israel:
100 and 101 are the national emergency numbers for police and ambulances in Israel.
Eran.org.il Suicide line operates 24/7 including holidays and can be reached from all regions of Israel by calling 1201 or 972-9 8891333 from abroad. SMS service is given as well during Sunday – Friday between 14:00-18:00 at 076-88444-00.
Italy:
112 is the national emergency number for Italy.
Servizio per la Prevenzione del Suicidio (SPS) (http://www.prevenireilsuicidio.it/) ) is a suicide prevention helpline whose mission is to give psychological and emotional support to anyone in suicidal crisis or to anyone who lost a dear one for suicide, through a confidential listening from an equipe of doctors, psychologists and volunteers . The helpline is operating from 9.30 am till 4.30 pm, from Monday to Friday, and it can be reached from all regions of Italy.
Samaritans – ONLUS (http://www.samaritansonlus.org) is available every day from 1pm to 10pm by calling 800 86 00 22 or 06 77208977.
Telefono Amico (http://www.telefonoamico.it) provides services everyday from 10am to 12am by calling 199284284.
Japan:
110 and 119 are the national emergency numbers for police and ambulances in Japan.
TELL (http://telljp.com/lifeline/) provides a free, confidential English-language Lifeline service, plus clinical mental health services, for the international community in Japan.[7]
Befrienders Worldwide Osaka Suicide Prevent Center (http://www.spc-osaka.org)
Jordan:
911 is the national emergency number in Jordan.
110 for Families & Children (https://www.jordanriver.jo/en/programs/protecting-children/110-families-children) The Helpline offers services in psychological support and consultation, as well as referrals. The initiative aims to alleviate the effect of risk factors children in vulnerable families are exposed to, including families facing challenges impairing their parenting, as well as abuse cases
South Korea:
112 and 119 are the national emergency numbers for police and ambulances in South Korea.
Love-Line (Sarang – Jonwha) Counselling Centre Shingongduk-dong 9-22 Mapo-gu SEOUL 24 hours a day.
Hotline: (2) 715 8600
Hotline: (2) 716 8600
Hotline: (2) 717 8600
Hotline: (2) 718 8600
Cheju 159 Ildo 2-dong CHEJU Contact by: – Phone Hotline: (064) 52 9191
Choongju 178-5 Sungnae-dong
Choongju 380-010 CHOONGBUK Contact by: – Phone Hotline: (0441) 847-9191
Chunju 560-600 CHUNBUK Contact by: – Phone Hotline: (0652) 86-9191
INCHON Hotline: (032) 421 9191
Puchon 2nd 105-7 Wonmi-dong, Wonmi-Ku Puchon 420-110
KYUMGKIDO Contact by: – Phone Hotline: (032) 663-9191
Pohang 414-15 Nambin-dong Buk-Ku
Pohang 791-040
KYUNGBUK Contact by: – Phone Hotline: (0562) 72-9191
Koyang Hyungjae Bld 499-2 Sungsa-dong Duchyang-Ku
Koyang 411-020 KYUNGKIDO Contact by: – Phone Hotline: (0344) 915-9191
Kimhae 305-20 Suhsang-dong Kimhae 621-030 KYUNGNAM Contact by: – Phone Hotline: (0525) 21-9191
Ulsan 627-20 Sinjung 1-dong, Nam-Ku
Ulsan 680-011 KYUNGNAM Contact by: – Phone Hotline: (0522) 67-9191
Pusan 607-1 Chunpo 4-dong, Pusanjin-Ku 614-044 PUSAN Contact by: – Phone Hotline: (051) 807-9191
Lifeline National Office 607-1 Chunpo 4-dong Pusanjin-Ku 614-044 PUSAN Contact by: – Phone Hotline: (82) 51 804 0896
SEOUL Contact by: – Phone Hotline: (02) 916-9191
TAEGI Contact by: – Phone Hotline: (053) 475-9191 Taejon Kukmin Bank, 4th 1194 Samchon-dong 302-220
TAEJON Contact by: – Phone Hotline: (042) 254-9191
Latvia:
113 is the national emergency number in Latvia.
Skalbes.lv (http://www.skalbes.lv/) You can call them on +371 67222922 or +371 27722292 the lines are working 24h on all week days.
Lebanon:
Suicide Hotline Lebanon (Embrace) : 1564
Embrace LifeLine (http://www.embracelifeline.org/) You can call them on 1564 the lines are working from 12 P.M until 2 A.M on all week days.
Liberia:
Lifeline Liberia: 6534308
Luxembourg:
112 is the national emergency number in Luxembourg.
454545.lu (https://454545.lu/) +352 45 45 45 the lines are working 11h-23h on all week days and 11h-3h on Friday and Saturday.
Malaysia:
999 is the national emergency number in Malaysia.
Befrienders (http://www.befrienders.org.my) offers a 24/7, confidential hotline.
Befrienders hotline can be reached at 03-79568144 or 03-79568145.
Malta:
Appogg Supportline 179
Mauritius:
112 and 114 are the national emergency numbers for police and ambulances in Mauritius.
Befrienders Mauritius (http://www.befrienders.org/directory?country=MU) offer a limited-hour crisis helpline for English and French speakers.
Befrienders Maritius hotline can be reached at 800 93 93 +230 800 93 93 (available from 09:00 to 21:00 daily).
Mexico:
911 is the national emergency number in Mexico.
SAPTEL (http://www.saptel.org.mx/index.html) is an independent care provider subsidized by the Mexican red cross. It can be reached at (55) 5259-8121. SAPTEL has been active since 2000. It is totally free and they are available Monday to Sunday 9:00 to 21:00. Provides crisis dialogue or treatment for anything related to mental health crisis.
Netherlands:
112 is the national emergency number in the Netherlands.
Stichting 113Online (https://www.113.nl/) provides a 24/7 national suicide prevention phone line and webchat.
113Online hotline can be reached at 0900 0113.
113Online Webchat can be found at https://www.113.nl/ik-denk-aan-zelfmoord/crisislijn.
New Zealand:
111 is the national emergency number in New Zealand.
1737, need to talk? (http://www.1737.org.nz) is the national mental health and addictions helpline. Free call or text 1737 any time for support from a trained counsellor.
Lifeline Aotearoa (http://www.lifeline.org.nz) is a New Zealand organisation providing free 24-hour counseling and phone help lines. It provides support, information and resources to people at risk of suicide, family and friends affected by suicide and people supporting someone with suicidal thoughts and/or suicidal behaviours. Call 09 5222 999 if you live within Auckland or 0800 543 354 for those outside of Auckland.
Youthline (https://www.youthline.co.nz) Call 0800 376 633 or text 234.
The Lowdown (https://thelowdown.co.nz) provides assistance in dealing with issues such as relationships, anxiety, and depression and are available by e-mail or texting 5626.
Norway:
112 and 113 is the national emergency numbers for police and ambulances in Norway
Mental Helse Mental Helse (Mental Health). Can be reached at 116 123 and is open 24 hours a day, 7 days a week. Mental Helse does also provide a chat-service at http://sidetmedord.no where users can write messages anonymously and get answers within 48-hours. A chat-service is also provided. It is open Mondays from 19.00 – 22.00 and Wednesdays: from 19.00 – 22.00. The chat-services may not always be open in July and on public celebration days or Sundays.
Kirkens SOS Kirkens SOS(The Church SOS). Can be reached at 22 40 00 40 and is open 24 hours a day, 7 days a week. The line is free to call and confidential. Kirkens SOS does also provide an anonymous message service(which replies within 24-hours) 27 hours a day, 7 days a week and a chat open 7 days a week at 18.30 – 22.30.
The Philippines:
911 is the national emergency number in the Philippines.
The Natasha Goulbourn Foundation (http://www.ngf-hope.org/contact-us/) provides 24/7 assistance to those who call (02) 804-HOPE (4673) or 0917 558 HOPE (4673)
Manila Lifeline Centre: (02) 8969191
Poland:
112 is the national emergency number in Poland.
Olsztynski Telefon Zaufania ‘Anonimowy Przyjaciel (http://telefonzaufania.org/) provides 24/7 assistance as it’s the only unit of this type in Poland. They can be reached by calling 89 19288 or 89 527 00 00.
Portugal:
112 is the national emergency number in Portugal.
Voz de Apoio (http://www.vozdeapoio.pt) is anonymous and confidential. You can speak to them by calling 225 50 60 70 or through Skype, face-to-face, or writing.
Sos Voz Amiga (http://www.sosvozamiga.org) is available daily from 4pm to 12am by calling 213 544 545, 912 802 669, or 963 524 660. Free Green Line callers can call 800 209 899 from 9pm to 12am.
Sos Estudante (http://sosestudante.pt) provides anonymous, confidential support every day from 8pm to 1am by calling 915 246 060, 969 554 545, 239 484 020 as well as through Skype.
Romania:
112 is the national emergency number in Romania.
Alianţa Română de Prevenţie a Suicidului (http://www.antisuicid.com/) is a Romanian support helpline whose mission is to give psychological and emotional support to those that find themselves in depression, those who are in a psychological crisis and those who are suicidal. Help is offered by psychologists and volunteers from Psychology Universities.
Russia:
112 is the national emergency number in Russia.
051 (or 8495051) is a 24 hour emergency number for Moscow residents
Samaritans (Cherepovets): 007 (8202) 577-577
Serbia:
SRCE Novi Sad (http://www.centarsrce.org/): (+381) 21-6623-393
Singapore:
999 and 995 are the national emergency numbers for the police and ambulances in Singapore.
The Samaritans of Singapore (https://sos.org.sg/) is the only 24-hour, toll-free, confidential suicide prevention hotline in Singapore, for anyone having difficulty coping during a crisis, who are thinking of suicide or affected by suicide.”
The Institute of Mental Health (Singapore) also has a 24-hour Mental Health Helpline (https://www.imh.com.sg/contact-us/) if you are facing a mental health crisis or emergency.”
The Singapore Association of Mental Health (http://www.samhealth.org.sg/) is a voluntary welfare organisation that provides a toll-free counselling helpline for those with emotional crisis or mental health conditions”
Slovakia:
IPčko.sk (www.ipcko.sk) – Suicide prevention and psychological help (mainly for youth), providing online chat counseling service from 7am to midnight. IPčko also provides email counseling 24/7 on [email protected].
Slovenia:
112 is the national emergency number in Slovenia.
Zaupni telefon Samarijan in Sopotnik (http://www.telefon-samarijan.si/) is available 24-hours a day, 7-days a week. The purpose of the organisation is to be available for a conversation to anyone suffering from distress. The confidential phone call hotline is carried out in accordance with the fundamental principles of the international organisation IFOTES. Qualified volunteers can be reached on the toll-free telephone number 116 123.
TOM – telefon za otroke in mladostnike (http://www.e-tom.si) is available 7-days a week from 13:00 – 20:00 and is primarily meant for children and adolescents in distress. The telephone functions within the Association of Friends of Youth of Slovenia (ZPMS). It serves the purpose of providing emotional support for children and young people who face various questions, dilemmas or distress during the process of growing up. Advisers are available to callers needing to share their problems or are seeking advice and additional information on the toll-free telephone number 116 111.
Klic v duševni stiski (http://www.psih-klinika.si/koristne-informacije/klic-v-dusevni-stiski/) is available 7-days a week 19:00 – 7:00. Counsellors of the hotline are trained to work with people and especially trained to talk with people who are having suicidal thoughts. However, you can call for help regardless of the cause of your distress. They are available on the telephone number (01) 520-99-00.
Ženska svetovalnica – krizni center (http://www.drustvo-zenska-svetovalnica.si/o-nas) is available 24-hours a day, 7-days a week. It is a voluntary women’s organisation that works in the field of psycho-social assistance and the self-help of women who are victims of violence. They offer free counseling, information on public service competencies and assistance in organizing self-help groups to women in need. They are available on the telephone number +386 31 233 211.
South Africa:
10111 and 10177 are the national emergency numbers for the police and ambulances in South Africa.
The Triangle project (https://triangle.org.za/about/) provides a helpline where lesbian, gay, bisexual, transgender and intersex people can talk to a trained professional. The professional will ensure the callers privacy and can also refer the caller to other support networks. It can be reached at (021) 712 6699 daily from 13:00 to 21:00. The counselor will then call you back.
Spain:
112 is the national emergency number in Spain.
Teléfono de la Esperanza (http://www.telefonodelaesperanza.org) is open 24 hours a day, 7 days a week, allowing callers to discuss a range of challenges from trauma and suicide to relationship issues.They can be reached by calling 717 003 717.
Sri Lanka:
Sri Lanka Sumithrayo – Bandarawela: 011 057 2222662
Saint Vincent and the Grenadines:
The Samaritans, St. Vincent: (784) 456 1044
Sudan:
Befrienders Khartoum: (249) 11-555-253
Sweden:
112 is the national emergency number in Sweden.
Självmordslinjen (Suicide prevention hotline) (https://mind.se/sjalvmordslinjen/) is a registered Non-profit organisation that has worked with mental health since 1931. The organisation provides a 24-hour email, chat and hotline service, all of which are toll-free.
Hjälplinjen (The help line) (https://www.1177.se/Stockholm/Om-1177/Om-Hjalplinjen/) offers temporary psychological support over the phone (toll-free), 7 days a week 13:00 – 22:00. You can opt to be anonymous.[17] The service is run by Sweden’s municipalities through Vårdguiden (the care guide).
BRIS – Barnens rätt i samhället (Children’s right in society) (https://www.bris.se/) is a children’s right organisation. they offer toll-free and anonymous support for all children and young adults up to the age of 18 through phone and chat every day of the year 14:00 – 21:00. BRIS can be reached at 116 111 but also offers contact to curators through email and contact with other youth through their online forum.
Switzerland:
112 is the national emergency number in Switzerland.
Die dargebotene Hand (https://www.143.ch/): 143 (helpline for any kind of life crisis and mental health problems)
Taiwan:
Kaohsiung Life Line: http://www.life1995.org.tw/
Thailand:
Samaritans of Thailand: (02) 713-6793
Tonga:
Lifeline: 23000
Trinidad and Tobago:
Lifeline: (868) 645 2800
Turkey:
Emergency Hotline: 182
United Kingdom:
999 and 112 is the national emergency number in the United Kingdom
111, Option 2, is the National Health Services’ First Response Service for mental health crises and support.
Samaritans (http://www.samaritans.org/) is a registered charity aimed at providing emotional support to anyone in distress or at risk of suicide throughout the United Kingdom.[20] They provide a 24/7, toll-free crisis line, as well as local branches.
Samaritans Helpline can be reached at 116 123.
Samaritans’ previous hotline number, 08457 90 90 90, is no longer in use. Calling this line may result in charges for call forwarding.
Campaign Against Living Miserably (https://www.thecalmzone.net/) is a registered charity based in England. It was launched in March 2006 as a campaign aimed at bringing the suicide rate down among men aged 15–35.[22] It has a limited-hour phone and webchat options.
CALM (Nationwide) can be reached at 58 58 58 0800 58 58 58 (available every day from 5PM to midnight).
CALM (London) can be reached at 802 58 58 0808 802 58 58 (available every day from 5PM to midnight).
CALM webchat can be found at https://www.thecalmzone.net/help/get-help/ (available every day from 5PM to midnight).
United States:
911 is the national emergency number in the United States.
The National Suicide Prevention Lifeline (http://suicidepreventionlifeline.org/) is a 24-hour, toll-free, confidential suicide prevention hotline available to anyone in suicidal crisis or emotional distress. It provides Spanish-speaking counselors, as well as options for deaf and hard of hearing individuals. It is only available in the United States. A 24-hour an Online Chat in partnership with Contact USA is also available.
The National Suicide Prevention Lifeline can be reached at 1-800-273-8255.
The National Suicide Prevention Lifeline (ESP) can be reached at 1-888-628-9454
The National Suicide Prevention Lifeline (Deaf & Hard of Hearing Options) can be reached at 1-800-799-4889
The Veterans Crisis Line (https://www.veteranscrisisline.net/) is a 24-hour, toll-free hotline that provides phone, webchat, and text options available to military veterans and their families. It provides options for deaf and hard of hearing individuals.
The Veterans Crisis Line can be reached at 1-800-273-8255, Press 1.
The Crisis Text Line (crisistextline.org) is the only 24/7, nationwide crisis-intervention text-message hotline.
The Crisis Text Line can be reached by texting HOME to 741-741.
Samaritans USA (http://www.samaritansusa.org/) is a registered charity aimed at providing emotional support to anyone in distress or at risk of suicide throughout the United States.
The Trevor Project (http://www.thetrevorproject.org/) is a nationwide organization that provides a 24-hour phone hotline, as well as limited-hour webchat and text options, for lesbian, gay, bisexual, transgender and questioning youth.
The TrevorLifeline can be reached at 1-866-488-7386.
TrevorChat can be found at https://www.thetrevorproject.org/get-help-now/ (available 7 days a week from 3PM to 10PM ET).
TrevorText can be reached by texting TREVOR to 1-202-304-1200 (available M-F from 3PM to 10PM ET).
The Trans Lifeline (https://www.translifeline.org/) is a nonprofit organization that is created by and for the transgender community, providing crisis intervention hotlines, staffed by transgender individuals, available in the United States and Canada.
The Trans Lifeline can be reached at 1-877-565-8860.
1 note
·
View note
Text
a Basic Linear Regression Model
As always I will repeat this analysis in both python and SAS. I found both equally easy to use this week, although SAS took less commands to get out more information. In both SAS and python, there were special commands that could be use to center the mean. A little bit of internet research was all that was needed.
I will be making 4 regression models
1. polity score by employment rate
2. polity score by female employment rate
3. polty score by male employment rate
4. polity score by gender gap in employment rate
SAS
code
/* get access to course datasets*/
LIBNAME mydata "/courses/d1406ae5ba27fe300 " access=readonly;
/* pick specific data set*/
DATA new; set mydata.gapminder;
/* get the employee rates and democracy scores*/
LABEL femaleemployrate="% Females 15+ Employed 2007"
employrate="% Population 15+ Employed 2007"
polityscore="Polity Democracy Score 2009";
/* add a secondary variable of male employment rate % estimate*/
maleemployrate = employrate * 2 - femaleemployrate;
/* correction for 2 countries who do not have 50/50 split male to female*/
if country = "Qatar" then maleemployrate = ((4*employrate - femaleemployrate)/3);
if country = "United Arab Emirates" then maleemployrate = (3* employrate - femaleemployrate)/2;
/* Label the male employment rate */
LABEL maleemployrate=" Estimate of % Males 15+ Employed 2007" ;
/* create a secondary variable for gap in employment */
gaprate = maleemployrate - femaleemployrate;
/* Label the gap employment rate */
LABEL gaprate= "Gap between of % Males and Females 15+ Employed 2007" ;
/*centre means*/
PROC STANDARD MEAN=0 OUT=xdata;
VAR employrate femaleemployrate maleemployrate gaprate ;
PROC means data = xdata;
Var employrate femaleemployrate maleemployrate gaprate ;
/*linear models*/
PROC GLM data = xdata;model
polityscore=employrate;
PROC GLM data = xdata;model
polityscore=femaleemployrate;
PROC GLM data = xdata;model
polityscore=maleemployrate;
PROC GLM data = xdata;model
polityscore=gaprate;
run;
regression models and analysis
First I centered the 4 explanatory variables that I will use for the 4 models in SAS
As you can see the means are close to 0, whilst the standard deviation is not affected.
polity score by employment rate for the population
The p value of 0.0475 is below 0.05, so there does appear to be an association between the % population employed and the polity democracy score. The r-square says the % population employed explains 2.5% of the variation of the polity score. So it is a small association.
For every 1% increase in employment, the polity score goes down by 0.097. The regression euqation is polityscore = 3.711 - 0.097* (% population employment- mean of % population emplyoment)
polity score by female employment rate
The p value of 0.499 is above 0.05, so there does not appear to be an association between the % female employed and the polity democracy score.
polity score by male employment rate
The p value of <.0001 is below 0.05, so there does appear to be an association between the % males employed and the polity democracy score. The r-square says the % males employed explains 11.4% of the variation of the polity score. So it is a small association.
For every 1% increase in male employment, the polity score goes down by 0.207. The regression euqation is polityscore = 3.833 - 0.207* (% male employment- mean of % male emplyoment)
polity score by gender gap in employment rate
The p value of 0.0004 is below 0.05, so there does appear to be an association between the % gender employment gap and the polity democracy score. The r-square says the % gender employment gap explains 7.7% of the variation of the polity score. So it is a small association.
For every 1% increase in gender employment gap, the polity score goes down by 0.115. The regression euqation is polityscore = 3.687 - 0.115* (% gender employment gap- mean of % gender employment gap)
python
The analysis for python is the same as SAS, as the results are the same.
code
""
Script to load in gapminder data and
group explainatory variables into quartiles
create a new binary variable for democractic, undemocratic
male employment rates are estimated and gap in rate is computed
explores the relationship between democracy and employment
correlation coefficient analysis
"""
# load libraries
import pandas as pd
import statsmodels.formula.api as smf
from sklearn.preprocessing import scale
# load data
data = pd.read_csv(
'D:/Users/jesnr/Dropbox/coursera/data management and visualization/gapminder data.csv', low_memory=(False))
# toprevent runtime errors
#pd.set_option('display.float_format', lambda x: '%f'%x)
# change data to numeric
data['femaleemployrate'] = pd.to_numeric(
data['femaleemployrate'], errors='coerce')
data['employrate'] = pd.to_numeric(data['employrate'], errors='coerce')
data['polityscore'] = pd.to_numeric(data['polityscore'], errors='coerce')
# add in secondary variables
# estimate male employment rate
maleemployrate = []
for i, rate in enumerate(data['employrate']):
if data['country'][i] == "Qatar":
maleemployrate.append(((4*rate - data['femaleemployrate'][i])/3))
elif (data['country'][i] == "United Arab Emirates"):
maleemployrate.append((3 * rate - data['femaleemployrate'][i])/2)
else:
maleemployrate.append(rate * 2 - data['femaleemployrate'][i])
data['maleemployrate'] = maleemployrate
# determine employment gap:
employgap = []
for i, rate in enumerate(data['maleemployrate']):
employgap.append(rate - data['femaleemployrate'][i])
data['employgap'] = employgap
# make corrections for Qatar and UAE
data.loc[data['country'] == 'Qatar']['maleemployrate'] = (
4 * data.loc[data['country'] == 'Qatar']['employrate'] - 3 * data.loc[data['country'] == 'Qatar']['femaleemployrate'])
data.loc[data['country'] == 'United Arab Emirates']['maleemployrate'] = (
4 * data.loc[data['country'] == 'United Arab Emirates']['employrate'] - 3 * data.loc[data['country'] == 'United Arab Emirates']['femaleemployrate'])
# get rid of the nan's
data =data.dropna(subset = ['polityscore', 'employrate'])
# centre the explanatory variables
data['xemployrate'] = scale(data['employrate'],with_std=False)
data['xfemaleemployrate'] = scale(data['femaleemployrate'],with_std=False)
data['xmaleemployrate'] = scale(data['maleemployrate'],with_std=False)
data['xemploygap'] = scale(data['employgap'],with_std=False)
print("means")
print(data.mean())
print()
print("standard deviations")
print(data.std())
print()
print('OLS regression model for the association between rate of employment and polity score')
modelemploy = smf.ols(formula='polityscore~xemployrate',data=data).fit()
print(modelemploy.summary())
print()
print('OLS regression model for the association between rate of female employment and polity score')
modelemploy = smf.ols(formula='polityscore~xfemaleemployrate',data=data).fit()
print(modelemploy.summary())
print()
print('OLS regression model for the association between rate of male employment and polity score')
modelemploy = smf.ols(formula='polityscore~xmaleemployrate',data=data).fit()
print(modelemploy.summary())
print()
print('OLS regression model for the association between the gap in gender employment rate and polity score')
modelemploy = smf.ols(formula='polityscore~xemploygap',data=data).fit()
print(modelemploy.summary())
print()
regression models and analysis
First I centered the 4 explanatory variables that I will use for the 4 models in python
As you can see the means are close to 0, whilst the standard deviation is not affected.
polity score by employment rate for the population
The p value of 0.0475 is below 0.05, so there does appear to be an association between the % population employed and the polity democracy score. The r-square says the % population employed explains 2.5% of the variation of the polity score. So it is a small association.
For every 1% increase in employment, the polity score goes down by 0.0975. The regression euqation is polityscore = 3.64 - 0.0975* (% population employment- mean of % population emplyoment)
polity score by female employment rate
The p value of 0.4572 is above 0.05, so there does not appear to be an association between the % female employed and the polity democracy score.
polity score by male employment rate
The p value of <.0001 is below 0.05, so there does appear to be an association between the % males employed and the polity democracy score. The r-square says the % males employed explains 11.4% of the variation of the polity score. So it is a small association.
For every 1% increase in male employment, the polity score goes down by 0.207. The regression euqation is polityscore = 3.64 - 0.207* (% male employment- mean of % male emplyoment)
polity score by gender gap in employment rate
The p value of 0.0004 is below 0.05, so there does appear to be an association between the % gender employment gap and the polity democracy score. The r-square says the % gender employment gap explains 7.7% of the variation of the polity score. So it is a small association.
For every 1% increase in gender employment gap, the polity score goes down by 0.115. The regression euqation is polityscore = 3.639 - 0.115* (% gender employment gap- mean of % gender employment gap)
0 notes
Text
Speaking of Aristophanes in my previous post, I finally got around to writing the next chapter of Unit Number one - took me long enough!
#livastia#livastia universe#robots#lai#livastian military ai#mai#world anvil#livastian ai#lore#character#unit number one#writing#aristophanes 0001 0#aristophanes freling#tg1-0001-0
7 notes
·
View notes
Text
World wide suicide hotlines
There’s no shame in needing help. If you or a friend are thinking about suicide, please don’t. There are hotlines you can call. Your life is worth living for, I promise.
Talk to someone
Albania 127
Algeria 0021 3983 2000 58
Argentina (054–011) 4758 2554
Australia 1–800–273–8255
Austria 142
Bahamas 328–0922 / 322–4999 /322–2763
Bahrain 0097 161 199 188/ 0097 161 199 260 / 0097 161 199 191 / 0097 161 199 334
Barbados (246) 42 99 999
Belgium 106
Bolivia 00 591 4 4 25 42 42
Bostwana 3911270
Brazil +55 51 211 2888
Canada 514–723–4000
China 0800–810–1117
Colombia (00 57 5) 372 27 27
Costa Rica 506–253–5439
Croatia (01) 4833–888
Cuba 532 348 14 49
Cyprus +357 77 77 72 67
Denmark +45 70 201 20
Ecuador 593 2 6000 477
Eqypt 762 1602/3
Estonia 126 /127
Fiji (0679) 670565
Finland 040–5032199
France +33 951 11 61 30
Germany 0800 1110 222
Ghana 233 244 846 701
Greece 1018
Guatemala 1–800–999–9999
Guyana +592 223–0001, 223–0009, 600–7896, 623–4444
Honduras (00 504) 2558 08 08 /2232–1314
Hong Kong 2389 2222 /2382 0000
Hungary (46) 323 888
India 2549 7777
Iran 1480
Israel 1201
Italy 800 86 00 22
Jamaica 930–1152 / 1–888–429-KARE (5273)
Japan +81 (0) 3 5286 9090
Kenya +254 20 300 0378/205 1323
Latvia 371 67222922
Liberia 06534308 –
Lithuania 8–800 2 8888
Luxembourg 454545
Malaysia (063) 928 500 39
Malta 179
Mauritius 46 48 889
Mexico 525–510–2550
Namibia 61–232–221
Netherlands 0900–113 0 113
New Zealand 0800 543 354
Nicaragua 2311–7361
Norway +47 815 33 300
Papua New Guinea 675 326 0011 (Daytime only)
Peru (00 51 1) 273 8026
Philippines (02) 8969191 /893 7606
Poland 52 70 000 /52 70 988
Portugal (+351) 225 50 60 70
Russia 007 (8202) 577–577
Samoa 32000
Serbia 037 23 025
Singapore 1800 221 4444
South Africa 0861 322 322
South Korea (02) 715 8600
Spain 0145 900 50
Sri Lanka 011 057 2222662
St. Vincent (784) 456 1044
Sudan (249) 11–555–253
Sweden (46) 31 711 2400
Switzerland 143 suicide prevention
Thailand (02) 713–6793
Tonga 23000 /25144
Trinidad & Tobago (868) 645 2800
Turkey 182
UK & Ireland +44 8457 90 90 90
Ukraine 058
USA 1–800–273-TALK(8255)
United States Crisis Text Line If you are immediately concerned about yourself or a friend, reach out for help: TEXT: 741741
crisistextline[dot]org
Venezuela 0241–8433308
Zimbabwe (9) 650 00
1 note
·
View note
Text
Using Absolute Value, Sign, Rounding and Modulo in CSS Today
For quite a while now, the CSS spec has included a lot of really useful mathematical functions, such as trigonometric functions (sin(), cos(), tan(), asin(), acos(), atan(), atan2()), exponential functions (pow(), exp(), sqrt(), log(), hypot()), sign-related functions (abs(), sign()) and stepped value functions (round(), mod(), rem()).
However, these are not yet implemented in any browser, so this article is going to show how, using CSS features we already have, we can compute the values that abs(), sign(), round() and mod() should return. And then we’ll see what cool things this allows us to build today.
A few of the things these functions allow us to make.
Note that none of these techniques were ever meant to work in browsers from back in the days when dinosaurs roamed the internet. Some of them even depend on the browser supporting the ability to register custom properties (using @property), which means they’re limited to Chromium for now.
The computed equivalents
--abs
We can get this by using the new CSS max() function, which is already implemented in the current versions of all major browsers.
Let’s say we have a custom property, --a. We don’t know whether this is positive or negative and we want to get its absolute value. We do this by picking the maximum between this value and its additive inverse:
--abs: max(var(--a), -1*var(--a));
If --a is positive, this means it’s greater than zero, and multiplying it with -1 gives us a negative number, which is always smaller than zero. That, in turn, is always smaller than the positive --a, so the result returned by max() is equal to var(--a).
If --a is negative, this means it’s smaller than zero, and that multiplying it by -1 gives us a positive number, which is always bigger than zero, which, in turn, is always bigger than the negative --a. So, the result returned by max() is equal to -1*var(--a).
--sign
This is something we can get using the previous section as the sign of a number is that number divided by its absolute value:
--abs: max(var(--a), -1*var(--a)); --sign: calc(var(--a)/var(--abs));
A very important thing to note here is that this only works if --a is unitless, as we cannot divide by a number with a unit inside calc().
Also, if --a is 0, this solution works only if we register --sign (this is only supported in Chromium browsers at this point) with an initial-value of 0:
@property --sign { syntax: '<integer>'; initial-value: 0; inherits: false /* or true depending on context */ }
This is because --a, being 0, also makes --abs compute to 0 — and dividing by 0 is invalid in CSS calc() — so we need to make sure --sign gets reset to 0 in this situation. Keep in mind that this does not happen if we simply set it to 0 in the CSS prior to setting it to the calc() value and we don’t register it:
--abs: max(var(--a), -1*var(--a)); --sign: 0; /* doesn't help */ --sign: calc(var(--a)/var(--abs));
In practice, I’ve also often used the following version for integers:
--sign: clamp(-1, var(--a), 1);
Here, we’re using a clamp() function. This takes three arguments: a minimum allowed value -1, a preferred value var(--a) and a maximum allowed value, 1. The value returned is the preferred value as long as it’s between the lower and upper bounds and the limit that gets exceeded otherwise.
If --a is a negative integer, this means it’s smaller or equal to -1, the lower bound (or the minimum allowed value) of our clamp() function, so the value returned is -1. If it’s a positive integer, this means it’s greater or equal to 1, the upper bound (or the maximum allowed value) of the clamp() function, so the value returned is 1. And finally, if --a is 0, it’s between the lower and upper limits, so the function returns its value (0 in this case).
This method has the advantage of being simpler without requiring Houdini support. That said, note that it only works for unitless values (comparing a length or an angle value with integers like ±1 is like comparing apples and oranges — it doesn’t work!) that are either exactly 0 or at least as big as 1 in absolute value. For a subunitary value, like -.05, our method above fails, as the value returned is -.05, not -1!
My first thought was that we can extend this technique to subunitary values by introducing a limit value that’s smaller than the smallest non-zero value we know --a can possibly take. For example, let’s say our limit is .000001 — this would allow us to correctly get -1 as the sign for -.05, and 1 as the sign for .0001!
--lim: .000001; --sign: clamp(-1*var(--lim), var(--a), var(--lim));
Temani Afif suggested a simpler version that would multiply --a by a very large number in order to produce a superunitary value.
--sign: clamp(-1, var(--a)*10000, 1);
I eventually settled on dividing --a by the limit value because it just feels a bit more intuitive to see what minimum non-zero value it won’t go below.
--lim: .000001; --sign: clamp(-1, var(--a)/var(--lim), 1);
--round (as well as --ceil and --floor)
This is one I was stuck on for a while until I got a clever suggestion for a similar problem from Christian Schaefer. Just like the case of the sign, this only works on unitless values and requires registering the --round variable as an <integer> so that we force rounding on whatever value we set it to:
@property --round { syntax: '<integer>'; initial-value: 0; inherits: false /* or true depending on context */ } .my-elem { --round: var(--a); }
By extension, we can get --floor and --ceil if we subtract or add .5:
@property --floor { syntax: '<integer>'; initial-value: 0; inherits: false /* or true depending on context */ } @property --ceil { syntax: '<integer>'; initial-value: 0; inherits: false /* or true depending on context */ } .my-elem { --floor: calc(var(--a) - .5); --ceil: calc(var(--a) + .5) }
--mod
This builds on the --floor technique in order to get an integer quotient, which then allows us to get the modulo value. This means that both our values must be unitless.
@property --floor { syntax: '<integer>'; initial-value: 0; inherits: false /* or true depending on context */ } .my-elem { --floor: calc(var(--a)/var(--b) - .5); --mod: calc(var(--a) - var(--b)*var(--floor)) }
Use cases
What sort of things can we do with the technique? Let’s take a good look at three use cases.
Effortless symmetry in staggered animations (and not only!)
While the absolute value can help us get symmetrical results for a lot of properties, animation-delay and transition-delay are the ones where I’ve been using it the most, so let’s see some examples of that!
We put --n items within a container, each of these items having an index --i. Both --n and --i are variables we pass to the CSS via style attributes.
- let n = 16; .wrap(style=`--n: ${n}`) - for(let i = 0; i < n; i++) .item(style=`--i: ${i}`)
This gives us the following compiled HTML:
<div class='wrap' style='--n: 16'> <div class='item' style='--i: 0'></div> <div class='item' style='--i: 1'></div> <!-- more such items --> </div>
We set a few styles such that the items are laid out in a row and are square with a non-zero edge length:
$r: 2.5vw; .wrap { display: flex; justify-content: space-evenly; } .item { padding: $r; }
The result so far.
Now we add two sets of keyframes to animate a scaling transform and a box-shadow. The first set of keyframes, grow, makes our items scale up from nothing at 0% to full size at 50%, after which they stay at their full size until the end. The second set of keyframes, melt, shows us the items having inset box shadows that cover them fully up to the midway point in the animation (at 50%). That’s also when the items reach full size after growing from nothing. Then the spread radius of these inset shadows shrinks until it gets down to nothing at 100%.
$r: 2.5vw; .item { padding: $r; animation: a $t infinite; animation-name: grow, melt; } @keyframes grow { 0% { transform: scale(0); } 50%, 100% { transform: none; } } @keyframes melt { 0%, 50% { box-shadow: inset 0 0 0 $r; } 100% { box-shadow: inset 0 0; } }
The base animation (live demo).
Now comes the interesting part! We compute the middle between the index of the first item and that of the last one. This is the arithmetic mean of the two (since our indices are zero-based, the first and last are 0 and n - 1 respectively):
--m: calc(.5*(var(--n) - 1));
We get the absolute value, --abs, of the difference between this middle, --m, and the item index, --i, then use it to compute the animation-delay:
--abs: max(var(--m) - var(--i), var(--i) - var(--m)); animation: a $t calc(var(--abs)/var(--m)*#{$t}) infinite backwards; animation-name: grow, melt;
The absolute value ,--abs, of the difference between the middle, --m, and the item index, --i, can be as small as 0 (for the middle item, if --n is odd) and as big as --m (for the end items). This means dividing it by --m always gives us a value in the [0, 1] interval, which we then multiply with the animation duration $t to ensure every item has a delay between 0s and the animation-duration.
Note that we’ve also set animation-fill-mode to backwards. Since most items will start the animations later, this tells the browser to keep them with the styles in the 0% keyframes until then.
In this particular case, we wouldn’t see any difference without it either because, while the items would be at full size (not scaled to nothing like in the 0% keyframe of the grow animation), they would also have no box-shadow until they start animating. However, in a lot of other cases, it does make a difference and we shouldn’t forget about it.
Another possibility (one that doesn’t involve setting the animation-fill-mode) would be to ensure the animation-delay is always smaller or at most equal to 0 by subtracting a full animation-duration out of it.
--abs: max(var(--m) - var(--i), var(--i) - var(--m)); animation: a $t calc((var(--abs)/var(--m) - 1)*#{$t}) infinite; animation-name: grow, melt;
Both options are valid, and which one you use depends on what you prefer to happen at the very beginning. I generally tend to go for negative delays because they make more sense when recording the looping animation to make a gif like the one below, which illustrates how the animation-delay values are symmetrical with respect to the middle.
The staggered looping animation.
For a visual comparison between the two options, you can rerun the following demo to see what happens at the very beginning.
CodePen Embed Fallback
A fancier example would be the following:
Navigation links sliding up and then back down with a delay proportional to how far they are from the selected one.
Here, each and every one of the --n navigation links and corresponding recipe articles have an index --idx. Whenever a navigation link is hovered or focused, its --idx value is read and set to the current index, --k, on the body. If none of these items is hovered or focused, --k gets set to a value outside the [0, n) interval (e.g. -1).
The absolute value, --abs, of the difference between --k and a link’s index, --idx, can tell us whether that’s the currently selected (hovered or focused) item. If this absolute value is 0, then our item is the currently selected one (i.e. --not-sel is 0 and --sel is 1). If this absolute value is bigger than 0, then our item is not the currently selected one (i.e. --not-sel is 1 and --sel is 0).
Given both --idx and --k are integers, it results that their difference is also an integer. This means the absolute value, --abs, of this difference is either 0 (when the item is selected), or bigger or equal to 1 (when the item is not selected).
When we put all of this into code, this is what we get:
--abs: Max(var(--k) - var(--idx), var(--idx) - var(--k)); --not-sel: Min(1, var(--abs)); --sel: calc(1 - var(--not-sel));
The --sel and --not-sel properties (which are always integers that always add up to 1) determine the size of the navigation links (the width in the wide screen scenario and the height in the narrow screen scenario), whether they’re greyscaled or not and whether or not their text content is hidden. This is something we won’t get into here, as it is outside the scope of this article and I’ve already explained in a lot of detail in a previous one.
What is relevant here is that, when a navigation link is clicked, it slides out of sight (up in the wide screen case, and left in the narrow screen case), followed by all the others around it, each with a transition-delay that depends on how far they are from the one that was clicked (that is, on the absolute value, --abs, of the difference between their index, --idx, and the index of the currently selected item, --k), revealing the corresponding recipe article. These transition-delay values are symmetrical with respect to the currently selected item.
transition: transform 1s calc(var(--abs)*.05s);
The actual transition and delay are actually a bit more complex because more properties than just the transform get animated and, for transform in particular, there’s an additional delay when going back from the recipe article to the navigation links because we wait for the <article> element to disappear before we let the links slide down. But what were’re interested in is that component of the delay that makes the links is closer to the selected one start sliding out of sight before those further away. And that’s computed as above, using the --abs variable.
You can play with the interactive demo below.
CodePen Embed Fallback
Things get even more interesting in 2D, so let’s now make our row a grid!
We start by changing the structure a bit so that we have 8 columns and 8 rows (which means we have 8·8 = 64 items in total on the grid).
- let n = 8; - let m = n*n; style - for(let i = 0; i < n; i++) | .item:nth-child(#{n}n + #{i + 1}) { --i: #{i} } | .item:nth-child(n + #{n*i + 1}) { --j: #{i} } .wrap(style=`--n: ${n}`) - for(let i = 0; i < m; i++) .item
The above Pug code compiles to the following HTML:
<style> .item:nth-child(8n + 1) { --i: 0 } /* items on 1st column */ .item:nth-child(n + 1) { --j: 0 } /* items starting from 1st row */ .item:nth-child(8n + 2) { --i: 1 } /* items on 2nd column */ .item:nth-child(n + 9) { --j: 1 } /* items starting from 2nd row */ /* 6 more such pairs */ </style> <div class='wrap' style='--n: 8'> <div class='item'></div> <div class='item'></div> <!-- 62 more such items --> </div>
Just like the previous case, we compute a middle index, --m, but since we’ve moved from 1D to 2D, we now have two differences in absolute value to compute, one for each of the two dimensions (one for the columns, --abs-i, and one for the rows, --abs-j).
--m: calc(.5*(var(--n) - 1)); --abs-i: max(var(--m) - var(--i), var(--i) - var(--m)); --abs-j: max(var(--m) - var(--j), var(--j) - var(--m));
We use the exact same two sets of @keyframes, but the animation-delay changes a bit, so it depends on both --abs-i and --abs-j. These absolute values can be as small as 0 (for tiles in the dead middle of the columns and rows) and as big as --m (for tiles at the ends of the columns and rows), meaning that the ratio between either of them and --m is always in the [0, 1] interval. This means the sum of these two ratios is always in the [0, 2] interval. If we want to reduce it to the [0, 1] interval, we need to divide it by 2 (or multiply by .5, same thing).
animation-delay: calc(.5*(var(--abs-i)/var(--m) + var(--abs-j)/var(--m))*#{$t});
This gives us delays that are in the [0s, $t] interval. We can take the denominator, var(--m), out of the parenthesis to simplify the above formula a bit:
animation-delay: calc(.5*(var(--abs-i) + var(--abs-j))/var(--m)*#{$t});
Just like the previous case, this makes grid items start animating later the further they are from the middle of the grid. We should use animation-fill-mode: backwards to ensure they stay in the state specified by the 0% keyframes until the delay time has elapsed and they start animating.
Alternatively, we can subtract one animation duration $t from all delays to make sure all grid items have already started their animation when the page loads.
animation-delay: calc((.5*(var(--abs-i) + var(--abs-j))/var(--m) - 1)*#{$t});
This gives us the following result:
The staggered 2D animation (live demo).
Let’s now see a few more interesting examples. We won’t be going into details about the “how” behind them as the symmetrical value technique works exactly the same as for the previous ones and the rest is outside the scope of this article. However, there is a link to a CodePen demo in the caption for each of the examples below, and most of these Pens also come with a recording that shows me coding them from scratch.
In the first example, each grid item is made up of two triangles that shrink down to nothing at opposite ends of the diagonal they meet along and then grow back to full size. Since this is an alternating animation, we let the delays to stretch across two iterations (a normal one and a reversed one), which means we don’t divide the sum of ratios in half anymore and we subtract 2 to ensure every item has a negative delay.
animation: s $t ease-in-out infinite alternate; animation-delay: calc(((var(--abs-i) + var(--abs-j))/var(--m) - 2)*#{$t});
Grid wave: pulsing triangles (live demo)
In the second example, each grid item has a gradient at an angle that animates from 0deg to 1turn. This is possible via Houdini as explained in this article about the state of animating gradients with CSS.
Field wave: cell gradient rotation (live demo)
The third example is very similar, except the animated angle is used by a conic-gradient instead of a linear one and also by the hue of the first stop.
Rainbow hour wave (live demo)
In the fourth example, each grid cell contains seven rainbow dots that oscillate up and down. The oscillation delay has a component that depends on the cell indices in the exact same manner as the previous grids (the only thing that’s different here is the number of columns differs from the number of rows, so we need to compute two middle indices, one along each of the two dimensions) and a component that depends on the dot index, --idx, relative to the number of dots per cell, --n-dots.
--k: calc(var(--idx)/var(--n-dots)); --mi: calc(.5*(var(--n-cols) - 1)); --abs-i: max(var(--mi) - var(--i), var(--i) - var(--mi)); --mj: calc(.5*(var(--n-rows) - 1)); --abs-j: max(var(--mj) - var(--j), var(--j) - var(--mj)); animation-delay: calc((var(--abs-i)/var(--mi) + var(--abs-j)/var(--mj) + var(--k) - 3)*#{$t});
Rainbow dot wave: dot oscillation (live demo)
In the fifth example, the tiles making up the cube faces shrink and move inwards. The animation-delay for the top face is computed exactly as in our first 2D demo.
Breathe into me: neon waterfall (live demo and a previous iteration)
In the sixth example, we have a grid of columns oscillating up and down.
Column wave (live demo)
The animation-delay isn’t the only property we can set to have symmetrical values. We can also do this with the items’ dimensions. In the seventh example below, the tiles are distributed around half a dozen rings starting from the vertical (y) axis and are scaled using a factor that depends on how far they are from the top point of the rings. This is basically the 1D case with the axis curved on a circle.
Circular grid melt (live demo)
The eighth example shows ten arms of baubles that wrap around a big sphere. The size of these baubles depends on how far they are from the poles, the closest ones being the smallest. This is done by computing the middle index, --m, for the dots on an arm and the absolute value, --abs, of the difference between it and the current bauble index, --j, then using the ratio between this absolute value and the middle index to get the sizing factor, --f, which we then use when setting the padding.
--m: calc(.5*(var(--n-dots) - 1)); --abs: max(var(--m) - var(--j), var(--j) - var(--m)); --f: calc(1.05 - var(--abs)/var(--m)); padding: calc(var(--f)*#{$r});
Travel inside the sphere (live demo)
Different styles for items before and after a certain (selected or middle) one
Let’s say we have a bunch of radio buttons and labels, with the labels having an index set as a custom property, --i. We want the labels before the selected item to have a green background, the label of the selected item to have a blue background and the rest of the labels to be grey. On the body, we set the index of the currently selected option as another custom property, --k.
- let n = 8; - let k = Math.round((n - 1)*Math.random()); body(style=`--k: ${k}`) - for(let i = 0; i < n; i++) - let id = `r${i}`; input(type='radio' name='r' id=id checked=i===k) label(for=id style=`--i: ${i}`) Option ##{i}
This compiles to the following HTML:
<body style='--k: 1'> <input type='radio' name='r' id='r0'/> <label for='r0' style='--i: 0'>Option #0</label> <input type='radio' name='r' id='r1' checked='checked'/> <label for='r1' style='--i: 1'>Option #1</label> <input type='radio' name='r' id='r2'/> <label for='r2' style='--i: 2'>Option #2</label> <!-- more options --> </body>
We set a few layout and prettifying styles, including a gradient background on the labels that creates three vertical stripes, each occupying a third of the background-size (which, for now, is just the default 100%, the full element width):
$c: #6daa7e, #335f7c, #6a6d6b; body { display: grid; grid-gap: .25em 0; grid-template-columns: repeat(2, max-content); align-items: center; font: 1.25em/ 1.5 ubuntu, trebuchet ms, sans-serif; } label { padding: 0 .25em; background: linear-gradient(90deg, nth($c, 1) 33.333%, nth($c, 2) 0 66.667%, nth($c, 3) 0); color: #fff; cursor: pointer; }
The result so far.
From the JavaScript, we update the value of --k whenever we select a different option:
addEventListener('change', e => { let _t = e.target; document.body.style.setProperty('--k', +_t.id.replace('r', '')) })
Now comes the interesting part! For our label elements, we compute the sign, --sgn, of the difference between the label index, --i, and the index of the currently selected option, --k. We then use this --sgn value to compute the background-position when the background-size is set to 300% — that is, three times the label’s width because we may have of three possible backgrounds: one for the case when the label is for an option before the selected one, a second for the case when the label is for the selected option, and a third for the case when the label is for an option after the selected one.
--sgn: clamp(-1, var(--i) - var(--k), 1); background: linear-gradient(90deg, nth($c, 1) 33.333%, nth($c, 2) 0 66.667%, nth($c, 3) 0) calc(50%*(1 + var(--sgn)))/ 300%
If --i is smaller than --k (the case of a label for an option before the selected one), then --sgn is -1 and the background-position computes to 50%*(1 + -1) = 50%*0 = 0%, meaning we only see the first vertical stripe (the green one).
If --i is equal --k (the case of the label for the selected option), then --sgn is 0 and the background-position computes to 50%*(1 + 0) = 50%*1 = 50%, so we only see the vertical stripe in the middle (the blue one).
If --i is greater than --k (the case of a label for an option after the selected one), then --sgn is 1 and the background-position computes to 50%*(1 + 1) = 50%*2 = 100%, meaning we only see the last vertical stripe (the grey one).
CodePen Embed Fallback
A more aesthetically appealing example would be the following navigation where the vertical bar is on the side closest to the selected option and, for the selected one, it spreads across the entire element.
This uses a structure that’s similar to that of the previous demo, with radio inputs and labels for the navigation items. The moving “background” is actually an ::after pseudo-element whose translation value depends on the sign, --sgn. The text is a ::before pseudo-element whose position is supposed to be in the middle of the white area, so its translation value also depends on --sgn.
/* relevant styles */ label { --sgn: clamp(-1, var(--k) - var(--i), 1); &::before { transform: translate(calc(var(--sgn)*-.5*#{$pad})) } &::after { transform: translate(calc(var(--sgn)*(100% - #{$pad}))) } }
CodePen Embed Fallback
Let’s now quickly look at a few more demos where computing the sign (and maybe the absolute value as well) comes in handy.
First up, we have a square grid of cells with a radial-gradient whose radius shrinks from covering the entire cell to nothing. This animation has a delay computed as explained in the previous section. What’s new here is that the coordinates of the radial-gradient circle depend on where the cell is positioned with respect to the middle of the grid — that is, on the signs of the differences between the column --i and row --j indices and the middle index, --m.
/* relevant CSS */ $t: 2s; @property --p { syntax: '<length-percentage>'; initial-value: -1px; inherits: false; } .cell { --m: calc(.5*(var(--n) - 1)); --dif-i: calc(var(--m) - var(--i)); --abs-i: max(var(--dif-i), -1*var(--dif-i)); --sgn-i: clamp(-1, var(--dif-i)/.5, 1); --dif-j: calc(var(--m) - var(--j)); --abs-j: max(var(--dif-j), -1*var(--dif-j)); --sgn-j: clamp(-1, var(--dif-j)/.5, 1); background: radial-gradient(circle at calc(50% + 50%*var(--sgn-i)) calc(50% + 50%*var(--sgn-j)), currentcolor var(--p), transparent calc(var(--p) + 1px)) nth($c, 2); animation-delay: calc((.5*(var(--abs-i) + var(--abs-j))/var(--m) - 1)*#{$t}); } @keyframes p { 0% { --p: 100%; } }
Sinking feeling (live demo)
Then we have a double spiral of tiny spheres where both the sphere diameter --d and the radial distance --x that contributes to determining the sphere position depend on the absolute value --abs of the difference between each one’s index, --i, and the middle index, --m. The sign, --sgn, of this difference is used to determine the spiral rotation direction. This depends on where each sphere is with respect to the middle – that is, whether its index ,--i, is smaller or bigger than the middle index, --m.
/* relevant styles */ --m: calc(.5*(var(--p) - 1)); --abs: max(calc(var(--m) - var(--i)), calc(var(--i) - var(--m))); --sgn: clamp(-1, var(--i) - var(--m), 1); --d: calc(3px + var(--abs)/var(--p)*#{$d}); /* sphere diameter */ --a: calc(var(--k)*1turn/var(--n-dot)); /* angle used to determine sphere position */ --x: calc(var(--abs)*2*#{$d}/var(--n-dot)); /* how far from spiral axis */ --z: calc((var(--i) - var(--m))*2*#{$d}/var(--n-dot)); /* position with respect to screen plane */ width: var(--d); height: var(--d); transform: /* change rotation direction by changing x axis direction */ scalex(var(--sgn)) rotate(var(--a)) translate3d(var(--x), 0, var(--z)) /* reverse rotation so the sphere is always seen from the front */ rotate(calc(-1*var(--a))); /* reverse scaling so lighting on sphere looks consistent */ scalex(var(--sgn))
No perspective (live demo)
Finally, we have a grid of non-square boxes with a border. These boxes have a mask created using a conic-gradient with an animated start angle, --ang. Whether these boxes are flipped horizontally or vertically depends on where they are with respect to the middle – that is, on the signs of the differences between the column --i and row --j indices and the middle index, --m. The animation-delay depends on the absolute values of these differences and is computed as explained in the previous section. We also have a gooey filter for a nicer “wormy” look, but we won’t be going into that here.
/* relevant CSS */ $t: 1s; @property --ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; } .box { --m: calc(.5*(var(--n) - 1)); --dif-i: calc(var(--i) - var(--m)); --dif-j: calc(var(--j) - var(--m)); --abs-i: max(var(--dif-i), -1*var(--dif-i)); --abs-j: max(var(--dif-j), -1*var(--dif-j)); --sgn-i: clamp(-1, 2*var(--dif-i), 1); --sgn-j: clamp(-1, 2*var(--dif-j), 1); transform: scale(var(--sgn-i), var(--sgn-j)); mask: repeating-conic-gradient(from var(--ang, 0deg), red 0% 12.5%, transparent 0% 50%); animation: ang $t ease-in-out infinite; animation-delay: calc(((var(--abs-i) + var(--abs-j))/var(--n) - 1)*#{$t}); } @keyframes ang { to { --ang: .5turn; } }
Consumed by worms (live demo)
Time (and not only) formatting
Let’s say we have an element for which we store a number of seconds in a custom property, --val, and we want to display this in a mm:ss format, for example.
We use the floor of the ratio between --val and 60 (the number of seconds in a minute) to get the number of minutes and modulo for the number of seconds past that number of minutes. Then we use a clever little counter trick to display the formatted time in a pseudo-element.
@property --min { syntax: '<integer>'; initial-value: 0; inherits: false; } code { --min: calc(var(--val)/60 - .5); --sec: calc(var(--val) - var(--min)*60); counter-reset: min var(--min) sec var(--sec); &::after { /* so we get the time formatted as 02:09 */ content: counter(min, decimal-leading-zero) ':' counter(sec, decimal-leading-zero); } }
This works in most situations, but we encounter a problem when --val is exactly 0. In this case, 0/60 is 0 and then subtracting .5, we get -.5, which gets rounded to what’s the bigger adjacent integer in absolute value. That is, -1, not 0! This means our result will end up being -01:60, not 00:00!
Fortunately, we have a simple fix and that’s to slightly alter the formula for getting the number of minutes, --min:
--min: max(0, var(--val)/60 - .5);
There are other formatting options too, as illustrated below:
/* shows time formatted as 2:09 */ content: counter(min) ':' counter(sec, decimal-leading-zero); /* shows time formatted as 2m9s */ content: counter(min) 'm' counter(sec) 's';
We can also apply the same technique to format the time as hh:mm:ss (live test).
@property --hrs { syntax: '<integer>'; initial-value: 0; inherits: false; } @property --min { syntax: '<integer>'; initial-value: 0; inherits: false; } code { --hrs: max(0, var(--val)/3600 - .5); --mod: calc(var(--val) - var(--hrs)*3600); --min: max(0, var(--mod)/60 - .5); --sec: calc(var(--mod) - var(--min)*60); counter-reset: hrs var(--hrs) var(--min) sec var(--sec); &::after { /* so we get the time formatted as 00:02:09 */ content: counter(hrs, decimal-leading-zero) ':' counter(min, decimal-leading-zero) ':' counter(sec, decimal-leading-zero); } }
This is a technique I’ve used for styling the output of native range sliders such as the one below.
Styled range input indicating time (live demo)
Time isn’t the only thing we can use this for. Counter values have to be integer values, which means the modulo trick also comes in handy for displaying decimals, as in the second slider seen below.
Styled range inputs, one of which has a decimal output (live demo)
A couple more such examples:
Styled range inputs, one of which has a decimal output (live demo)
Styled range inputs, one of which has a decimal output (live demo)
Even more use cases
Let’s say we have a volume slider with an icon at each end. Depending on the direction we move the slider’s thumb in, one of the two icons gets highlighted. This is possible by getting the absolute value, --abs, of the difference between each icon’s sign, --sgn-ico (-1 for the one before the slider, and 1 for the one after the slider), and the sign of the difference, --sgn-dir, between the slider’s current value, --val, and its previous value, --prv. If this is 0, then we’re moving in the direction of the current icon so we set its opacity to 1. Otherwise, we’re moving away from the current icon, so we keep its opacity at .15.
This means that, whenever the range input’s value changes, not only do we need to update its current value, --val, on its parent, but we need to update its previous value, which is another custom property, --prv, on the same parent wrapper:
addEventListener('input', e => { let _t = e.target, _p = _t.parentNode; _p.style.setProperty('--prv', +_p.style.getPropertyValue('--val')) _p.style.setProperty('--val', +_t.value) })
The sign of their difference is the sign of the direction, --sgn-dir, we’re going in and the current icon is highlighted if its sign, --sgn-ico, and the sign of the direction we’re going in, --sgn-dir, coincide. That is, if the absolute value, --abs, of their difference is 0 and, at the same time, the parent wrapper is selected (it’s either being hovered or the range input in it has focus).
[role='group'] { --dir: calc(var(--val) - var(--prv)); --sgn-dir: clamp(-1, var(--dir), 1); --sel: 0; /* is the slider focused or hovered? Yes 1/ No 0 */ &:hover, &:focus-within { --sel: 1; } } .ico { --abs: max(var(--sgn-dir) - var(--sgn-ico), var(--sgn-ico) - var(--sgn-dir)); --hlg: calc(var(--sel)*(1 - min(1, var(--abs)))); /* highlight current icon? Yes 1/ No 0 */ opacity: calc(1 - .85*(1 - var(--hlg))); }
CodePen Embed Fallback
Another use case is making property values of items on a grid depend on the parity of the sum of horizontal --abs-i and vertical --abs-j distances from the middle, --m. For example, let’s say we do this for the background-color:
@property --floor { syntax: '<integer>'; initial-value: 0; inherits: false; } .cell { --m: calc(.5*(var(--n) - 1)); --abs-i: max(var(--m) - var(--i), var(--i) - var(--m)); --abs-j: max(var(--m) - var(--j), var(--j) - var(--m)); --sum: calc(var(--abs-i) + var(--abs-j)); --floor: max(0, var(--sum)/2 - .5); --mod: calc(var(--sum) - var(--floor)*2); background: hsl(calc(90 + var(--mod)*180), 50%, 65%); }
Background depending on parity of sum of horizontal and vertical distances to the middle (live demo)
We can spice things up by using the modulo 2 of the floor of the sum divided by 2:
@property --floor { syntax: '<integer>'; initial-value: 0; inherits: false; } @property --int { syntax: '<integer>'; initial-value: 0; inherits: false; } .cell { --m: calc(.5*(var(--n) - 1)); --abs-i: max(var(--m) - var(--i), var(--i) - var(--m)); --abs-j: max(var(--m) - var(--j), var(--j) - var(--m)); --sum: calc(var(--abs-i) + var(--abs-j)); --floor: max(0, var(--sum)/2 - .5); --int: max(0, var(--floor)/2 - .5); --mod: calc(var(--floor) - var(--int)*2); background: hsl(calc(90 + var(--mod)*180), 50%, 65%); }
A more interesting variation of the previous demo (live demo)
We could also make both the direction of a rotation and that of a conic-gradient() depend on the same parity of the sum, --sum, of horizontal --abs-i and vertical --abs-j distances from the middle, --m. This is achieved by horizontally flipping the element if the sum, --sum, is even. In the example below, the rotation and size are also animated via Houdini (they both depend on a custom property, --f, which we register and then animate from 0 to 1), and so are the worm hue, --hue, and the conic-gradient() mask, both animations having a delay computed exactly as in previous examples.
@property --floor { syntax: '<integer>'; initial-value: 0; inherits: false; } .🐛 { --m: calc(.5*(var(--n) - 1)); --abs-i: max(var(--m) - var(--i), var(--i) - var(--m)); --abs-j: max(var(--m) - var(--j), var(--j) - var(--m)); --sum: calc(var(--abs-i) + var(--abs-j)); --floor: calc(var(--sum)/2 - .5); --mod: calc(var(--sum) - var(--floor)*2); --sgn: calc(2*var(--mod) - 1); /* -1 if --mod is 0; 1 id --mod is 1 */ transform: scalex(var(--sgn)) scale(var(--f)) rotate(calc(var(--f)*180deg)); --hue: calc(var(--sgn)*var(--f)*360); }
Grid wave: triangular rainbow worms (live demo).
Finally, another big use case for the techniques explained so far is shading not just convex, but also concave animated 3D shapes using absolutely no JavaScript! This is one topic that’s absolutely massive on its own and explaining everything would take an article as long as this one, so I won’t be going into it at all here. But I have made a few videos where I code a couple of such basic pure CSS 3D shapes (including a wooden star and a differently shaped metallic one) from scratch and you can, of course, also check out the CSS for the following example on CodePen.
Musical toy (live demo)
The post Using Absolute Value, Sign, Rounding and Modulo in CSS Today appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.
Using Absolute Value, Sign, Rounding and Modulo in CSS Today published first on https://deskbysnafu.tumblr.com/
0 notes