投稿時間:2023-02-23 13:11:37 RSSフィード2023-02-23 13:00 分まとめ(11件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT 気になる、記になる… ヤマダウェブコムで「MacBook Air (M2)」のCTOモデルが最大6万円オフになる在庫一掃セール開催中 ー 他にも多数のApple製品が対象 https://taisy0.com/2023/02/23/168834.html apple 2023-02-23 03:59:00
IT 気になる、記になる… 新型「Mac Pro」の拡張モジュール?? ー 「iOS 16.4」から「ComputeModule」というデバイスの存在が明らかに https://taisy0.com/2023/02/23/168831.html apple 2023-02-23 03:07:10
IT ITmedia 総合記事一覧 [ITmedia News] シグマ、ニコンZマウントに参入 3本のAPS-Cレンズを4月に投入 https://www.itmedia.co.jp/news/articles/2302/23/news059.html 発売予定 2023-02-23 12:20:00
TECH Techable(テッカブル) CESイノベーションアワード受賞!歯磨きが10秒で終了するプレミアム電動歯ブラシが日本で発売開始 https://techable.jp/archives/196802 発売開始 2023-02-23 03:00:12
python Pythonタグが付けられた新着投稿 - Qiita if文 https://qiita.com/rion3376/items/2e565f8bd4ea952a3043 elifxgtprint 2023-02-23 12:34:34
python Pythonタグが付けられた新着投稿 - Qiita 型とキャスト https://qiita.com/rion3376/items/e464d7b54feb5b63b841 aprinttypeasixpitext 2023-02-23 12:04:13
海外TECH DEV Community Notas rápidas de Flexbox https://dev.to/oswald_echeverri/notas-rapidas-de-flexbox-51b9 Notas rápidas de Flexbox Tabla de contenido Idea del postLista de etiquetas por defecto en inline y blockContexto flex y flex directionLista de valores de propiedadesManejo de contenedoresManejo de item o elemento Idea del postEsta es una guía rápida de flexbox y el objetivo es que tengas en mano los pasos u anotaciones para usarloPor último Si te gusto este post déjame un ️ Lista de etiquetas por defecto en inline y blockPor defecto html contiene etiquetas que tienen dirección en línea o en bloque sin necesidad de usar la propiedad flex y conocer las etiquetas nos ayudara con más precisión manipular los ítems en nuestros contenedores A continuación una lista de las etiquetas más usadas Etiquetas en bloqueEtiquetas en linea lt address gt lt img gt lt article gt lt span gt lt aside gt lt button gt lt blockquote gt lt input gt lt div gt lt label gt lt fieldset gt lt select gt lt figcaption gt lt textarea gt lt figure gt lt br gt lt footer gt lt a gt lt form gt lt sup gt lt h gt lt sub gt lt header gt lt script gt lt hgroup gt lt q gt lt hr gt lt object gt lt li gt lt map gt lt main gt lt i gt lt nav gt lt var gt lt ol gt lt time gt lt output gt lt strong gt lt p gt lt em gt lt pre gt lt code gt lt section gt lt cite gt lt table gt lt acronym gt lt tfoot gt lt small gt lt ul gt lt big gt Contexto flex y flex directionBásicamente para usar flexbox necesitamos un elemento contenedor y que su contenedor tenga hijos Al contenedor se lo conoce flex container y a los hijos se los conoce como flex itemsdisplay flex es la propiedad para activar flexboxAdemás de activar flexbox con la propiedad display flex se necesita darle una dirección a través de la propiedad flex direction El valor puede ser row o columnLa dirección que se defina en el flex direction serála dirección principal o main axis y la dirección que no séescribióserála dirección secundaria o cross axis Usar la propiedad flex direction nos da la ventaja de poder invertir el main axis usando flex direction row reverse o flex direccion column reverse como lo vemos en las siguinetes imagenes Si deseamos activar flexbox y en el mismo valor darle la dirección podemos usar display inline para trabajar en filas o display block para trabajar en columnas Cuando se trabaja en fila los items tienen el alto y ancho de su contenido por defecto y no poseen algunas propiedades que en cambio trabajando en bloque o columna si se pueden aprovechar como alto ancho y margenes Entonces para solucionar eso podemos usar display en fila con las propiedades de bloque a esto lo llamamos display inline block Lista de valores de propiedadesPrimero conoceremos los valores que se pueden usar en las propiedades flex start Envia el o los elementos al comienzo del flex containerflex end Envia el o los elementos al final del flex containercenter Centra el o los elementos en el flex container space between Distribuye los espacios de los elementos en el flex container ponendo el primer y el ultimo elemento al raz del container space around Distribuye los espacios de los elementos en el flex container sin poner el primer y el ultimo elemento al raz del container esta opcion añade unos margenes entre item por defecto en algunos casos no parecieran estar distribuidos equitativamente space evenly Distribuye los espacios de los elementos en el flex container sin poner el primer y el ultimo elemento al raz del container esta opcion si distribuye equitativamente los espacios baseline Los flex items se alinearán en la dirección de su línea base esta opción se ejecuta en el contenedor no en el ítem Ejemplo nowrap Permite que el contenido se desborde del flex containerwrap No permite que el contenido se desborde del flex container reduciendo el tamaño de los elementoswrap reverse No permite que el contenido se desborde del flex container reduciendo el tamaño de los elementos además invierte su dirección Manejo de contenedoresFlex wrap Maneja el desbordamiento del flex container Sus propiedades son nowrapwrapwrap reverse Justify content Justifica o maneja la alineación en la dirección principal o main axis del flex container Sus propiedades son flex startflex endcenterspace betweenspace aroundspace evenlyAlign items Alinea el contenido en la dirección secundaria o cross axis Sus porpiedades son flex start flex endcenterbaselineAlign content Maneja la alineacion del flex container siempre y cuando halla más de una fila en tal caso el flex direction sea row o halla más de una columna si el flex direction es column Sus propiedades son flex startflex endcenterspace betweenspace aroundspace evenly Manejo de item o elementoLas siguientes propiedades sirven para el manejo individual del item o elemento Un contenedor también puede ser un ítem si es hijo de un flex container padre Order Ordena los flex items en el main axis El ítem que tenga el menor número seráel primero Por defecto los ítems tiene valor de En el siguiente ejemplo el main axis es de izquierda a derecha o row y poniéndole el valor de lo enviamos al final Flex grow Es el factor de crecimiento de los flex items en relacion con otros es decir distribuye los espacios sobrantes afectando solo al main axis Su valor se representa en forma de porciones en números enteros En el siguiente ejemplo vemos que exite un espacio sobrante y luego indicamos que los items se distribuyan en porciones iguales de Flex shrink Determina que tanto se encogen los flex items con respecto al otro es decir maneja los espacios faltantes recordando que display flex no permite que su contenido se desborde si no más bien los reduce Siempre que flex shrink tenga un valor positivo no se desborda el flex container Esta propiedad afecta al main axis Por defecto su valor es y no acepta valores negativos pero síel EjemploEn la siguiente imagen podemos observar que flex shrink tiene un valor de esto inmediatamente le quita la propiedad flex shrink y le da el ancho o el alto que este por defecto en el css para el item Flex basis Indica el tamaño de un flex item de forma predominante inclusive a su width base flex grow o flex thrink Si su valor es auto su flex basis sería su height o width Afecta al main axis Ejemplo Si ponemos un flex direction row flex basis px width px Predominaráel flex basisEjemplo Que pasa si un ítem tiene contenido y no tiene width suponiendo que es flex y queremos distribuirlos iguales La solucion Se desborda el contenido pero se distribuye en partes iguales Align self Permite alinear solo a un elemento en el cross axis o direccion secundaria Hace lo mismo que align items y con los mismo valoresflex start flex endcenterbaselineFlex Es el shortcut para ejecutar tres propiedades para ítems al mismo tiempo las cuales son flex grow flex shrink y flex basis Se la usa de la siguiente manera flex valor grow valor shrink valor basisEsta propiedad nos permite distribuir equitativamente los ítems de formas flex flex auto flex 2023-02-23 03:30:12
海外TECH DEV Community Pixelating Images With React/JavaScript https://dev.to/bytebodger/pixelating-images-in-reactjavascript-2ac7 Pixelating Images With React JavaScript NOTE The live web app that encompasses this functionality can be found here All of the underlying code for that site can be found here In the first few articles in this series I discussed the challenges of capturing the true color of real world objects and I showed how to use React JavaScript to capture and render images But now that we have an image loaded we need to start the process of manipulating that image to our needs The first step in that process is to pixelate the image Why pixelate You don t have to pixelate an image if you re going to convert a digital image into a painting But you probably want to First with regard to my particular style of painting I grid out my panels so I know where I m at on the painting at any given point in time Specifically I work on x panels divided into quarter inch squares This means that each painting consists of x squares This works particularly well for me because my style of painting is much more abstract I m not creating true to life images Even though my style has evolved to look ever less pixelated over time I m still working with big clunky blobs of paint on the panel So there s no need to get down to pixel level accuracy when my chosen style of painting is far chunkier As an example this is what one of my panels looks like when I m just about to start painting But even if you re aiming to do a more realistic style of painting you almost certainly don t want to capture ALL of the colors that exist in a given digital image I work from images that are cropped to a height and width of pixels This means that the source image contains more than million pixels Furthermore there are more than million potential colors available in the RGB color space So in a x digital image it s theoretically possible that every single one of those million pixels is a unique color Of course many of those unique colors would be indistinguishable to the human eye And no painter wants to set about mixing up million different colors Even the most realistic of painters needs only to get a general idea of the color palette that will be necessary for the whole painting or at least for a particular section of the painting So it s far more practical to take a digital image that is rich with many millions of technically distinct colors and collapse it down to a handful of reference colors We can accomplish this task by pixelating the image Manipulating the loaded imageIn the last article we loaded a user s image and rendered it on a canvas We started building a useImage Hook that will do most of our image processing But where we left off that hook does nothing but render the original image on the screen The previous state of the useImage Hook looked like this useImage js export const useImage gt const canvas useRef null const context useRef null const image useRef null useEffect gt canvas current document getElementById canvas const create src gt const source src image current src src const newImage new Image newImage src source newImage onload gt image current newImage canvas current width newImage width canvas current height newImage height context current canvas current getContext d alpha false willReadFrequently true context current drawImage newImage let stats pixelate uiState setStats stats return create To be clear the code above doesn t precisely match the useImage Hook that I showed in the last article Specifically I ve added a call to a new function pixelate and I m logging the resulting stats from the image back into our global context at the end of the onload event Also for reference purposes I m going to show you what the new calculations will do to a target image For the sake of this article I m going to use this image I ve chosen this image because skin tones are particularly difficult to get right when doing algorithmic color matching But we won t have to worry about that in this article For the time being I m only concerned with pixelating the image so that it can be processed in larger chunks So let s take a look at the code in our new function pixelate const pixelate gt get dimensions from the image that we just put into the canvas const height width canvas current const stats colorCounts colors map const blockSize looping through every new block that will be created with the pixelation for let y y lt height y blockSize const row for let x x lt width x blockSize const remainingX width x const remainingY height y const blockX remainingX gt blockSize blockSize remainingX const blockY remainingY gt blockSize blockSize remainingY get the image data for the current block and calculate its average color const averageColor calculateAverageColor context current getImageData x y blockX blockY averageColor name averageColor red averageColor green averageColor blue add this color to the row array so it can be added to the image stats row push averageColor if Object hasOwn stats colorCounts averageColor name stats colorCounts averageColor name else stats colorCounts averageColor name stats colors push averageColor draw the new block over the top of the existing image that exists in the canvas context current fillStyle rgb averageColor red averageColor green averageColor blue context current fillRect x y blockX blockY stats map push row return stats This function performs the following steps Grabs the height width parameters from the existing lt canvas gt element Loops through every block that we re gonna create with our new pixelation I don t call them pixels because that gets rather confusing The image already has pixels of them to be exact But for us to pixelate the image we re essentially creating new larger blocks that will be painted over the top of the original image Calls another function to determine the average color in each block Adds the block info to a stats object so we can reference it in future operations Paints the new block over the top of the old image Essentially what we re doing is tiling over the old image with new chunkier blocks that represent the original colors beneath them We do this by looping through the image data The image data is organized on an x y grid with x representing the horizontal position of a pixel and y representing the vertical position of that same pixel We already have the dimensions of our canvas because they reside in the canvas ref So we can use those to instantiate our loops You may notice that getImageData allows us to get the canvas information for all the pixels that reside in any given region on the canvas The getImageData function works like this context getImageData xCoordinateToStartCapture yCoordinateToStartCapture widthOfTheRegionToBeCaptured heightOfTheRegionToBeCaptured So if you already have an image loaded into a canvas and you wanted to grab the data for a region that s pixels wide and pixels tall starting from the pixel that s pixels from the left and pixels from the top you d do this context getImageData That line of code would return an array containing the data for all of the pixels in that particular region of the image In the pixelate function the regions we re grabbing are always squares The size of those regions is determined by the blockSize variable NOTE In the live app blockSize is a configurable variable that s defined by the user through the UI I ve only hardcoded it to in this example for simplicity So now that we see how to loop through the image data and repaint regions of the canvas we need to dive into that calculateAverageColor function Color averagingNow that our pixelate loop is parsing through the image in x blocks we ll have a lot of individual blocks For example the first block in the image meaning the block in the far upper left corner looks like this Obviously I enlarged that original x block by quite a bit so you don t have to squint to look at a pixel by pixel image on your screen But you get the idea This particular block of pixels is quite homogenous Not a lot of color variation there But there are still multiple different colors in this block of pixels For example in this block alone here are a few of the colors I can find with my color picker rgb rgb rgb rgb and many more Even though the block looks quite unicolor it actually contains many slight variations So how do we get the average color for all pixels in the block Thankfully this is fairly straightforward Because for every pixel we can extract the red green and blue values Once we have the red green and blue values you can simply average them all together to get the average red green and blue value for the entire block Then we use the new averaged RGB values to paint the new block on our canvas The calculateAverageColor code looks like this const calculateAverageColor imageData gt let redSum let redCounter let greenSum let greenCounter let blueSum let blueCounter for let x x lt imageData width x for let y y lt imageData height y const red green blue getRgbFromImageData imageData x y if red redSum red redCounter if green greenSum green greenCounter if blue blueSum blue blueCounter return red Math round redSum redCounter green Math round greenSum greenCounter blue Math round blueSum blueCounter We pass in the region of image data that was captured from the original canvas Then we calculate the average RGB values and return them in a convenient object Our new averaged block will look like this again enlarged for convenience All pixels in the image are now the exact same color Full Disclosure If you take a color picker and hover it over the newly averaged block shown above it will still show you a myriad of slightly different colors This isn t a bug in my averaging algorithm It s a side effect from my desktop image editor that happens when you take a unicolor x image and blow it up to x Also you may notice that in the function above it makes a call to another custom function getRgbFromImageData That s basically a helper function which in turn calls getPixelFromImageData which in turn calls getPixelIndex I m not going to bother illustrating all of those smaller helper functions here But if you d like to see them all and all the rest of the code that runs you can feel free to dig through it in the GitHub repo Once the pixelate function has averaged every one of the blocks it will render a new image that looks like this Obviously you re going to lose some image acuity After all we ve just reduced the color density by a factor of But you can t pixelate an image and expect the resulting likeness to not have a few quirks And of course the blockSize variable plays a key role in how accurate our processed image appears Bigger blocks lead to rougher images Smaller blocks produce images that are much closer to the original For example this is the same image pixelated with blockSize And it s much more accurate with blockSize So it may be tempting to ratchet blockSize down to its lowest possible number But the closer that blockSize gets to the more colors and for my purposes paints you ll need to produce to a replica In the next installment This feels like pretty good progress We re now capturing images rendering them onscreen and transforming them by pixelating them But there s still a lot of work to do because we still have no way of knowing how any of the colors in the pixelated image would map to our inventory of real world paints In the next installment I m gonna dive into the hairy world of digital color matching Things get much more intense from that point forward 2023-02-23 03:15:47
海外ニュース Japan Times latest articles K-Pop battle shines spotlight on new wave of shareholder activism in South Korea https://www.japantimes.co.jp/news/2023/02/23/business/kpop-battle-shareholder-activism/ K Pop battle shines spotlight on new wave of shareholder activism in South KoreaThe new protagonists of shareholder activism in Asia are millennials steeped in the local culture who are using that knowledge to take on the old 2023-02-23 12:23:29
海外ニュース Japan Times latest articles Emperor Naruhito expresses sorrow at world suffering and prays for peace https://www.japantimes.co.jp/news/2023/02/23/national/emperor-naruhito-birthday-peace-suffering/ Emperor Naruhito expresses sorrow at world suffering and prays for peaceThe emperor also expressed hopes that people would support each other to overcome challenges like the COVID pandemic and skyrocketing costs of living 2023-02-23 12:07:19
ニュース BBC News - Home Winter storm: North America hit by blizzards and heat wave https://www.bbc.co.uk/news/world-us-canada-64733809?at_medium=RSS&at_campaign=KARANGA warmer 2023-02-23 03:17:49

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)