Rendering form in paragraph [on hold]

I need to preprocess paragraph that is in a custom block in header so I can generate my custom made form inside it, and then render that form in twig. So far I have form, paragraph–request.html.twig file with {{form}} in it, and in my theme.module file I have

function theme_preprocess_paragraph__request(&$ vars){ $ myForm = \Drupal::formBuilder()->getForm(‘\Drupal\theme\src\Form\RequestForm’); $ vars = [ ‘#form’ => $ myForm,]; }

I cleared my cashe but nothing is happening. How can I achieve this?

SVG not rendering in PNG, only renders in Chrome after zooming in/out

I’m trying trying to create a relatively simple background for an SVG image. I’ve created an equivalent in GIMP, applying a radial gradient from the centre to the edge and then applying the “spread” filter.

Version created in GIMP.

I have the following code that accomplishes a similar result, at least in Inkscape.

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg id="wallpaper"   viewBox="0 0 1920 1080" height="1080" width="1920"   xmlns="http://www.w3.org/2000/svg"   version="1.1" >   <defs>     <radialGradient id="gradient">       <stop offset="2.5%" stop-color="#ffffff"/>       <stop offset="100%" stop-color="#000000"/>     </radialGradient>      <clipPath id="gradientClip" clipPathUnits="userSpaceOnUse">       <rect         id="gradientClip-rect" y="0" x="0" height="1080" width="1920"       />     </clipPath>   </defs>     <g id="background" clip-path="url(#gradientClip)">     <rect       id="background-fill" width="1920" height="1080" x="0" y="0"       style="fill:#000000;"     />      <filter id="gradientNoise">       <feTurbulence type="fractalNoise" baseFrequency="50" numOctaves="2" result="turbulence"/>       <feDisplacementMap         in2="turbulence" in="SourceGraphic" scale="540"         xChannelSelector="R" yChannelSelector="G"       />     </filter>      <circle       id="background-gradient" filter="url(#gradientNoise)" fill="url(#gradient)"       cx="960" cy="540" r="960"     />   </g> </svg> 

However, when I rasterize it to a PNG or open it in Chrome (at 100% zoom) all I get is the gradient with no noise.

enter image description here

However again, if I zoom in or out in Chrome the filter applies correctly.

Side-by-side comparison of Chrome rendering the image at 80% and 110%.

Is it possible that there is some kind of issue with this file that only appears when the image is viewed at the size defined in the viewbox? Is there something else that I’m not seeing?

I would have chalked my PNG issue up to the same problem this poster was having if it weren’t for the odd behaviour I’m only noticing when my browser is set to 100% zoom.

Thanks!

How to remove default form tag while rendering output in hook_theme

I am customizing the login form. I have to put all the three forms(login, register, forgotpassword) into one page. I don’t want that unwanted root form tag, how can i remove that one? I am using drupal 7. This is my code.

template.php

function bartik_theme() {

$  items = array();  $  items['user_login'] = array(     'render element' => 'div',     'arguments' => array('form' => NULL),     'variables' => array('form' => NULL),     'path' => drupal_get_path('theme', 'bartik') . '/templates',     'template' => 'user-login',     'preprocess functions' => array(           'bartik_preprocess_user_login'     ), 

);

return $ items;

}

user-login.tpl.php

        <div id="signupbox">             <?php                 $  login_form = drupal_get_form ( 'user_login_block' );                 echo drupal_render ( $  login_form );                  $  forgot_password_form = drupal_get_form ( 'user_pass' );                 echo drupal_render ( $  forgot_password_form );                  $  register_form = drupal_get_form ( 'user_register_form' );                 echo drupal_render ( $  register_form );             ?>         </div> 

My problem is that all the 3 forms are rendering in one more form tag.

My Output:

<form action=”/drupal728/user” method=”post” id=”user-login”>

 <form>Login</form>  <form>Password....</form>  <form>Registration....</form> 

</form>

I don’t want that unwanted root form tag, how can i remove that one? I am using drupal 7.

How do I enable CSR to return the default rendering for a Select column in a list view web part that provides filter values to other list web parts?

I’m attempting to override the rendering of a Select column in a list web part that provides filter values to another list web part. In the code below, I’m attempting to not display the Selector icon for the list web part providing the filter values when the first 7 characters of the “Proficiency_x0020_Level” contain the value “Level 3”. When that value is “Level 3”, I want to display the text “NA”. Otherwise, I would like to see the default selector icons displayed for the “Select” column.

In the code below, the logic for what to do when the value is “Level 3” works just fine. My problem is that I can’t figure out how to return the default format (i.e., the selector icon and it’s underlying link) for the “SelectTitle” column. When using CSR, how does one enable the default rendering of a field? Thanks!


(function () {  // Create an object that have the context information about the fields that we want to change the rendering of.   var SLevlFieldContext = {};   SLevlFieldContext.Templates = {};   SLevlFieldContext.Templates.Fields = {  // Apply the new rendering for these fields on List View   "SelectTitle": { "View": SLevlFieldTemplate}  };  SPClientTemplates.TemplateManager.RegisterTemplateOverrides(SLevlFieldContext);  })();  // This function provides the rendering logic for the list view  function SLevlFieldTemplate(ctx) {    var _SLevlvalue = ctx.CurrentItem["Proficiency_x0020_Level"];   var _subSLevlvalue = _SLevlvalue.substring(0,7)   switch (_subSLevlvalue) {   case "Level 3":   return "<center>NA</center>";  break;    default:  return ctx.CurrentItem.SelectTitle;  break;  } } 

Added the screenshot below to illustrate the outcome I experienced attempting to use Abdul’s recommendation of RenderFieldValueDefault(ctx)

Screenshot added 3/23/2018

Metatag not rendering front-end

I’m using the metatag module to set metadata on a custom content type. I’ve added metatags as a field and added data to pieces of content but when I check the source on the front-end there is no data. I’ve cleared cache and tried with the default theme, still no metadata.

Do I need to manually render these somewhere? Or shouldn’t they already appear in html.html.twig <head-placeholder token="{{ placeholder_token|raw }}">

Font not properly rendering on Ubuntu 18.04 Terminal for Amharic Language

I am trying to write a bash script that uses my native language (Amharic) to echo message but all the letters are overlapping.

I am using Ubuntu 18.04 with Amharic Keyboard Layout

The output should be like this

ከጀፈለ ለከደለጀከለ ለጀፈደለጀፈ …

(This have a proper space between the letters)

So far I have tried changing the:

  • Terminal’s Font
  • System’s Font
  • Other Amharic fonts (Different from the current one)

WebView – MathJax rendering – why taking so long

I am passing an HTML string containing Tex-formatted math to a WebView, which uses the MathJax library (delivered through a CDN) to render the webpage. The problem is, the app takes a long time to complete this whole process. On my Galaxy S7 edge on a good wifi connection, it takes almost 2 minutes to render even a very short string, such as $ $ X^2$ $ . My question is,

  1. Which part of the program is actually responsible for such delay?
  2. How to improve it?

Code:

package com.example.mutas.mathjaxpilot;  import android.Manifest; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.EditText;  public class MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          final String front = "<html>" +                 "    <head>" +                 "        <script src=\'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML\' async></script>" +                 "    </head>" +                 "    <body>";          final String back = " </body>" +                 "</html>" ;           final WebView webView = (WebView) findViewById(R.id.webView);         final EditText editText = (EditText) findViewById(R.id.editText);          WebSettings webSettings = webView.getSettings();         webSettings.setJavaScriptEnabled(true);           editText.setOnClickListener(                 new EditText.OnClickListener() {                     @Override                     public void onClick(View v) {                         String content = editText.getText().toString();                         content = front + "\( " + content + " \)" + back;                         webView.loadData(content, "text/html; charset=utf-8", "UTF-8");                     }                 }         );           if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.INTERNET)                 != PackageManager.PERMISSION_GRANTED) {             // Permission is not granted             ActivityCompat.requestPermissions(MainActivity.this,                     new String[]{Manifest.permission.INTERNET},                     1);         }         //webView.loadUrl("file:///android_asset/test.html");     } } 

Unity3D shader for rendering 2D sprites with a pseudo-glitch effect

I’m making a puzzle game in Unity with sprite-based graphics. When the game is paused, I want to hide most game elements, because I don’t want the player to be able to pause and leisurely think about their next move.

I could just make the sprites invisible, but I decided to do something more stylish; render sprites with pseudo-glitches, simulated in this shader:

Shader "Sprites/Glitch Sprite" {     Properties     {         [NoScaleOffset] _MainTex ("Sprite Atlas", 2D) = "white" {}         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0         [HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)         [PerRendererData] _TextureRect ("Base Texture Rect", Vector) = (0, 0, 0, 0)         // The position and size of this sprite on the original texture atlas     }      SubShader     {         Tags         {             "Queue"="Transparent"             "IgnoreProjector"="True"             "RenderType"="Transparent"             "PreviewType"="Plane"             "CanUseSpriteAtlas"="True"         }          Cull Off         Lighting Off         ZWrite Off         Blend One OneMinusSrcAlpha          Pass         {         CGPROGRAM             #pragma vertex vert             #pragma fragment frag             #pragma target 3.0             #pragma multi_compile_instancing             #pragma multi_compile _ PIXELSNAP_ON             #pragma multi_compile _ ETC1_EXTERNAL_ALPHA             #pragma instancing_options assumeuniformscaling             // Sprites will not scale in my game              #pragma instancing_options nolightmap             #pragma instancing_options nolightprobe             // My game does not use lighting (it's all pixel art)              #include "UnitySprites.cginc"              UNITY_INSTANCING_BUFFER_START(Props)                 UNITY_DEFINE_INSTANCED_PROP(float4, _TextureRect)                 // Sprites are GPU-instanced where supported             UNITY_INSTANCING_BUFFER_END(Props)              // These four properties are set once, when the game is first loaded             uniform float4 _MainTex_TexelSize;             uniform float2 _InitialSeed;             uniform float4 _SpriteRectChunks[128];             // Coordinates of each 8x8 sprite chunk I want to use in the shader             // x,y are the positions (in pixels) of the chunk on the original atlas, z,w are unused and set to 0             uniform int _SpriteRectChunkCount = 0;             // Not all of these vectors are used, so I also pass in how many actually are               struct vert2frag_img             {                 float4 pos : SV_POSITION;                 half2 uv : TEXCOORD0;                 nointerpolation float4 chunk : POSITION1;                 // The chunk selection is done in the vertex shader                  UNITY_VERTEX_INPUT_INSTANCE_ID                 UNITY_VERTEX_OUTPUT_STEREO             };              // Taken from https://stackoverflow.com/a/3451607/1089957             float2 remap(float2 value, float2 low1, float2 high1, float2 low2, float2 high2)             {                 return low2 + (value - low1) * (high2 - low2) / (high1 - low1);             }              // Given a vec2 as a seed, return a number from [0, 1)             // Taken from https://stackoverflow.com/a/10625698/1089957             float random(float2 seed)             {                 const float2 r = float2(                     23.1406926327792690,                     2.6651441426902251                 );                 return frac(cos(fmod(123456789., 1e-7 + 256. * dot(seed, r))));               }              int random(float2 seed, int limit) {                 return (int)round(random(seed) * limit);             }              vert2frag_img vert(appdata_img IN)             {                 vert2frag_img OUT;                  UNITY_SETUP_INSTANCE_ID(IN);                 UNITY_TRANSFER_INSTANCE_ID(IN, OUT);                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);                  OUT.pos = UnityFlipSprite(IN.vertex, _Flip);                 OUT.pos = UnityObjectToClipPos(OUT.pos);                 OUT.uv = IN.texcoord;                  float2 position = mul(unity_ObjectToWorld, float4(0, 0, 0, 1)).xy;                  #ifdef UNITY_INSTANCING_ENABLED                 int index = random(round(position * _InitialSeed * 8 + UNITY_GET_INSTANCE_ID(IN)), _SpriteRectChunkCount);                 #else                 int index = random(round(position * _InitialSeed * 8), _SpriteRectChunkCount);                 #endif                 OUT.chunk = _SpriteRectChunks[index];                  #ifdef PIXELSNAP_ON                 OUT.pos = UnityPixelSnap(OUT.pos);                 #endif                  return OUT;             }              fixed4 frag(vert2frag_img IN) : SV_Target             {                 UNITY_SETUP_INSTANCE_ID(IN);                  float2 pixels = remap(IN.uv, 0, 1, 0, _MainTex_TexelSize.zw);                 // texture coords (range [0, 1]) -> texture pixels (range [0, TextureSize])                  pixels = pixels - UNITY_ACCESS_INSTANCED_PROP(Props, _TextureRect).xy;                 // Sprite pixel coordinate, relative to (0, 0)                  pixels = fmod(pixels, 8);                 // Display glitched sprites in 8x8 chunks                  pixels = pixels + IN.chunk.xy;                 // Back to the sprite                  pixels = remap(pixels, 0, _MainTex_TexelSize.zw, 0, 1);                 // Remap to normalized coordinates                  fixed4 c = tex2D(_MainTex, clamp(pixels, 0, 1));                  c.rgb *= c.a;                 return c;             }          ENDCG         }     } } 

There’s a lot of window dressing, but the actual shader code in the CGPROGRAM block is standard HLSL. This is a screenshot of my game without this shader:

Screenshot, no shader

And this is the same scene, with the shader:

Screenshot, with shader

Here are some relevant facts:

  • All sprites are stored on a single texture atlas.
  • All sprites have a length and width that are a multiple of 8. But their position on the texture atlas might not be.
  • Some sprites in the second screenshot are invisible, even though they should be glitchy like the ones that are. While this is technically a bug, it’s consistent with the style I’m going for, so I will probably leave it as is. If you happen to have a fix to suggest, I’ll try it out and see how it looks, but that’s not the basis of my question.
  • I intend to release this game on a variety of platforms, so make no assumptions about what graphics API (DirectX, OpenGL, etc.) is actually being used. However, this shader will always be written in HLSL (Unity compiles it to other languages as needed).

These are my questions:

  • Are there ways I can optimize this shader?
  • How can ensure this shader runs on as many Unity-supported platforms as possible?
  • How can I gracefully degrade this shader if necessary? I don’t need the effect to look exactly the same on all platforms, but I would like something close enough.

I’m looking for changes I can make in either the actual HLSL code or the surrounding ShaderLab declarations.